Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jun 2002 12:20:04 -0700 (PDT)
From:      Peter Edwards <peter.edwards@openet-telecom.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/37554: [PATCH] Make ELF shared libraries immutable once loaded (like executables)
Message-ID:  <200206131920.g5DJK4V67244@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/37554; it has been noted by GNATS.

From: Peter Edwards <peter.edwards@openet-telecom.com>
To: freebsd-gnats-submit@FreeBSD.org, pmedwards@eircom.net
Cc:  
Subject: Re: kern/37554: [PATCH] Make ELF shared libraries immutable once
 loaded (like executables)
Date: Thu, 13 Jun 2002 20:19:11 +0100

 Hm. This is possibly a nicer way to do it, and certainly a smaller, if more 
 intrusive, patch. It changes the semantics of mmap() somewhat, but I think 
 in a reasonable way, and it avoids all that ugliness in the run-time linker.
 
 Basically, a request for PROT_EXEC on a regular file will cause it to become 
 immutable:
 
 
 --- vm_mmap.c   3 Nov 2001 01:41:10 -0000       1.108.2.5
 +++ vm_mmap.c   13 Jun 2002 19:15:28 -0000
 @@ -406,8 +406,17 @@
 
          error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot,
              flags, handle, pos);
 -       if (error == 0)
 +       if (error == 0) {
                  p->p_retval[0] = (register_t) (addr + pageoff);
 +               /*
 +                * A successful map for a regular file, with execute access:
 +                * mark the vnode immutable.
 +                * XXX: GCC warns, but (handle == 0 || handle == vp)
 +                * I'm not sure of the "correct" way to avoid this.
 +                */
 +               if (handle && vp->v_type == VREG && (prot & PROT_EXEC))
 +                       vp->v_flag |= VTEXT;
 +       }
   done:
          if (fp)
                  fdrop(fp, p);
 
 
 
 Of course, the utility of all this is questionable: I just wanted the 
 functionality for something locally.
 Cheers,
 Peter
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206131920.g5DJK4V67244>