[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200515192559.e5ofmmzxdviierkb@comp-core-i7-2640m-0182e6>
Date: Fri, 15 May 2020 21:25:59 +0200
From: Alexey Gladkov <gladkov.alexey@...il.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
syzbot <syzbot+c1af344512918c61362c@...kaller.appspotmail.com>,
jmorris@...ei.org, linux-kernel@...r.kernel.org,
linux-next@...r.kernel.org, linux-security-module@...r.kernel.org,
serge@...lyn.com, sfr@...b.auug.org.au,
syzkaller-bugs@...glegroups.com,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: linux-next boot error: general protection fault in
tomoyo_get_local_path
On Fri, May 15, 2020 at 01:16:59PM -0500, Eric W. Biederman wrote:
> Tetsuo Handa <penguin-kernel@...ove.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
Powered by blists - more mailing lists