linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>, Andrew Morton <akpm00@gmail.com>,
	linux-kernel@vger.kernel.org, containers@lists.osdl.org,
	linux-fsdevel@vger.kernel.org,
	Kirill Shutemov <kirill@shutemov.name>,
	Pavel Emelyanov <xemul@parallels.com>,
	James Bottomley <jbottomley@parallels.com>,
	Nathan Lynch <ntl@pobox.com>, Zan Lynx <zlynx@acm.org>,
	Daniel Lezcano <dlezcano@fr.ibm.com>, Tejun Heo <tj@kernel.org>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch 2/2] fs, proc: Introduce the /proc/<pid>/map_files/ directory v12
Date: Wed, 14 Sep 2011 20:07:25 +0400	[thread overview]
Message-ID: <20110914160724.GA10612@albatros> (raw)
In-Reply-To: <20110914160018.GW25367@sun>

On Wed, Sep 14, 2011 at 20:00 +0400, Cyrill Gorcunov wrote:
> On Wed, Sep 14, 2011 at 06:48:41PM +0400, Vasiliy Kulikov wrote:
> ...
> > 
> > Actually now I see the difference between having something mapped and
> > having an _fd_ of this something.
> > 
> > Relevant code:
> > 
> > +static struct dentry *
> > +proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
> > +              struct task_struct *task, const void *ptr)
> > +{
> > ...
> > +   inode->i_mode = S_IFLNK;
> > +
> > +   if (file->f_mode & FMODE_READ)
> > +       inode->i_mode |= S_IRUSR | S_IXUSR;
> > +   if (file->f_mode & FMODE_WRITE)
> > +       inode->i_mode |= S_IWUSR | S_IXUSR;
> > 
> > 
> > If you have a write mmap area, but no fd, you may not trunc a file; with
> > map_files/ you may get an fd and ftrunc it.
> > 
> 
> This stands for anonymous memory, and if you have enough rights to
> access the task this ftruncate is the last problem (since having ptrace
> access to the task I _aready_ can trash various stuff inside, i dont need
> even bother to look into map_files/ or whatever). So I don't see how
> ftruncate migh harm you here?

No, I mean something else.  Assume you have a task, which does the
steps:

1) opens some sensitive file as root.  This file is e.g. 0700.

2) mmaps the file via opened fd, either RO or RW.

3) closes fd.

4) drops root.

Now it has a mapping of a privileged file, but cannot get fd of it
anyhow.  With map_files/ he may open his own /proc/$$/map_files/, pass
ptrace() check, and get fd of the privileged file.  He cannot explicitly
open it as it is 0700, but he may open it via map_files/ and get RO/RW
fd.

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

  reply	other threads:[~2011-09-14 16:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 21:13 [patch 0/2] symlinks for mapped files in proc Cyrill Gorcunov
2011-09-13 21:14 ` [patch 1/2] fs, proc: Make proc_get_link to use dentry instead of inode Cyrill Gorcunov
2011-09-14  1:37   ` Kirill A. Shutemov
2011-09-13 21:14 ` [patch 2/2] fs, proc: Introduce the /proc/<pid>/map_files/ directory v12 Cyrill Gorcunov
     [not found]   ` <20110914023428.GA4034@shutemov.name>
2011-09-14  5:54     ` Cyrill Gorcunov
2011-09-14  6:52   ` Andrew Morton
2011-09-14 10:56     ` Cyrill Gorcunov
2011-09-14 11:14       ` Pavel Machek
2011-09-14 11:39         ` Cyrill Gorcunov
2011-09-14 13:44           ` Cyrill Gorcunov
2011-09-14 14:48             ` Vasiliy Kulikov
2011-09-14 14:57               ` Vasiliy Kulikov
2011-09-14 16:00               ` Cyrill Gorcunov
2011-09-14 16:07                 ` Vasiliy Kulikov [this message]
2011-09-14 16:13                   ` Pavel Emelyanov
2011-09-14 16:21                     ` Vasiliy Kulikov
2011-09-15  9:14                   ` Cyrill Gorcunov
2011-09-15  9:27                     ` Vasiliy Kulikov
2011-09-15 10:29                       ` Cyrill Gorcunov
2011-09-15 10:56                         ` Vasiliy Kulikov
2011-09-15 11:00                           ` Cyrill Gorcunov
2011-09-15 20:19                           ` Cyrill Gorcunov
2011-09-16 17:56                             ` Vasiliy Kulikov
2011-09-16 18:07                               ` Cyrill Gorcunov
2011-09-16 18:11                                 ` Vasiliy Kulikov
2011-09-16 18:26                                   ` Cyrill Gorcunov
2011-09-16 18:31                                     ` Kirill A. Shutemov
2011-09-16 18:40                                       ` Cyrill Gorcunov

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=20110914160724.GA10612@albatros \
    --to=segoon@openwall.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm00@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.osdl.org \
    --cc=dlezcano@fr.ibm.com \
    --cc=gorcunov@gmail.com \
    --cc=jbottomley@parallels.com \
    --cc=kirill@shutemov.name \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntl@pobox.com \
    --cc=pavel@ucw.cz \
    --cc=tj@kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=xemul@parallels.com \
    --cc=zlynx@acm.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).