Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Aug 2012 12:11:49 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239250 - head/sys/vm
Message-ID:  <201208141211.q7ECBnYL093026@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Aug 14 12:11:48 2012
New Revision: 239250
URL: http://svn.freebsd.org/changeset/base/239250

Log:
  For old mmap syscall, when executing on amd64 or ia64, enforce the
  PROT_EXEC if prot is non-zero, process is 32bit and
  kern.elf32.i386_read_exec syscal is enabled. This workaround is needed
  for old i386 a.out binaries, where dynamic linker did not specified
  PROT_EXEC for mapping of the text.
  
  The kern.elf32.i386_read_exec MIB name looks weird for a.out binaries,
  but I reused the existing knob which already has the needed semantic.
  
  MFC after:	1 week

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Tue Aug 14 12:09:36 2012	(r239249)
+++ head/sys/vm/vm_mmap.c	Tue Aug 14 12:11:48 2012	(r239250)
@@ -453,6 +453,13 @@ ommap(td, uap)
 	nargs.addr = uap->addr;
 	nargs.len = uap->len;
 	nargs.prot = cvtbsdprot[uap->prot & 0x7];
+#ifdef COMPAT_FREEBSD32
+#if defined(__amd64__) || defined(__ia64__)
+	if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32) &&
+	    nargs.prot != 0)
+		nargs.prot |= PROT_EXEC;
+#endif
+#endif
 	nargs.flags = 0;
 	if (uap->flags & OMAP_ANON)
 		nargs.flags |= MAP_ANON;



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