Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jul 2019 08:19:33 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349880 - head/sys/compat/linux
Message-ID:  <201907100819.x6A8JXHe020462@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tijl
Date: Wed Jul 10 08:19:33 2019
New Revision: 349880
URL: https://svnweb.freebsd.org/changeset/base/349880

Log:
  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
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D20864

Modified:
  head/sys/compat/linux/linux_mmap.c
  head/sys/compat/linux/linux_mmap.h

Modified: head/sys/compat/linux/linux_mmap.c
==============================================================================
--- head/sys/compat/linux/linux_mmap.c	Wed Jul 10 08:08:14 2019	(r349879)
+++ head/sys/compat/linux/linux_mmap.c	Wed Jul 10 08:19:33 2019	(r349880)
@@ -228,6 +228,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: head/sys/compat/linux/linux_mmap.h
==============================================================================
--- head/sys/compat/linux/linux_mmap.h	Wed Jul 10 08:08:14 2019	(r349879)
+++ head/sys/compat/linux/linux_mmap.h	Wed Jul 10 08:19:33 2019	(r349880)
@@ -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);



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