FAILED: patch "[PATCH] ksmbd: let the owner read and change the DACL when no ACE names it" failed to apply to 6.18-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.18-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.18.y
git checkout FETCH_HEAD
git cherry-pick -x ffc855fe16afe02b22305111aa68cd8d07360941
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From ffc855fe16afe02b22305111aa68cd8d07360941 Mon Sep 17 00:00:00 2001
From: Ian Bridges <[email protected]>
Date: Mon, 2 Nov 2026 00:15:36 -0600
Subject: [PATCH] ksmbd: let the owner read and change the DACL when no ACE
names it
smb_check_perm_dacl() refuses the owner when neither its DACL lookup nor the POSIX ACL fallback matches. The owner then cannot read or replace the DACL over SMB. MS-DTYP 2.5.3.2 grants the owner READ_CONTROL and WRITE_DAC unless an OWNER RIGHTS ACE applies.
An empty DACL allows the owner's explicit requests for these rights but refuses MAXIMUM_ALLOWED. smb2_open() uses that check for the maximal access reply (MS-SMB2 3.3.5.9.5), so even a READ_CONTROL open fails when it asks for that reply.
Grant the owner's implicit rights on both paths, for explicit requests and MAXIMUM_ALLOWED, unless an OWNER RIGHTS ACE applies.
--- fs/smb/server/smbacl.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
fs/smb/server/smbacl.c +30 -4
@@ -1477,6 +1477,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,int i, found =0 ;unsigned int access_bits =0 , denied =0 ;struct smb_ace *others_ace =NULL ; +bool or_ace = false;struct posix_acl_entry *pa_entry;unsigned int sid_type =SIDOWNER ;unsigned short ace_size;
@@ -1509,6 +1510,8 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, is_owner = uid ==from_kuid (&init_user_ns,vfsuid_into_kuid (vfsuid));if (!pdacl->num_aces) { +unsigned int allowed =0 ; +/* * An empty (present, zero-ACE) DACL grants no access to * anyone except the object owner's implicit READ_CONTROL
@@ -1517,9 +1520,14 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,* not let trailing bytes after a zero-ACE DACL become an * implicit grant. */ -if (!is_owner || - (*pdaccess & ~(FILE_READ_CONTROL_LE |FILE_WRITE_DAC_LE ))) +if (is_owner) + allowed =READ_CONTROL |WRITE_DAC ; +if (*pdaccess &FILE_MAXIMAL_ACCESS_LE ) + requested |= allowed; +if (!allowed || requested & ~allowed) rc = -EACCES ; +else + *pdaccess =cpu_to_le32 (requested); goto err_out; }
@@ -1604,6 +1612,9 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, found =1 ;break ; } +if (!compare_sids (&sid_owner_rights, &ace->sid) && + !(ace->flags &INHERIT_ONLY_ACE )) + or_ace = true;if (!compare_sids (&sid_everyone, &ace->sid) || !compare_sids (&sid_authusers, &ace->sid)) others_ace = ace;
@@ -1648,8 +1659,23 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,if (others_ace) { ace = others_ace; }else { -ksmbd_debug (SMB ,"Can't find corresponding sid\n" ); - rc = -EACCES ; +unsigned int allowed =0 ; + +/* +* No ACE names the owner, who may still read and +* change the DACL unless OWNER RIGHTS applies +* (MS-DTYP 2.5.3.2). +*/ +if (is_owner && !or_ace) + allowed =READ_CONTROL |WRITE_DAC ; +if (*pdaccess &FILE_MAXIMAL_ACCESS_LE ) + requested |= allowed; +if (!allowed || requested & ~allowed) { +ksmbd_debug (SMB ,"Can't find corresponding sid\n" ); + rc = -EACCES ; + goto err_out; + } + *pdaccess =cpu_to_le32 (requested); goto err_out; } }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: let the owner read and change the DACL when no ACE names it
From: Ian Bridges <[email protected]>
[ Upstream commit ffc855fe16afe02b22305111aa68cd8d07360941 ]
smb_check_perm_dacl() refuses the owner when neither its DACL lookup nor the POSIX ACL fallback matches. The owner then cannot read or replace the DACL over SMB. MS-DTYP 2.5.3.2 grants the owner READ_CONTROL and WRITE_DAC unless an OWNER RIGHTS ACE applies.
An empty DACL allows the owner's explicit requests for these rights but refuses MAXIMUM_ALLOWED. smb2_open() uses that check for the maximal access reply (MS-SMB2 3.3.5.9.5), so even a READ_CONTROL open fails when it asks for that reply.
Grant the owner's implicit rights on both paths, for explicit requests and MAXIMUM_ALLOWED, unless an OWNER RIGHTS ACE applies.
--- fs/smb/server/smbacl.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
fs/smb/server/smbacl.c +33 -4
@@ -27,6 +27,9 @@ static const struct smb_sid creator_owner = {/* security id for everyone/world system group */ static const struct smb_sid creator_group = {1 ,1 , {0 ,0 ,0 ,0 ,0 ,3 }, {cpu_to_le32 (1 )} }; +/* security id for owner rights */ +static const struct smb_sid sid_owner_rights = { +1 ,1 , {0 ,0 ,0 ,0 ,0 ,3 }, {cpu_to_le32 (4 )} };/* security id for everyone/world system group */ static const struct smb_sid sid_everyone = {
@@ -1466,6 +1469,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,int i, found =0 ;unsigned int access_bits =0 , denied =0 ;struct smb_ace *others_ace =NULL ; +bool or_ace = false;struct posix_acl_entry *pa_entry;unsigned int sid_type =SIDOWNER ;unsigned short ace_size;
@@ -1498,6 +1502,8 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, is_owner = uid ==from_kuid (&init_user_ns,vfsuid_into_kuid (vfsuid));if (!pdacl->num_aces) { +unsigned int allowed =0 ; +/* * An empty (present, zero-ACE) DACL grants no access to * anyone except the object owner's implicit READ_CONTROL
@@ -1506,9 +1512,14 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,* not let trailing bytes after a zero-ACE DACL become an * implicit grant. */ -if (!is_owner || - (*pdaccess & ~(FILE_READ_CONTROL_LE |FILE_WRITE_DAC_LE ))) +if (is_owner) + allowed =READ_CONTROL |WRITE_DAC ; +if (*pdaccess &FILE_MAXIMAL_ACCESS_LE ) + requested |= allowed; +if (!allowed || requested & ~allowed) rc = -EACCES ; +else + *pdaccess =cpu_to_le32 (requested); goto err_out; }
@@ -1585,6 +1596,9 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, found =1 ;break ; } +if (!compare_sids (&sid_owner_rights, &ace->sid) && + !(ace->flags &INHERIT_ONLY_ACE )) + or_ace = true;if (!compare_sids (&sid_everyone, &ace->sid) || !compare_sids (&sid_authusers, &ace->sid)) others_ace = ace;
@@ -1629,8 +1643,23 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,if (others_ace) { ace = others_ace; }else { -ksmbd_debug (SMB ,"Can't find corresponding sid\n" ); - rc = -EACCES ; +unsigned int allowed =0 ; + +/* +* No ACE names the owner, who may still read and +* change the DACL unless OWNER RIGHTS applies +* (MS-DTYP 2.5.3.2). +*/ +if (is_owner && !or_ace) + allowed =READ_CONTROL |WRITE_DAC ; +if (*pdaccess &FILE_MAXIMAL_ACCESS_LE ) + requested |= allowed; +if (!allowed || requested & ~allowed) { +ksmbd_debug (SMB ,"Can't find corresponding sid\n" ); + rc = -EACCES ; + goto err_out; + } + *pdaccess =cpu_to_le32 (requested); goto err_out; } }
Signature · 1 line
2.53.0