All of lore.kernel.org
 help / color / mirror / Atom feed
From: Seth Forshee <sforshee@kernel.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-security-module@vger.kernel.org,
	syzbot <syzbot+541e21dcc32c4046cba9@syzkaller.appspotmail.com>,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH (urgent)] vfs: fix uninitialized uid/gid in chown_common()
Date: Mon, 19 Sep 2022 19:25:39 -0500	[thread overview]
Message-ID: <YykIg4PRC3XZoJ9A@do-x1extreme> (raw)
In-Reply-To: <20220919234102.GA21118@mail.hallyn.com>

On Mon, Sep 19, 2022 at 06:41:02PM -0500, Serge E. Hallyn wrote:
> On Mon, Sep 19, 2022 at 05:14:14PM +0200, Christian Brauner wrote:
> > On Mon, Sep 19, 2022 at 05:12:25PM +0200, Christian Brauner wrote:
> > > On Mon, Sep 19, 2022 at 08:05:12PM +0900, Tetsuo Handa wrote:
> > > > syzbot is reporting uninit-value in tomoyo_path_chown() [1], for
> > > > chown_common() is by error passing uninitialized newattrs.ia_vfsuid to
> > > > security_path_chown() via from_vfsuid() when user == -1 is passed.
> > > > We must initialize newattrs.ia_vfs{u,g}id fields in order to make
> > > > from_vfs{u,g}id() work.
> > > > 
> > > > Link: https://syzkaller.appspot.com/bug?extid=541e21dcc32c4046cba9 [1]
> > > > Reported-by: syzbot <syzbot+541e21dcc32c4046cba9@syzkaller.appspotmail.com>
> > > > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > > > ---
> > > 
> > > Odd that we didn't get any of the reports. Thanks for relying this.
> > > I'll massage this a tiny bit, apply and will test with syzbot.
> > 
> > Fyi, Seth.
> 
> Because the modules are ignoring ia_valid & ATTR_XID?

security_path_chown() takes ids as arguments, not struct iattr.

  int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)

The ones being passed are now taken from iattr and thus potentially not
initialized. Even if we change it to only call security_path_chown()
when one of ATTR_{U,G}ID is set the other might not be set, so
initializing iattr.ia_vfs{u,g}id makes sense to me and should match the
old behavior of passing invalid ids in this situation.

What I don't understand is why security_path_chown() is even necessary
when we also have security_inode_setattr(), which also gets called
during chown and gets the full iattr struct. Maybe there's a good
reason, but at first glance it seems like it could do any checks that
security_path_chown() is doing.

Seth

  reply	other threads:[~2022-09-20  0:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19  8:10 [syzbot] KMSAN: uninit-value in tomoyo_path_chown syzbot
2022-09-19 11:05 ` [PATCH (urgent)] vfs: fix uninitialized uid/gid in chown_common() Tetsuo Handa
2022-09-19 15:12   ` Christian Brauner
2022-09-19 15:14     ` Christian Brauner
2022-09-19 23:41       ` Serge E. Hallyn
2022-09-20  0:25         ` Seth Forshee [this message]
2022-09-20  0:29           ` Seth Forshee
2022-09-20  0:45             ` Tetsuo Handa

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=YykIg4PRC3XZoJ9A@do-x1extreme \
    --to=sforshee@kernel.org \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=serge@hallyn.com \
    --cc=syzbot+541e21dcc32c4046cba9@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.