From: Eric Paris <eparis@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: jmorris@namei.org, sds@tycho.nsa.gov, selinux@tycho.nsa.gov,
alan@redhat.com, chrisw@redhat.com, hpa@zytor.com,
akpm@linux-foundation.org
Subject: [PATCH 1/3] mmap: protect from stack expantion into low vm addresses
Date: Fri, 16 Nov 2007 15:54:39 -0500 [thread overview]
Message-ID: <1195246479.2924.86.camel@localhost.localdomain> (raw)
When adding the new security hooks into mmap to enhance protection
against NULL pointers in the kernel I overlooked that a user may be able
to expand the stack all the way down to low addresses. This flaw was
pointed out by a PaX/grsecurity developer and this patch should provide
protection against this missed code path.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
** Be very careful applying/rediffing this patch. Standard 3 lines of
context from git diff will misapply the first hunk to expand_upwards
instead of properly in expand_downwards. This patch was generated using
-U 4 to make sure it applies in the correct place. **
mm/mmap.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- kernel-1/mm/mmap.c
+++ kernel-2/mm/mmap.c
@@ -1614,17 +1614,21 @@ static inline int expand_downwards(struc
* so that the anon_vma locking is not a noop.
*/
if (unlikely(anon_vma_prepare(vma)))
return -ENOMEM;
+
+ address &= PAGE_MASK;
+ error = security_file_mmap(0, 0, 0, 0, address, 1);
+ if (error)
+ return error;
+
anon_vma_lock(vma);
/*
* vma->vm_start/vm_end cannot change under us because the caller
* is required to hold the mmap_sem in read mode. We need the
* anon_vma lock to serialize against concurrent expand_stacks.
*/
- address &= PAGE_MASK;
- error = 0;
/* Somebody else might have raced and expanded it already */
if (address < vma->vm_start) {
unsigned long size, grow;
next reply other threads:[~2007-11-16 20:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 20:54 Eric Paris [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-11-26 23:47 [PATCH 1/3] mmap: protect from stack expantion into low vm addresses Eric Paris
2007-11-27 1:04 ` James Morris
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=1195246479.2924.86.camel@localhost.localdomain \
--to=eparis@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alan@redhat.com \
--cc=chrisw@redhat.com \
--cc=hpa@zytor.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/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