ns_mkdir_op() drops inode_lock for simple_pin_fs() and re-acquires it
before instantiating the dentry. A concurrent mkdir() of the same name
can pass the VFS negative-dentry checks in that window and also reach
d_instantiate(), tripping BUG_ON(!hlist_unhashed(&d_alias)).
Re-check that the dentry is still negative after re-acquiring inode_lock
and return -EEXIST if a concurrent mkdir() won the race.
Fixes: 4ae47f33354a ("apparmor: add mkdir/rmdir interface to manage policy namespaces")
Signed-off-by: Ran Hongyun <redacted>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109025600.2031008-1-ranhongyun1@huawei.com?part=1