On Tue, Apr 2, 2024 at 5:00 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > On Tue, Apr 02, 2024 at 12:57:28PM -0700, Linus Torvalds wrote: > > > 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? > > Several things here: > > 1) location of that hook is wrong. It's really "how do we catch > file creation that does not come through open() - yes, you can use > mknod(2) for that". It should've been after the call of vfs_create(), > not the entire switch. LSM folks have a disturbing fondness of inserting > hooks in various places, but IMO this one has no business being where > they'd placed it. I know it's everyone's favorite hobby to bash the LSM and LSM devs, but it's important to note that we don't add hooks without working with the associated subsystem devs to get approval. In the cases where we don't get an explicit ACK, there is an on-list approval, or several ignored on-list attempts over weeks/months/years. We want to be good neighbors. Roberto's original patch which converted from the IMA/EVM hook to the LSM hook was ACK'd by the VFS folks. Regardless, Roberto if it isn't obvious by now, just move the hook back to where it was prior to v6.9-rc1. -- paul-moore.com