FAILED: patch "[PATCH] ksmbd: evaluate the DACL in order for explicit access" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-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.1.y
git checkout FETCH_HEAD
git cherry-pick -x 20bed0d6ff62d985fe8222958825504b8aad4e88
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112543-battle-overtime-0414@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 20bed0d6ff62d985fe8222958825504b8aad4e88 Mon Sep 17 00:00:00 2001
From: Ian Bridges <[email protected]>
Date: Sun, 8 Nov 2026 12:20:10 -0600
Subject: [PATCH] ksmbd: evaluate the DACL in order for explicit access
requests
For requests without MAXIMUM_ALLOWED, smb_check_perm_dacl() selects one ACE instead of evaluating the DACL in order. When the selected ACE is a deny ACE, the function grants the complement of its mask, and deny ACEs before it are ignored. The selected ACE can also be inherit-only, unsupported, or an NFS mode ACE.
Guest and anonymous sessions also match Authenticated Users. These bugs can grant read or write access that the stored DACL does not grant. For example, a deny of FILE_READ_DATA grants FILE_WRITE_DATA, and guests can read files granted only to Authenticated Users.
Evaluate explicit requests in DACL order. Use exact SID matching for the caller, Everyone, Authenticated Users, OWNER RIGHTS and the caller's groups. Match Authenticated Users only for authenticated sessions, and ignore the NFS mode SID.
An Authenticated Users ACE must still prevent the POSIX ACL fallback from replacing the DACL result for guest and anonymous sessions. The ACE does not grant them access.
Keep the existing single-ACE behavior when a non-inherit-only object deny ACE is present because ksmbd does not parse those ACEs. Guest and anonymous sessions do not match Authenticated Users there either. MAXIMUM_ALLOWED behavior is unchanged.
fs/smb/server/mgmt/user_config.h +5 -0
@@ -67,4 +67,9 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp,void ksmbd_free_user (struct ksmbd_user *user);bool ksmbd_anonymous_user (struct ksmbd_user *user);bool ksmbd_compare_user (struct ksmbd_user *u1,struct ksmbd_user *u2); + +static inline bool ksmbd_user_authenticated (struct ksmbd_user *user) +{ +return user && !user_guest (user) && !ksmbd_anonymous_user (user); +}#endif /* __USER_CONFIG_MANAGEMENT_H__ */
fs/smb/server/smb2pdu.c +8 -3
@@ -4338,7 +4338,8 @@ static int smb2_handle_app_instance_id(struct ksmbd_work *work,/* Authorize the referenced open even if its name changes meanwhile. */ old_path = &old_fp->filp->f_path; rc =smb_check_perm_dacl (conn, old_path, &maximal_access,0 , - work->sess->user->uid, false); + work->sess->user->uid, +ksmbd_user_authenticated (work->sess->user), false);if (rc) {/* Access denial prevents takeover, not the CREATE itself. */ ksmbd_put_durable_fd (old_fp);
@@ -4860,14 +4861,17 @@ int smb2_open(struct ksmbd_work *work)if (file_present && !(req->CreateOptions &FILE_DELETE_ON_CLOSE_LE )) { rc =smb_check_perm_dacl (conn, &path, &daccess, req->DesiredAccess, - sess->user->uid, false); + sess->user->uid, +ksmbd_user_authenticated (sess->user), false);if (rc) goto err_out;if (maximal_access_ctxt) { maximal_access =FILE_MAXIMAL_ACCESS_LE ; rc =smb_check_perm_dacl (conn, &path, &maximal_access, -0 , sess->user->uid, false); +0 , sess->user->uid, +ksmbd_user_authenticated (sess->user), + false);if (rc) goto err_out;
@@ -6347,6 +6351,7 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv) rc =smb_check_perm_dacl (priv->work->conn, &path, &daccess, daccess, priv->work->sess->user->uid, +ksmbd_user_authenticated (priv->work->sess->user), true);if (rc) {dput (dent);
fs/smb/server/smbacl.c +46 -12
128 lines not on this page · raw message
fs/smb/server/smbacl.h +1 -1
@@ -97,7 +97,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn, const struct path *path, unsigned int uid, unsigned int gid);int smb_check_perm_dacl (struct ksmbd_conn *conn,const struct path *path,__le32 *pdaccess,__le32 raw_daccess,int uid, -bool strict); +bool authenticated,bool strict); int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, const struct path *path, struct smb_ntsd *pntsd, int ntsd_len, bool type_check, bool get_write, bool posix_open,
fs/smb/server/tests/smbacl_kunit.c +2 -2
@@ -229,7 +229,7 @@ static void ksmbd_smb_check_perm_dacl_boundary_test(struct kunit *test) goto out; rc =smb_check_perm_dacl (NULL , &file->f_path, &daccess, -cpu_to_le32 (FILE_READ_DATA ),0 , false); +cpu_to_le32 (FILE_READ_DATA ),0 , true, false);/* * The post-boundary ACE (ACE #2, beyond pdacl->size) grants
@@ -271,7 +271,7 @@ ksmbd_smb_check_perm_dacl_maximal_boundary_test(struct kunit *test) goto out; rc =smb_check_perm_dacl (NULL , &file->f_path, &daccess, -FILE_MAXIMAL_ACCESS_LE ,0 , false); +FILE_MAXIMAL_ACCESS_LE ,0 , true, false);KUNIT_EXPECT_EQ (test,0 , rc);if (rc) goto out;