From: Frank Sorenson <sorenson@redhat.com>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org, pc@manguebit.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 11/11] smb: client: fix NameOffset and Next field validation in smb2_parse_contexts()
Date: Sat, 29 Aug 2026 11:26:08 -0500 [thread overview]
Message-ID: <666879b8-5117-4c41-ab1d-e50637e68a5d@redhat.com> (raw)
In-Reply-To: <CAKYAXd8_jvTz6DX-1OjkCu1UAe7qKKHKOyW7-yOqrqVtxC6dPQ@mail.gmail.com>
On 8/29/26 9:01 AM, Namjae Jeon wrote:
>> case 16:
>> - if (posix && !memcmp(name, smb3_create_tag_posix, 16))
>> + if (dlen && posix && !memcmp(name, smb3_create_tag_posix, 16))
> Could we check that dlen is large enough for the fixed POSIX fields
> before calling parse_posix_ctxt()? It reads 12 bytes even when
> DataLength is smaller.
so this needs to be:
if (dlen > 12 && posix && !memcmp(name, smb3_create_tag_posix, 16))
I think we'll need similar before the calls to the
server->ops->parse_lease_buf:
if (dlen && !strncmp(name,
SMB2_CREATE_REQUEST_LEASE, 4)) {
*oplock = server->ops->parse_lease_buf(cc, epoch,
lease_key);
for smb2: smb2_parse_lease_buf(void *buf, __u16 *epoch, char *lease_key)
{ struct create_lease *lc = (struct create_lease *)buf;
*epoch = 0; /* not used */ if (lc->lcontext.LeaseFlags &
SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE) return
SMB2_OPLOCK_LEVEL_NOCHANGE; return
le32_to_cpu(lc->lcontext.LeaseState);
/* See MS-SMB2 2.2.13.2.8 */ struct lease_context { __u8
LeaseKey[SMB2_LEASE_KEY_SIZE]; __le32 LeaseState; __le32
LeaseFlags; __le64 LeaseDuration; } __packed;
for smb2, we only access through LeaseFlags (24 bytes), but the entire
struct is 32
static __u8 smb3_parse_lease_buf(void *buf, __u16 *epoch, char
*lease_key) { struct create_lease_v2 *lc = (struct
create_lease_v2 *)buf; *epoch = le16_to_cpu(lc->lcontext.Epoch);
if (lc->lcontext.LeaseFlags &
SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE) return
SMB2_OPLOCK_LEVEL_NOCHANGE; if (lease_key)
memcpy(lease_key, &lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
return le32_to_cpu(lc->lcontext.LeaseState);
/* See MS-SMB2 2.2.13.2.10 */ struct lease_context_v2 { __u8
LeaseKey[SMB2_LEASE_KEY_SIZE]; __le32 LeaseState; __le32
LeaseFlags; __le64 LeaseDuration; __u8
ParentLeaseKey[SMB2_LEASE_KEY_SIZE]; __le16 Epoch;
__le16 Reserved; } __packed; and for smb3, we'll need through Epoch, so
SMB2_LEASE_KEY_SIZE + 4 + 4 + 8 + SMB2_LEASE_KEY_SIZE + 2 = 50,
with the entire struct being 52 bytes
and also before the call to parse_query_id_ctxt():
} else if (dlen > 16 && buf &&
!strncmp(name, SMB2_CREATE_QUERY_ON_DISK_ID, 4))
{ parse_query_id_ctxt(cc, buf);
parse_query_id_ctxt(struct create_context *cc, struct smb2_file_all_info *buf)
{
struct create_disk_id_rsp *pdisk_id = (struct create_disk_id_rsp *)cc;
cifs_dbg(FYI, "parse query id context 0x%llx 0x%llx\n",
pdisk_id->DiskFileId, pdisk_id->VolumeId);
buf->IndexNumber = pdisk_id->DiskFileId;
/* See MS-SMB2 2.2.14.2.9 */
struct create_disk_id_rsp {
struct create_context_hdr ccontext;
__u8 Name[8];
__le64 DiskFileId;
__le64 VolumeId;
__u8 Reserved[16];
} __packed;
With varying sizes, how do we handle the check prior to the call to the version-specificserver->ops->parse_lease_buf ?
--
Frank Sorenson
sorenson@redhat.com
Principal Software Maintenance Engineer, filesystems
Red Hat
next prev parent reply other threads:[~2026-08-29 16:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 15:31 [PATCH v3 00/11] smb: client: fix OOB reads and UAFs in SMB2/3 receive paths Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 01/11] smb: client: fix NextCommand bounds and aliasing UAF in receive_encrypted_standard() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 02/11] smb: client: validate PDU length before smb2_get_data_area_len() struct access Frank Sorenson
2026-08-29 10:31 ` Namjae Jeon
2026-08-30 2:43 ` Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 03/11] smb: client: fix server->total_read not tracking sub-PDU size in receive_encrypted_standard() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 04/11] smb: client: fix missing lower-bound check on DFS referral string offsets Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 05/11] smb: client: fix missing lower-bound on Next field in parse_server_interfaces() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 06/11] smb: client: fix OOB struct field reads in move_smb2_ea_to_cifs() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 07/11] smb: client: fix missing iov bounds check in parse_posix_sids() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 08/11] smb: client: fix underflow in is_valid_oplock_break() notify offset check Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 09/11] smb: client: fix potential OOB read in smb3_enum_snapshots() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 10/11] smb: client: fix incomplete bounds check on reparse buffer in cifs_query_reparse_point() Frank Sorenson
2026-08-26 15:31 ` [PATCH v3 11/11] smb: client: fix NameOffset and Next field validation in smb2_parse_contexts() Frank Sorenson
2026-08-29 14:01 ` Namjae Jeon
2026-08-29 16:26 ` Frank Sorenson [this message]
2026-08-29 16:52 ` Frank Sorenson
2026-08-30 1:29 ` Namjae Jeon
2026-08-30 1:40 ` [PATCH v3 00/11] smb: client: fix OOB reads and UAFs in SMB2/3 receive paths Namjae Jeon
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=666879b8-5117-4c41-ab1d-e50637e68a5d@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 \
/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