FAILED: patch "[PATCH] ksmbd: use check_add_overflow() to prevent u16 DACL size" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-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-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 299f962c0b02d048fb45d248b4da493d03f3175d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026042457-bullfrog-connected-a810@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 299f962c0b02d048fb45d248b4da493d03f3175d Mon Sep 17 00:00:00 2001
From: Tristan Madani <[email protected]>
Date: Fri, 17 Apr 2026 19:54:57 +0000
Subject: [PATCH] ksmbd: use check_add_overflow() to prevent u16 DACL size
overflow
set_posix_acl_entries_dacl() and set_ntacl_dacl() accumulate ACE sizes in u16 variables. When a file has many POSIX ACL entries, the accumulated size can wrap past 65535, causing the pointer arithmetic (char *)pndace + *size to land within already-written ACEs. Subsequent writes then overwrite earlier entries, and pndacl->size gets a truncated value.
Use check_add_overflow() at each accumulation point to detect the wrap before it corrupts the buffer, consistent with existing check_mul_overflow() usage elsewhere in smbacl.c.
fs/smb/server/smbacl.c +12 -4
@@ -596,6 +596,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,struct smb_sid *sid;struct smb_ace *ntace;int i, j; +u16 ace_sz;if (!fattr->cf_acls) goto posix_default_acl;
@@ -640,8 +641,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, flags =0x03 ; ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , flags, + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , flags, pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -650,8 +653,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,if (S_ISDIR (fattr->cf_mode) && (pace->e_tag ==ACL_USER || pace->e_tag ==ACL_GROUP )) { ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x03 , pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -691,8 +696,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, } ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x0b , + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x0b , pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -728,7 +735,8 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap,break ;memcpy ((char *)pndace + size, ntace, nt_ace_size); - size += nt_ace_size; +if (check_add_overflow (size, nt_ace_size, &size)) +break ; aces_size -= nt_ace_size; ntace = (struct smb_ace *)((char *)ntace + nt_ace_size); num_aces++;
Sasha Levin
maintainerPATCH 1/1 ksmbd: use check_add_overflow() to prevent u16 DACL size overflow
From: Tristan Madani <[email protected]>
[ Upstream commit 299f962c0b02d048fb45d248b4da493d03f3175d ]
set_posix_acl_entries_dacl() and set_ntacl_dacl() accumulate ACE sizes in u16 variables. When a file has many POSIX ACL entries, the accumulated size can wrap past 65535, causing the pointer arithmetic (char *)pndace + *size to land within already-written ACEs. Subsequent writes then overwrite earlier entries, and pndacl->size gets a truncated value.
Use check_add_overflow() at each accumulation point to detect the wrap before it corrupts the buffer, consistent with existing check_mul_overflow() usage elsewhere in smbacl.c.
--- fs/ksmbd/smbacl.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/ksmbd/smbacl.c +12 -4
@@ -588,6 +588,7 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns,struct smb_sid *sid;struct smb_ace *ntace;int i, j; +u16 ace_sz;if (!fattr->cf_acls) goto posix_default_acl;
@@ -632,8 +633,10 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, flags =0x03 ; ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , flags, + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , flags, pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -642,8 +645,10 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns,if (S_ISDIR (fattr->cf_mode) && (pace->e_tag ==ACL_USER || pace->e_tag ==ACL_GROUP )) { ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED , + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x03 , pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -683,8 +688,10 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, } ntace = (struct smb_ace *)((char *)pndace + *size); - *size +=fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x0b , + ace_sz =fill_ace_for_sid (ntace, sid,ACCESS_ALLOWED ,0x0b , pace->e_perm,0777 ); +if (check_add_overflow (*size, ace_sz, size)) +break ; (*num_aces)++;if (pace->e_tag ==ACL_USER ) ntace->access_req |=
@@ -720,7 +727,8 @@ static void set_ntacl_dacl(struct user_namespace *user_ns,break ;memcpy ((char *)pndace + size, ntace, nt_ace_size); - size += nt_ace_size; +if (check_add_overflow (size, nt_ace_size, &size)) +break ; aces_size -= nt_ace_size; ntace = (struct smb_ace *)((char *)ntace + nt_ace_size); num_aces++;
Signature · 1 line
2.53.0