Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1514253 > unrolled thread

Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory

Started byJann Horn <jann@thejh.net>
First post2016-11-03 03:30 +0100
Last post2016-11-03 03:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-11-03 03:30 +0100

#1514253 — Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory

FromJann Horn <jann@thejh.net>
Date2016-11-03 03:30 +0100
SubjectRe: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory
Message-ID<szfWV-68P-15@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

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?

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web