From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-cifs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
samba-technical@lists.samba.org, stable <stable@kernel.org>
Subject: Re: [PATCH 2/2] smb: client: fix OOB reads parsing symlink error response
Date: Wed, 8 Apr 2026 17:01:56 +0800 [thread overview]
Message-ID: <297d8d9b-adf7-42fd-a1c2-5b1f230032bc@chenxiaosong.com> (raw)
In-Reply-To: <2026040636-icy-constable-9e17@gregkh>
Sashiko reported the following out-of-bounds issue. I have checked and
confirmed that this indeed causes an OOB access.
When create fails on symlink, `len` in `smb2_check_message()` may be
smaller than `calc_len`. The function flow is as follows:
```
smb2_check_message()
// ensure StructureSize2 is 9
if (... pdu->StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2_LE ...) //
false
smb2_calc_size()
len = le16_to_cpu(shdr->StructureSize) == 64
len += le16_to_cpu(pdu->StructureSize2) == 64 + 9
smb2_get_data_area_len
if (shdr->StructureSize == 9) // true, return NULL
calc_len == 64 + 9
if (len != calc_len) { // true
/* create failed on symlink */
if (command == SMB2_CREATE_HE && shdr->Status ==
STATUS_STOPPED_ON_SYMLINK) // true
```
Should we add the following check? Or check it in symlink_data()?
```
-- a/fs/smb/client/smb2misc.c
+++ b/fs/smb/client/smb2misc.c
@@ -241,7 +241,8 @@ smb2_check_message(char *buf, unsigned int pdu_len,
unsigned int len,
if (len != calc_len) {
/* create failed on symlink */
if (command == SMB2_CREATE_HE &&
- shdr->Status == STATUS_STOPPED_ON_SYMLINK)
+ shdr->Status == STATUS_STOPPED_ON_SYMLINK &&
+ len > calc_len)
return 0;
/* Windows 7 server returns 24 bytes more */
if (calc_len + 24 == len && command ==
SMB2_OPLOCK_BREAK_HE)
```
>> --- a/fs/smb/client/smb2file.c
>> +++ b/fs/smb/client/smb2file.c
>> @@ -27,10 +27,11 @@ static struct smb2_symlink_err_rsp *symlink_data(const struct kvec *iov)
>> {
>> struct smb2_err_rsp *err = iov->iov_base;
>> struct smb2_symlink_err_rsp *sym = ERR_PTR(-EINVAL);
>> + u8 *end = (u8 *)err + iov->iov_len;
>> u32 len;
>>
>> if (err->ErrorContextCount) {
> Since smb2_check_message() returns success without length validation for
> the symlink error response, is it possible for iov->iov_len to be smaller
> than sizeof(struct smb2_err_rsp)?
> If the buffer only contains the base SMB2 header (64 bytes), does accessing
> err->ErrorContextCount (at offset 66) or err->ByteCount later in this
> function cause an out-of-bounds read?
--
ChenXiaoSong <chenxiaosong@kylinos.cn>
Chinese Homepage: chenxiaosong.com
English Homepage: chenxiaosong.com/en
next prev parent reply other threads:[~2026-04-08 9:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 13:49 [PATCH 0/2] smb: some potential bugfixes Greg Kroah-Hartman
2026-04-06 13:49 ` [PATCH 1/2] smb: client: fix off-by-8 bounds check in check_wsl_eas() Greg Kroah-Hartman
2026-04-08 2:51 ` ChenXiaoSong
2026-04-08 5:39 ` Greg Kroah-Hartman
2026-04-08 5:58 ` ChenXiaoSong
2026-04-08 6:15 ` Greg Kroah-Hartman
2026-04-08 6:19 ` ChenXiaoSong
2026-04-08 6:40 ` Greg Kroah-Hartman
2026-04-08 6:52 ` ChenXiaoSong
2026-04-08 6:56 ` Greg Kroah-Hartman
2026-04-09 3:09 ` ChenXiaoSong
2026-04-08 9:39 ` Yuanfu Xie
2026-04-06 13:49 ` [PATCH 2/2] smb: client: fix OOB reads parsing symlink error response Greg Kroah-Hartman
2026-04-08 9:01 ` ChenXiaoSong [this message]
2026-04-07 3:03 ` [PATCH 0/2] smb: some potential bugfixes Paulo Alcantara
[not found] ` <CAH2r5mvXFzWxs70Jmg=yWddmcHs+Bpf8eiBUvyc4oOMLzdCY7w@mail.gmail.com>
2026-04-08 5:45 ` Greg Kroah-Hartman
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=297d8d9b-adf7-42fd-a1c2-5b1f230032bc@chenxiaosong.com \
--to=chenxiaosong@chenxiaosong.com \
--cc=bharathsm@microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).