Linux-Security-Module Archive on lore.kernel.org
 help / color / Atom feed
From: Alexey Gladkov <gladkov.alexey@gmail.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	syzbot <syzbot+c1af344512918c61362c@syzkaller.appspotmail.com>,
	jmorris@namei.org, linux-kernel@vger.kernel.org,
	linux-next@vger.kernel.org,
	linux-security-module@vger.kernel.org, serge@hallyn.com,
	sfr@canb.auug.org.au, syzkaller-bugs@googlegroups.com,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: linux-next boot error: general protection fault in tomoyo_get_local_path
Date: Fri, 15 May 2020 21:25:59 +0200
Message-ID: <20200515192559.e5ofmmzxdviierkb@comp-core-i7-2640m-0182e6> (raw)
In-Reply-To: <87lfltcbc4.fsf@x220.int.ebiederm.org>

On Fri, May 15, 2020 at 01:16:59PM -0500, Eric W. Biederman wrote:
> Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> writes:
> 
> > This is
> >
> >         if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') {
> >                 char *ep;
> >                 const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10);
> >                 struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry)); // <= here
> >
> >                 if (*ep == '/' && pid && pid ==
> >                     task_tgid_nr_ns(current, proc_pidns)) {
> >
> > which was added by commit c59f415a7cb6e1e1 ("Use proc_pid_ns() to get pid_namespace from the proc superblock").
> >
> > @@ -161,9 +162,10 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
> >         if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') {
> >                 char *ep;
> >                 const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10);
> > +               struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry));
> >
> >                 if (*ep == '/' && pid && pid ==
> > -                   task_tgid_nr_ns(current, sb->s_fs_info)) {
> > +                   task_tgid_nr_ns(current, proc_pidns)) {
> >                         pos = ep - 5;
> >                         if (pos < buffer)
> >                                 goto out;
> >
> > Alexey and Eric, any clue?
> 
> Looking at the stack backtrace this is happening as part of creating a
> file or a device node.  The dentry that is passed in most likely
> comes from d_alloc_parallel.  So we have d_inode == NULL.
> 
> I want to suggest doing the very simple fix:
> 
> -	if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') {
> +	if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/' && denty->d_inode) {
> 
> But I don't know if there are any other security hooks early in lookup,
> that could be called for an already existing dentry.
> 
> So it looks like we need a version proc_pid_ns that works for a dentry,
> or a superblock.
> 
> Alex do you think you can code up an patch against my proc-next branch
> to fix this?

Sure.

-- 
Rgrds, legion


  reply index

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 14:46 syzbot
2020-05-15 15:18 ` Tetsuo Handa
2020-05-15 15:36   ` Tetsuo Handa
2020-05-15 20:13     ` Al Viro
2020-05-15 20:36       ` Eric W. Biederman
2020-05-15 20:56       ` Al Viro
2020-05-15 18:16   ` Eric W. Biederman
2020-05-15 19:25     ` Alexey Gladkov [this message]
2020-05-17 17:11     ` [PATCH] proc: proc_pid_ns takes super_block as an argument Alexey Gladkov
2020-05-18 11:17     ` [PATCH v2] " Alexey Gladkov
2020-05-18 12:08       ` Eric W. Biederman
2020-05-18 12:56         ` Alexey Gladkov
2020-05-18 12:57           ` Eric W. Biederman
2020-05-18 15:08     ` [PATCH v3] " Alexey Gladkov
2020-05-18 15:36       ` Tetsuo Handa
2020-05-18 18:07     ` [PATCH v4] " Alexey Gladkov

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=20200515192559.e5ofmmzxdviierkb@comp-core-i7-2640m-0182e6 \
    --to=gladkov.alexey@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=jmorris@namei.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=serge@hallyn.com \
    --cc=sfr@canb.auug.org.au \
    --cc=syzbot+c1af344512918c61362c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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

Linux-Security-Module Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-security-module/0 linux-security-module/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-security-module linux-security-module/ https://lore.kernel.org/linux-security-module \
		linux-security-module@vger.kernel.org
	public-inbox-index linux-security-module

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-security-module


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git