Linux-Security-Module Archive on lore.kernel.org
 help / color / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>,
	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 13:16:59 -0500
Message-ID: <87lfltcbc4.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <c3461e26-1407-2262-c709-dac0df3da2d0@i-love.sakura.ne.jp> (Tetsuo Handa's message of "Sat, 16 May 2020 00:18:00 +0900")

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?

Eric

  parent 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 [this message]
2020-05-15 19:25     ` Alexey Gladkov
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=87lfltcbc4.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=gladkov.alexey@gmail.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