svn commit: r350279 - stable/11/sys/compat/linux

Tijl Coosemans tijl at FreeBSD.org
Wed Jul 24 12:48:52 UTC 2019


Author: tijl
Date: Wed Jul 24 12:48:51 2019
New Revision: 350279
URL: https://svnweb.freebsd.org/changeset/base/350279

Log:
  MFC r349880:
  
  Let linuxulator mprotect mask unsupported bits before calling kern_mprotect.
  
  After r349240 kern_mprotect returns EINVAL for unsupported bits in the prot
  argument.  Linux rtld uses PROT_GROWSDOWN and PROT_GROWS_UP when marking the
  stack executable.  Mask these bits like kern_mprotect used to do.  For other
  unsupported bits EINVAL is returned like Linux does.
  
  Reviewed by:    trasz, brooks

Modified:
  stable/11/sys/compat/linux/linux_mmap.c
  stable/11/sys/compat/linux/linux_mmap.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linux/linux_mmap.c
==============================================================================
--- stable/11/sys/compat/linux/linux_mmap.c	Wed Jul 24 12:46:55 2019	(r350278)
+++ stable/11/sys/compat/linux/linux_mmap.c	Wed Jul 24 12:48:51 2019	(r350279)
@@ -229,6 +229,11 @@ int
 linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot)
 {
 
+	/* XXX Ignore PROT_GROWSDOWN and PROT_GROWSUP for now. */
+	prot &= ~(LINUX_PROT_GROWSDOWN | LINUX_PROT_GROWSUP);
+	if ((prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0)
+		return (EINVAL);
+
 #if defined(__amd64__)
 	linux_fixup_prot(td, &prot);
 #endif

Modified: stable/11/sys/compat/linux/linux_mmap.h
==============================================================================
--- stable/11/sys/compat/linux/linux_mmap.h	Wed Jul 24 12:46:55 2019	(r350278)
+++ stable/11/sys/compat/linux/linux_mmap.h	Wed Jul 24 12:48:51 2019	(r350279)
@@ -41,6 +41,8 @@
 #define	LINUX_MAP_ANON		0x0020
 #define	LINUX_MAP_GROWSDOWN	0x0100
 
+#define	LINUX_PROT_GROWSDOWN	0x01000000
+#define	LINUX_PROT_GROWSUP	0x02000000
 
 int linux_mmap_common(struct thread *, uintptr_t, size_t, int, int,
 			int, off_t);


More information about the svn-src-stable-11 mailing list