FAILED: patch "[PATCH] ksmbd: pin parent dentries in SMB2 CREATE ACL path" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 0383a66dabd7aa06237b9b24713c03656abeffe4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112518-cranberry-chaperone-0cf3@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0383a66dabd7aa06237b9b24713c03656abeffe4 Mon Sep 17 00:00:00 2001
From: Jiwoo Kim <[email protected]>
Date: Tue, 10 Nov 2026 16:24:05 +0900
Subject: [PATCH] ksmbd: pin parent dentries in SMB2 CREATE ACL path
smb2_open() and smb_inherit_dacl() read a child's d_parent without a dentry reference. A concurrent SMB request can move the child and remove the parent while CREATE uses its inode for permission, status, and ACL inheritance work. A remote SMB race with concurrent opener and mover connections on a writable KSMBD acl_xattr share triggered an 8-byte slab-use-after-free read in get_cached_acl on tmpfs and ext4 KASAN guests. With oops=panic, it also caused an Oops and kernel panic on an ext4 guest.
Take a parent dentry reference around each parent inode or ACL access in these paths and release it when the operation completes. Treat a negative parent dentry as -ENOENT for the affected operation.
On a tmpfs KASAN QEMU guest, two 3,000-round reproducer instances completed without a KASAN report or Oops; SMB remained reachable. On an ext4 non-KASAN QEMU guest with oops=panic, a 2,000-operation no-race control and two 5,000-round reproducer instances completed without an Oops or panic. An SMB health probe still succeeded.
OpenAI Codex assisted with finding the bug, generating the SMB race reproducer, drafting this fix and changelog, and running the tests.
fs/smb/server/smb2pdu.c +30 -7
@@ -4969,16 +4969,32 @@ int smb2_open(struct ksmbd_work *work)if ((daccess &FILE_DELETE_LE ) || (req->CreateOptions &FILE_DELETE_ON_CLOSE_LE )) { - rc =inode_permission (idmap, -d_inode (path.dentry->d_parent), -MAY_EXEC |MAY_WRITE ); +struct dentry *parent =dget_parent (path.dentry); +struct inode *parent_inode =d_inode (parent); + +if (parent_inode) + rc =inode_permission (idmap, parent_inode, +MAY_EXEC |MAY_WRITE ); +else + rc = -ENOENT ; +dput (parent);if (rc) goto err_out; } } } - rc =ksmbd_query_inode_status (path.dentry->d_parent); + { +struct dentry *parent =dget_parent (path.dentry); + +if (!d_inode (parent)) { +dput (parent); + rc = -ENOENT ; + goto err_out; + } + rc =ksmbd_query_inode_status (parent); +dput (parent); + }if (rc ==KSMBD_INODE_STATUS_PENDING_DELETE ) { rc = -EBUSY ; goto err_out;
@@ -5061,10 +5077,17 @@ int smb2_open(struct ksmbd_work *work)if (created) {int posix_acl_rc;struct inode *inode =d_inode (path.dentry); +struct inode *parent_inode; +struct dentry *parent; - posix_acl_rc =ksmbd_vfs_inherit_posix_acl (idmap, - &path, -d_inode (path.dentry->d_parent)); + parent =dget_parent (path.dentry); + parent_inode =d_inode (parent); +if (parent_inode) + posix_acl_rc =ksmbd_vfs_inherit_posix_acl (idmap, &path, + parent_inode); +else + posix_acl_rc = -ENOENT ; +dput (parent);if (posix_acl_rc)ksmbd_debug (SMB ,"inherit posix acl failed : %d\n" , posix_acl_rc);
fs/smb/server/smbacl.c +8 -1
@@ -7,6 +7,7 @@*/ #include <linux/fs.h> +#include <linux/dcache.h> #include <kunit/visibility.h> #include <linux/slab.h> #include <linux/string.h>
@@ -1207,7 +1208,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_acl *parent_pdacl;struct smb_ntsd *parent_pntsd =NULL ;struct smb_sid owner_sid, group_sid; -struct dentry *parent = path->dentry->d_parent; +struct dentry *parent;const struct mnt_idmap *idmap =mnt_idmap (path->mnt);int inherited_flags =0 , flags =0 , i, nt_size =0 , pdacl_size;int rc =0 , pntsd_type, ppntsd_size, acl_len, aces_size;
@@ -1217,8 +1218,14 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,char *aces_base;bool is_dir =S_ISDIR (d_inode (path->dentry)->i_mode); + parent =dget_parent (path->dentry); +if (!d_inode (parent)) { +dput (parent); +return -ENOENT ; + } ppntsd_size =ksmbd_vfs_get_sd_xattr (conn, idmap, parent, &parent_pntsd); +dput (parent);if (ppntsd_size <=0 )return -ENOENT ;
Sasha Levin
maintainerPATCH 1/1 ksmbd: pin parent dentries in SMB2 CREATE ACL path
From: Jiwoo Kim <[email protected]>
[ Upstream commit 0383a66dabd7aa06237b9b24713c03656abeffe4 ]
smb2_open() and smb_inherit_dacl() read a child's d_parent without a dentry reference. A concurrent SMB request can move the child and remove the parent while CREATE uses its inode for permission, status, and ACL inheritance work. A remote SMB race with concurrent opener and mover connections on a writable KSMBD acl_xattr share triggered an 8-byte slab-use-after-free read in get_cached_acl on tmpfs and ext4 KASAN guests. With oops=panic, it also caused an Oops and kernel panic on an ext4 guest.
Take a parent dentry reference around each parent inode or ACL access in these paths and release it when the operation completes. Treat a negative parent dentry as -ENOENT for the affected operation.
On a tmpfs KASAN QEMU guest, two 3,000-round reproducer instances completed without a KASAN report or Oops; SMB remained reachable. On an ext4 non-KASAN QEMU guest with oops=panic, a 2,000-operation no-race control and two 5,000-round reproducer instances completed without an Oops or panic. An SMB health probe still succeeded.
OpenAI Codex assisted with finding the bug, generating the SMB race reproducer, drafting this fix and changelog, and running the tests.
--- fs/smb/server/smb2pdu.c | 39 +++++++++++++++++++++++++++++++-------- fs/smb/server/smbacl.c | 9 ++++++++- 2 files changed, 39 insertions(+), 9 deletions(-)
fs/smb/server/smb2pdu.c +31 -8
@@ -3442,16 +3442,32 @@ int smb2_open(struct ksmbd_work *work)if ((daccess &FILE_DELETE_LE ) || (req->CreateOptions &FILE_DELETE_ON_CLOSE_LE )) { - rc =inode_permission (idmap, -d_inode (path.dentry->d_parent), -MAY_EXEC |MAY_WRITE ); +struct dentry *parent =dget_parent (path.dentry); +struct inode *parent_inode =d_inode (parent); + +if (parent_inode) + rc =inode_permission (idmap, parent_inode, +MAY_EXEC |MAY_WRITE ); +else + rc = -ENOENT ; +dput (parent);if (rc) goto err_out; } } } - rc =ksmbd_query_inode_status (path.dentry->d_parent); + { +struct dentry *parent =dget_parent (path.dentry); + +if (!d_inode (parent)) { +dput (parent); + rc = -ENOENT ; + goto err_out; + } + rc =ksmbd_query_inode_status (parent); +dput (parent); + }if (rc ==KSMBD_INODE_STATUS_PENDING_DELETE ) { rc = -EBUSY ; goto err_out;
@@ -3505,10 +3521,17 @@ int smb2_open(struct ksmbd_work *work)if (created) {int posix_acl_rc;struct inode *inode =d_inode (path.dentry); - - posix_acl_rc =ksmbd_vfs_inherit_posix_acl (idmap, - &path, -d_inode (path.dentry->d_parent)); +struct inode *parent_inode; +struct dentry *parent; + + parent =dget_parent (path.dentry); + parent_inode =d_inode (parent); +if (parent_inode) + posix_acl_rc =ksmbd_vfs_inherit_posix_acl (idmap, &path, + parent_inode); +else + posix_acl_rc = -ENOENT ; +dput (parent);if (posix_acl_rc)ksmbd_debug (SMB ,"inherit posix acl failed : %d\n" , posix_acl_rc);
fs/smb/server/smbacl.c +8 -1
@@ -7,6 +7,7 @@*/ #include <linux/fs.h> +#include <linux/dcache.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/mnt_idmapping.h>
@@ -1200,7 +1201,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_acl *parent_pdacl;struct smb_ntsd *parent_pntsd =NULL ;struct smb_sid owner_sid, group_sid; -struct dentry *parent = path->dentry->d_parent; +struct dentry *parent;struct mnt_idmap *idmap =mnt_idmap (path->mnt);int inherited_flags =0 , flags =0 , i, nt_size =0 , pdacl_size;int rc =0 , pntsd_type, ppntsd_size, acl_len, aces_size;
@@ -1210,8 +1211,14 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,char *aces_base;bool is_dir =S_ISDIR (d_inode (path->dentry)->i_mode); + parent =dget_parent (path->dentry); +if (!d_inode (parent)) { +dput (parent); +return -ENOENT ; + } ppntsd_size =ksmbd_vfs_get_sd_xattr (conn, idmap, parent, &parent_pntsd); +dput (parent);if (ppntsd_size <=0 )return -ENOENT ;
Signature · 1 line
2.53.0