mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hector Marco-Gisbert <hecmargi@upv.es>
To: linux-kernel@vger.kernel.org
Cc: James Morris <james.l.morris@oracle.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	kees Cook <keescook@chromium.org>, Ismael Ripoll <iripoll@upv.es>,
	Hector Marco-Gisbert <hecmargi@upv.es>
Subject: [PATCH] Honor mmap_min_addr with the actual minimum
Date: Wed,  6 Apr 2016 21:07:28 +0200	[thread overview]
Message-ID: <1459969648-4386-1-git-send-email-hecmargi@upv.es> (raw)

The minimum address that a process is allowed to mmap when LSM is
enabled is 0x10000 (65536). This value is tunable and exported via
/proc/sys/vm/mmap_min_addr but it is not honored with the actual
minimum value.

It can be easily checked in a system typing:

$ cat /proc/sys/vm/mmap_min_addr
4096    # <= Incorrect, it should be 65536

$ echo 1024 > /proc/sys/vm/mmap_min_addr
$ cat /proc/sys/vm/mmap_min_addr
1024    # <= Incorrect, it should be 65536

After applying the patch:

$ cat /proc/sys/vm/mmap_min_addr
65536    # <= It is correct

$ echo 1024 > /proc/sys/vm/mmap_min_addr
$ cat /proc/sys/vm/mmap_min_addr
65536    # <= It is correct



Signed-off-by: Hector Marco-Gisbert <hecmargi@upv.es>
Acked-by: Ismael Ripoll Ripoll <iripoll@upv.es>
---
 security/min_addr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/security/min_addr.c b/security/min_addr.c
index f728728..96d1811 100644
--- a/security/min_addr.c
+++ b/security/min_addr.c
@@ -15,10 +15,12 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
 static void update_mmap_min_addr(void)
 {
 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
-	if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
+	if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR) {
 		mmap_min_addr = dac_mmap_min_addr;
-	else
+	} else {
 		mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
+		dac_mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
+	}
 #else
 	mmap_min_addr = dac_mmap_min_addr;
 #endif
-- 
1.9.1

             reply	other threads:[~2016-04-06 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-06 19:07 Hector Marco-Gisbert [this message]
2016-04-06 22:40 ` Kees Cook
2016-04-19 18:55   ` Hector Marco-Gisbert
2016-04-20 22:12     ` Kees Cook
2016-05-11 12:54       ` Hector Marco-Gisbert
2016-05-11 13:50         ` Eric Paris
2016-05-12 17:56           ` Hector Marco-Gisbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459969648-4386-1-git-send-email-hecmargi@upv.es \
    --to=hecmargi@upv.es \
    --cc=iripoll@upv.es \
    --cc=james.l.morris@oracle.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®