FAILED: patch "[PATCH] smb: client: validate POSIX create context length" 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 fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092934-enclosure-bronchial-deea@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc Mon Sep 17 00:00:00 2001
From: Zihan Xi <[email protected]>
Date: Wed, 16 Sep 2026 15:29:25 +0000
Subject: [PATCH] smb: client: validate POSIX create context length
parse_posix_ctxt() reads the fixed nlink, reparse_tag, and mode fields before checking that the POSIX create context contains them. A short context can pass the generic checks and still make these fixed-width reads run past its declared data.
The current in-tree smb2_open_file() path passes a NULL posix pointer, so this handler is not reached on the ordinary open path. Still require the POSIX data to cover all three fields before reading them because the helper performs those unguarded reads. Keep the existing soft-failure behavior so malformed optional metadata does not fail the open.
fs/smb/client/smb2pdu.c +5 -2
@@ -2396,12 +2396,15 @@ static void parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info, struct create_posix_rsp *posix) { - int sid_len; u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset); -u8 *end = beg +le32_to_cpu (cc->DataLength); +u32 dlen =le32_to_cpu (cc->DataLength); +u8 *end = beg + dlen; +int sid_len;u8 *sid;memset (posix,0 ,sizeof (*posix)); +if (dlen <3 *sizeof (__le32)) +return ; posix->nlink =get_unaligned_le32 (beg); posix->reparse_tag =get_unaligned_le32 (beg +4 );
Sasha Levin
maintainerPATCH 1/1 smb: client: validate POSIX create context length
From: Zihan Xi <[email protected]>
[ Upstream commit fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc ]
parse_posix_ctxt() reads the fixed nlink, reparse_tag, and mode fields before checking that the POSIX create context contains them. A short context can pass the generic checks and still make these fixed-width reads run past its declared data.
The current in-tree smb2_open_file() path passes a NULL posix pointer, so this handler is not reached on the ordinary open path. Still require the POSIX data to cover all three fields before reading them because the helper performs those unguarded reads. Keep the existing soft-failure behavior so malformed optional metadata does not fail the open.
--- fs/cifs/smb2pdu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +5 -2
@@ -2030,12 +2030,15 @@ static void parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info, struct create_posix_rsp *posix) { - int sid_len; u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset); -u8 *end = beg +le32_to_cpu (cc->DataLength); +u32 dlen =le32_to_cpu (cc->DataLength); +u8 *end = beg + dlen; +int sid_len;u8 *sid;memset (posix,0 ,sizeof (*posix)); +if (dlen <3 *sizeof (__le32)) +return ; posix->nlink =get_unaligned_le32 (beg); posix->reparse_tag =get_unaligned_le32 (beg +4 );
Signature · 1 line
2.53.0