[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjjx3oZ55Uyaw9N_kboHdiScLkXAu05CmPF_p_UhQ-tbw@mail.gmail.com>
Date: Tue, 2 Apr 2024 12:57:28 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Roberto Sassu <roberto.sassu@...weicloud.com>
Cc: linux-integrity@...r.kernel.org, linux-security-module@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org, Roberto Sassu <roberto.sassu@...wei.com>
Subject: Re: [GIT PULL] security changes for v6.9-rc3
On Tue, 2 Apr 2024 at 12:39, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
> {
> - if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> + struct inode *inode = d_backing_inode(dentry);
> + if (unlikely(!inode || IS_PRIVATE(inode)))
> return;
> call_void_hook(path_post_mknod, idmap, dentry);
Hmm. We do have other hooks that get called for this case.
For fsnotify_create() we actually have a comment about this:
* fsnotify_create - 'name' was linked in
*
* Caller must make sure that dentry->d_name is stable.
* Note: some filesystems (e.g. kernfs) leave @dentry negative and instantiate
* ->d_inode later
and audit_inode_child() ends up having a
if (inode)
handle_one(inode);
in it.
So in other cases we do handle the NULL, but it does seem like the
other cases actually do validaly want to deal with this (ie the
fsnotify case will say "the directory that mknod was done in was
changed" even if it doesn't know what the change is.
But for the security case, it really doesn't seem to make much sense
to check a mknod() that you don't know the result of.
I do wonder if that "!inode" test might also be more specific with
"d_unhashed(dentry)". But that would only make sense if we moved this
test from security_path_post_mknod() into the caller itself, ie we
could possibly do something like this instead (or in addition to):
- if (error)
- goto out2;
- security_path_post_mknod(idmap, dentry);
+ if (!error && !d_unhashed(dentry))
+ security_path_post_mknod(idmap, dentry);
which might also be sensible.
Al? Anybody?
Linus
Powered by blists - more mailing lists