From: Frank Sorenson <sorenson@redhat.com>
To: Zihan Xi <zihanx@nebusec.ai>
Cc: Paulo Alcantara <pc@manguebit.org>,
Namjae Jeon <linkinjeon@kernel.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
Pavel Shilovsky <pshilovsky@samba.org>,
Aurelien Aptel <aaptel@suse.com>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] smb: client: fix create context out-of-bounds reads
Date: Fri, 11 Sep 2026 12:00:29 -0500 [thread overview]
Message-ID: <20260911170034.1236993-1-sorenson@redhat.com> (raw)
In-Reply-To: <20260904140527.62354-1-zihanx@nebusec.ai>
On Fri, Sep 04, 2026 at 02:05:17PM +0000, Zihan Xi wrote:
> smb2_parse_contexts() validates the complete create-context area but does
> not bound each context record by its Next field before dispatching to a
> handler. A malformed chain can therefore expose bytes past one context to
> the handler. The QFid handler also used a full response-structure cast even
> though it only consumes DiskFileId.
Hello,
I have some thoughts/comments on your series.
First, a possible reason for not getting a response on your v2, and
delayed response on this v3: Steve French passed away in August, so
mail addressed to him isn't reaching a maintaner, and things may
have gotten missed during transitions. You'll want to send future
versions to Paulo Alcantara <pc@manguebit.org>, with Cc to
Namjae Jeon <linkinjeon@kernel.org>
I've been carrying an overlapping patch (an earlier posting:
https://lore.kernel.org/r/20260826153147.4112943-12-sorenson@redhat.com).
in a bounds-checking series of my own. Like yours, my patch has
been addressing the memory safety problem in the three handlers
which read at fixed offsets, rather than the generic checks.
But I think yours is probably a better fix, and you've got the
PoC, so if we can perfect yours and get it in, I'll be dropping
mine in favor of this series.
A few points (take with a grain of salt):
1) The lease parser still reads at a fixed offset rather than from
DataOffset:
> case 4:
> if (!strncmp(name, SMB2_CREATE_REQUEST_LEASE, 4)) {
> - *oplock = server->ops->parse_lease_buf(cc, epoch,
> + if (cc_len >= smb2_create_lease_min_cc_len(server))
> + *oplock = server->ops->parse_lease_buf(cc, epoch,
> lease_key);
cc_len bounds the record, so the read stays in bounds. But this is
just like the QFid bug you just fixed nearby: smb2_parse_lease_buf()
and smb3_parse_lease_buf() reach the fields at the canonical offset
of the create_lease layout, not at DataOffset, so a valid but non-
canonical DataOffset could get in-bounds garbage rather than an
OOB. That's not a security fix, but since LeaseState drives client
caching decisions, it's probably worth closing. Reading lcontext
from DataOffset, as with DiskFileId would make the two handlers
consistent.
(My version also had this, so it's more an observation than anything
else)
2) You may want to consider matching DataLength exactly, rather than
taking a minimum.
ksmbd's parse_lease_state() requires:
sizeof(struct lease_context_v2) == le32_to_cpu(cc->DataLength)
and validates DataOffset + DataLength against the create_lease_v2
size, rather than accepting anything at least long enough. It was
suggested to me that having the client & server halves agree on
strictness would be good.
(I did confirm your minimums cover all the fields each of the parsers
actually touch, so this is about strictness, not a hole)
Frank
--
Frank Sorenson
sorenson@redhat.com
Principal Software Maintenance Engineer, filesystems
Red Hat
next prev parent reply other threads:[~2026-09-11 17:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 14:05 [PATCH v3 0/2] " Zihan Xi
2026-09-04 14:05 ` [PATCH v3 1/2] " Zihan Xi
2026-09-11 17:00 ` Frank Sorenson [this message]
2026-09-12 2:50 ` zihan xi
2026-09-04 14:05 ` [PATCH v3 2/2] smb: client: validate POSIX create context length Zihan Xi
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=20260911170034.1236993-1-sorenson@redhat.com \
--to=sorenson@redhat.com \
--cc=aaptel@suse.com \
--cc=bharathsm@microsoft.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=pshilovsky@samba.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=zihanx@nebusec.ai \
/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
all inboxes | Powered by JetHome®