From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: elf_set_personality()
Date: Mon, 27 Feb 2012 17:16:34 +0000 [thread overview]
Message-ID: <20120227171634.GC2440@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAG6tG3zwfhZXw5M_kk4ry4H6NhTuKyenP-6UUm+XwyxbBbcG9g@mail.gmail.com>
On Mon, Feb 27, 2012 at 12:09:00PM -0500, Robert Love wrote:
> On Mon, Feb 27, 2012 at 11:41 AM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > It seems that vanilla mmap() of a file does not deny a mapping containing
> > PROT_EXEC of a file with read-write-noexec permissions - it permits it,
> > but it does fail mapping a file PROT_WRITE which wasn't opened for write.
> >
> > Moreover, it's not actually possible to prevent execution of code if
> > you have read permission - if you can read a mapping, you can copy it
> > into an executable mapping and then execute copied code.
> >
> > So, I don't think there's any reason to prevent PROT_EXEC in a hard and
> > fast manner. ?If you don't want to go that far, what about:
> >
> > ? ? ? ?prot_mask = PROT_MASK;
> > ? ? ? ?if (current->personality & READ_IMPLIES_EXEC)
> > ? ? ? ? ? ? ? ?prot_mask &= ~PROT_EXEC;
> > ? ? ? ?if (vma->vm_flags & ~asma->prot_mask & prot_mask) {
> > ? ? ? ? ? ? ? ?ret = -EPERM;
> > ? ? ? ? ? ? ? ?goto out;
> > ? ? ? ?}
> >
> > which would mean !READ_IMPLIES_EXEC threads would get the full permission
> > checking, but a READ_IMPLIES_EXEC thread would still be able to attach
> > to a r/w only shared mapping.
>
> ashmem should behave however vanilla mmap behaves.
Well, it's fairly clear that it doesn't, because it has more stringent
permission checks than vanilla mmap.
> There is no reason to be different and I'd prefer to consolidate or at
> least copy the code.
>
> It is unfortunate that each implementer of fops->mmap needs to
> manually handle the READ_IMPLIES_EXEC case.
That would mean ignoring PROT_EXEC entirely.
next prev parent reply other threads:[~2012-02-27 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-27 12:36 elf_set_personality() Peter De Schrijver
2012-02-27 13:04 ` elf_set_personality() Russell King - ARM Linux
2012-02-27 15:03 ` elf_set_personality() Peter De Schrijver
2012-02-27 15:20 ` elf_set_personality() Robert Love
2012-02-27 16:41 ` elf_set_personality() Russell King - ARM Linux
2012-02-27 17:09 ` elf_set_personality() Robert Love
2012-02-27 17:16 ` Russell King - ARM Linux [this message]
2012-02-27 17:18 ` elf_set_personality() Robert Love
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=20120227171634.GC2440@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).