From: Chris Wright <chrisw@sous-sol.org>
To: Eric Paris <eparis@redhat.com>
Cc: linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov,
Alan Cox <alan@redhat.com>,
drepper@redhat.com, roland@redhat.com, arjan@infradead.org,
mingo@elte.hu, viro@zeniv.linux.org.uk, jmorris@namei.org,
chrisw@redhat.com, sds@tycho.nsa.gov, sgrubb@redhat.com
Subject: Re: [PATCH] Protection for exploiting null dereference using mmap
Date: Tue, 5 Jun 2007 15:49:41 -0700 [thread overview]
Message-ID: <20070605224941.GD3723@sequoia.sous-sol.org> (raw)
In-Reply-To: <1181075666.3978.31.camel@localhost.localdomain>
* Eric Paris (eparis@redhat.com) wrote:
> +mmap_protect_memory
I'm terrible at names, but something like mmap_minimum_addr would be a
little clearer at describing that it's a lower bound on mapping memory.
BTW, this is also an arch specific issue, those with disjoint kernel
and user memory space don't suffer (yet another reason to default to 0).
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -615,6 +615,15 @@ static ctl_table kern_table[] = {
> .proc_handler = &proc_dointvec,
> },
> #endif
> + {
> + .ctl_name = CTL_UNNUMBERED,
> + .procname = "mmap_protect_memory",
> + .data = &mmap_protect_memory,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = &proc_dointvec,
> + .strategy = &sysctl_intvec,
I don't think this strategy does anything without some boundary values.
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -291,6 +291,10 @@ unsigned long do_mremap(unsigned long addr,
> if ((addr <= new_addr) && (addr+old_len) > new_addr)
> goto out;
>
> + ret = security_file_mmap(0, 0, 0, 0, new_addr, 1);
> + if (ret)
> + goto out;
> +
> ret = do_munmap(mm, new_addr, new_len);
> if (ret)
> goto out;
> @@ -390,9 +394,16 @@ unsigned long do_mremap(unsigned long addr,
>
> new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
> vma->vm_pgoff, map_flags);
> - ret = new_addr;
> - if (new_addr & ~PAGE_MASK)
> + if (new_addr & ~PAGE_MASK) {
> + ret = new_addr;
> goto out;
> + }
> +
> + ret = security_file_mmap(0, 0, 0, 0, new_addr, 1);
> + if (ret)
> + goto out;
> +
> + ret = new_addr;
Nit: unnecessary assignment...
> }
> ret = move_vma(vma, addr, old_len, new_len, new_addr);
^^^
...as it's overwritten immediately after.
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
WARNING: multiple messages have this Message-ID (diff)
From: Chris Wright <chrisw@sous-sol.org>
To: Eric Paris <eparis@redhat.com>
Cc: linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov,
Alan Cox <alan@redhat.com>,
drepper@redhat.com, roland@redhat.com, arjan@infradead.org,
mingo@elte.hu, viro@zeniv.linux.org.uk, jmorris@namei.org,
chrisw@redhat.com, sds@tycho.nsa.gov, sgrubb@redhat.com
Subject: Re: [PATCH] Protection for exploiting null dereference using mmap
Date: Tue, 5 Jun 2007 15:49:41 -0700 [thread overview]
Message-ID: <20070605224941.GD3723@sequoia.sous-sol.org> (raw)
In-Reply-To: <1181075666.3978.31.camel@localhost.localdomain>
* Eric Paris (eparis@redhat.com) wrote:
> +mmap_protect_memory
I'm terrible at names, but something like mmap_minimum_addr would be a
little clearer at describing that it's a lower bound on mapping memory.
BTW, this is also an arch specific issue, those with disjoint kernel
and user memory space don't suffer (yet another reason to default to 0).
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -615,6 +615,15 @@ static ctl_table kern_table[] = {
> .proc_handler = &proc_dointvec,
> },
> #endif
> + {
> + .ctl_name = CTL_UNNUMBERED,
> + .procname = "mmap_protect_memory",
> + .data = &mmap_protect_memory,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = &proc_dointvec,
> + .strategy = &sysctl_intvec,
I don't think this strategy does anything without some boundary values.
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -291,6 +291,10 @@ unsigned long do_mremap(unsigned long addr,
> if ((addr <= new_addr) && (addr+old_len) > new_addr)
> goto out;
>
> + ret = security_file_mmap(0, 0, 0, 0, new_addr, 1);
> + if (ret)
> + goto out;
> +
> ret = do_munmap(mm, new_addr, new_len);
> if (ret)
> goto out;
> @@ -390,9 +394,16 @@ unsigned long do_mremap(unsigned long addr,
>
> new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
> vma->vm_pgoff, map_flags);
> - ret = new_addr;
> - if (new_addr & ~PAGE_MASK)
> + if (new_addr & ~PAGE_MASK) {
> + ret = new_addr;
> goto out;
> + }
> +
> + ret = security_file_mmap(0, 0, 0, 0, new_addr, 1);
> + if (ret)
> + goto out;
> +
> + ret = new_addr;
Nit: unnecessary assignment...
> }
> ret = move_vma(vma, addr, old_len, new_len, new_addr);
^^^
...as it's overwritten immediately after.
next prev parent reply other threads:[~2007-06-05 22:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 21:48 [PATCH] SELinux protection for exploiting null dereference using mmap Eric Paris
2007-05-31 0:07 ` James Morris
2007-05-31 5:46 ` Eric Paris
2007-05-31 13:45 ` James Morris
2007-05-31 14:45 ` Stephen Smalley
[not found] ` <465EE1C9.3020809@redhat.com>
2007-05-31 15:07 ` Stephen Smalley
2007-05-31 15:19 ` James Morris
2007-05-31 15:31 ` Stephen Smalley
2007-06-02 2:27 ` Chris Wright
2007-05-31 1:40 ` Chris Wright
[not found] ` <20070603205653.GE25869@devserv.devel.redhat.com>
2007-06-04 13:38 ` Stephen Smalley
2007-06-05 20:34 ` [PATCH] Protection " Eric Paris
2007-06-05 20:34 ` Eric Paris
2007-06-05 21:00 ` James Morris
2007-06-05 21:00 ` James Morris
2007-06-05 21:16 ` Alan Cox
2007-06-05 21:28 ` Eric Paris
2007-06-05 21:28 ` Eric Paris
2007-06-05 22:46 ` H. Peter Anvin
2007-06-07 14:28 ` Pavel Machek
2007-06-06 12:47 ` Stephen Smalley
2007-06-06 12:47 ` Stephen Smalley
2007-06-07 16:58 ` Jan Engelhardt
2007-06-06 6:30 ` Eric Paris
2007-06-06 6:30 ` Eric Paris
2007-06-06 13:21 ` James Morris
2007-06-06 13:21 ` James Morris
2007-06-06 17:30 ` Stephen Smalley
2007-06-06 17:30 ` Stephen Smalley
2007-06-06 18:01 ` James Morris
2007-06-06 18:01 ` James Morris
2007-06-06 18:06 ` Chris Wright
2007-06-06 18:06 ` Chris Wright
2007-06-20 19:48 ` Adam Jackson
2007-06-05 22:49 ` Chris Wright [this message]
2007-06-05 22:49 ` Chris Wright
2007-06-05 22:53 ` Chris Wright
2007-06-05 22:53 ` Chris Wright
2007-06-06 12:12 ` Stephen Smalley
2007-06-06 12:12 ` Stephen Smalley
2007-06-06 9:01 ` Russell Coker
2007-06-06 9:01 ` Russell Coker
2007-06-06 12:18 ` Stephen Smalley
2007-06-06 12:18 ` Stephen Smalley
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=20070605224941.GD3723@sequoia.sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=alan@redhat.com \
--cc=arjan@infradead.org \
--cc=chrisw@redhat.com \
--cc=drepper@redhat.com \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=sgrubb@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.