From: Jann Horn <jann@thejh.net>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "security@kernel.org" <security@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Paul Moore <paul@paul-moore.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Eric Paris <eparis@parisplace.org>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
Nick Kralevich <nnk@google.com>,
Janis Danisevskis <jdanis@google.com>,
LSM List <linux-security-module@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory
Date: Thu, 3 Nov 2016 03:25:40 +0100 [thread overview]
Message-ID: <20161103022540.GI8196@pc.thejh.net> (raw)
In-Reply-To: <20160928233256.GB2040@pc.thejh.net>
[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]
On Thu, Sep 29, 2016 at 01:32:56AM +0200, Jann Horn wrote:
> On Wed, Sep 28, 2016 at 04:22:53PM -0700, Andy Lutomirski wrote:
> > On Wed, Sep 28, 2016 at 3:54 PM, Jann Horn <jann@thejh.net> wrote:
> > > -struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
> > > +struct mm_struct *proc_mem_open(struct inode *inode,
> > > + const struct cred **object_cred,
> > > + unsigned int mode)
> > > {
> >
> > Why are you passing object_cred all over the place like this? You
> > have an inode, and an inode implies a task.
>
> But the task's mm and objective credentials can change, and only mm_access()
> holds the cred_guard_mutex during the mm lookup. Although, if the objective
> credentials change because of a setuid execution, being able to poke in the
> old mm would be pretty harmless...
Actually, no. If you can poke in the pre-execve memory, but are checked
against the (possibly more permissive) objective creds of the post-execve
process, you can affect another process that shares the pre-execve memory
(the case where task B, which calls execve(), was clone()d from task A
with CLONE_VM). So I'm keeping this code the way I wrote it.
> > For that matter, would it possibly make sense to use MEMCG's mm->owner
> > and get rid of object_cred entirely?
>
> I guess it might.
Actually, I'd prefer not to do that - I think it would be unnecessarily
unintuitive to check against the objective creds of task A when accessing
task B if task B was clone()d from A with clone(CLONE_VM).
> > I can see this causing issues in
> > strange threading cases, e.g. accessing your own /proc/$$/mem vs
> > another thread in your process's.
>
> Can you elaborate on that?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-11-03 2:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 22:54 [PATCH v2 0/3] fix SELinux W^X bypass via ptrace Jann Horn
2016-09-28 22:54 ` [PATCH v2 1/3] fs/exec: don't force writing memory access Jann Horn
2016-09-29 16:09 ` Oleg Nesterov
2016-09-28 22:54 ` [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Jann Horn
2016-09-28 23:22 ` Andy Lutomirski
2016-09-28 23:32 ` Jann Horn
2016-09-28 23:44 ` Jann Horn
2016-11-03 2:25 ` Jann Horn [this message]
2016-09-29 6:25 ` Ingo Molnar
2016-09-28 22:54 ` [PATCH v2 3/3] selinux: require EXECMEM for forced ptrace poke Jann Horn
2016-09-29 6:19 ` Ingo Molnar
2016-09-29 16:38 ` 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=20161103022540.GI8196@pc.thejh.net \
--to=jann@thejh.net \
--cc=eparis@parisplace.org \
--cc=james.l.morris@oracle.com \
--cc=jdanis@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=nnk@google.com \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=security@kernel.org \
--cc=serge@hallyn.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox