Re: [patch] remove MNT_NOEXEC check for PROT_EXEC mmaps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Arjan van de Ven wrote:
/ wants to be able to mark more partitions as noexec,/
.... and then execute from them!
that's what is bothering me most about all of this.
Do you mean "execute with ld.so", or "execute with PROT_EXEC mmap"?
I think for ld.so problem to cease existing, it is enought to do
simply "chmod 'go-x' ld.so". For this to work I tried opening the
loader with fsuid=0, like in the attached hack. Chmodding ld.so
also prevents the one from executing the binaries for which he have
no execute permission, which is what an mmap hack doesn't solve.

"execute with PROT_EXEC mmap" argument simply doesn't hold -
MAP_PRIVATE|MAP_ANONYMOUS with read() will always work, as well
as the mprotect it seems.

--- binfmt_elf.c.old	2006-08-20 15:49:55.000000000 +0400
+++ binfmt_elf.c	2006-09-30 13:01:27.000000000 +0400
@@ -623,6 +623,7 @@
 
 	for (i = 0; i < loc->elf_ex.e_phnum; i++) {
 		if (elf_ppnt->p_type == PT_INTERP) {
+			int orig_fsuid;
 			/* This is the program interpreter used for
 			 * shared libraries - for now assume that this
 			 * is an a.out format binary
@@ -680,7 +681,10 @@
 			 */
 			SET_PERSONALITY(loc->elf_ex, ibcs2_interpreter);
 
+			orig_fsuid = current->fsuid;
+			current->fsuid = 0;
 			interpreter = open_exec(elf_interpreter);
+			current->fsuid = orig_fsuid;
 			retval = PTR_ERR(interpreter);
 			if (IS_ERR(interpreter))
 				goto out_free_interp;

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux