From: Frank Sorenson <sorenson@redhat.com>
To: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org, pc@manguebit.org,
linkinjeon@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] smb: client: fix OOB array access in __smb2_calc_size() on unknown Command
Date: Fri, 21 Aug 2026 16:09:42 -0500 [thread overview]
Message-ID: <512e7a00-5306-41a3-b336-3c75377a7d0d@redhat.com> (raw)
In-Reply-To: <32cea692-1aa7-4eac-8f6f-eb39db63777a@talpey.com>
On 8/21/26 12:08 PM, Tom Talpey wrote:
> The SMB3 protocol often specifies closing the connection on invalid messages, is there some reason you are opting to ignore this field?
>
> Tom.
Examining the paths into __smb2_calc_size() more closely, I don't see a
call path that feeds an unvalidated Command into __smb2_calc_size();
either smb2_check_message() pre-validates it (and tears down the
connection as you expected), or the caller is operating on already-known
data.
So at this point, the OOB is unreachable, and this patch is unnecessary.
My apologies; this patch should be disregarded.
Frank
> Aug 21, 2026 10:45:35 AM Frank Sorenson <sorenson@redhat.com>:
>
>> has_smb2_data_area[] is indexed by the server-supplied shdr->Command
>> with no bounds check:
>>
>> if (has_smb2_data_area[le16_to_cpu(shdr->Command)] == false)
>>
>> The array has NUMBER_OF_SMB2_COMMANDS (0x13) entries; any Command value
>>> = 0x13 reads past the end into adjacent read-only data.
>> Add an upper-bound check before the lookup; commands outside the valid
>> range have no data area, so treat them as false.
>>
>> Fixes: 093b2bdad322 ("CIFS: Make demultiplex_thread work with SMB2 code")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Frank Sorenson <sorenson@redhat.com>
>> ---
>> fs/smb/client/smb2misc.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
>> index 9068175e57cd..26b41ea3b72b 100644
>> --- a/fs/smb/client/smb2misc.c
>> +++ b/fs/smb/client/smb2misc.c
>> @@ -451,7 +451,8 @@ __smb2_calc_size(void *buf, bool *have_data, bool *data_area_overlap)
>> */
>> len += le16_to_cpu(pdu->StructureSize2);
>>
>> - if (has_smb2_data_area[le16_to_cpu(shdr->Command)] == false)
>> + if (le16_to_cpu(shdr->Command) >= ARRAY_SIZE(has_smb2_data_area) ||
>> + !has_smb2_data_area[le16_to_cpu(shdr->Command)])
>> goto calc_size_exit;
>>
>> smb2_get_data_area_len(&offset, &data_length, shdr);
>> --
>> 2.55.0
--
Frank Sorenson
sorenson@redhat.com
Principal Software Maintenance Engineer, filesystems
Red Hat
prev parent reply other threads:[~2026-08-21 21:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 14:29 [PATCH] smb: client: fix OOB array access in __smb2_calc_size() on unknown Command Frank Sorenson
2026-08-21 17:08 ` Tom Talpey
2026-08-21 21:09 ` Frank Sorenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=512e7a00-5306-41a3-b336-3c75377a7d0d@redhat.com \
--to=sorenson@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.