All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smb: client: fix DACL-rewrite heap overflow in id_mode_to_cifs_acl()
@ 2026-07-09 15:54 Bjoern Doebel
  2026-07-09 22:15 ` Steve French
  2026-09-04 12:58 ` [PATCH] smb: client: fix heap overflow in DACL owner/group rewrite Bjoern Doebel
  0 siblings, 2 replies; 11+ messages in thread
From: Bjoern Doebel @ 2026-07-09 15:54 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, samba-technical
  Cc: stable, doebel, nmanthey

Budget the destination buffer for the worst case in both branches:
every rewritten ACE may take sizeof(struct smb_ace) bytes (which
already accounts for an smb_sid with SID_MAX_SUB_AUTHORITIES
sub-authorities), plus the smb_acl header that
replace_sids_and_copy_aces() emits.

Fixes: bc3e9dd9d104 ("cifs: Change SIDs in ACEs while transferring file ownership.")
Cc: stable@vger.kernel.org
Signed-off-by: Bjoern Doebel <doebel@amazon.de>
Assisted-by: Kiro:claude-opus-4.6
---
 fs/smb/client/cifsacl.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 07cf0e5782337..6d572dd995d79 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1812,11 +1812,13 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
 				cifs_put_tlink(tlink);
 				return rc;
 			}
-			if (mode_from_sid)
-				nsecdesclen +=
-					le16_to_cpu(dacl_ptr->num_aces) * sizeof(struct smb_ace);
-			else /* cifsacl */
-				nsecdesclen += le16_to_cpu(dacl_ptr->size);
+			/*
+			 * Worst case: every ACE is rewritten with a new SID of
+			 * SID_MAX_SUB_AUTHORITIES sub-auths -> sizeof(smb_ace) each,
+			 * plus the smb_acl header replace_sids_and_copy_aces() emits.
+			 */
+			nsecdesclen += sizeof(struct smb_acl) +
+				le16_to_cpu(dacl_ptr->num_aces) * sizeof(struct smb_ace);
 		}
 	}
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-09 17:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 15:54 [PATCH] smb: client: fix DACL-rewrite heap overflow in id_mode_to_cifs_acl() Bjoern Doebel
2026-07-09 22:15 ` Steve French
2026-07-10  6:37   ` Bjoern Doebel
2026-09-04 12:58 ` [PATCH] smb: client: fix heap overflow in DACL owner/group rewrite Bjoern Doebel
2026-09-05  1:15   ` Namjae Jeon
2026-09-07 17:59     ` Bjoern Doebel
2026-09-08 16:09   ` [PATCH v3 0/2] smb: client: fix DACL rewrite overflows Bjoern Doebel
2026-09-08 16:10     ` [PATCH v3 1/2] smb: client: fix heap overflow in DACL owner/group rewrite Bjoern Doebel
2026-09-08 16:10     ` [PATCH v3 2/2] smb: client: fail DACL rewrite when the new DACL exceeds 64K Bjoern Doebel
2026-09-09  2:55       ` Namjae Jeon
2026-09-09 17:15     ` [PATCH v3 0/2] smb: client: fix DACL rewrite overflows Paulo Alcantara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.