From: Ian Bridges <icb@fastmail.org>
To: linkinjeon@kernel.org
Cc: senozhatsky@chromium.org, tom@talpey.com,
chenxiaosong@chenxiaosong.com, manizada@pm.me,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Ian Bridges <icb@fastmail.org>,
stable@vger.kernel.org
Subject: [PATCH] ksmbd: allocate the security descriptor reply at its padded size
Date: Wed, 18 Nov 2026 11:34:54 -0600 [thread overview]
Message-ID: <20261118173454.76416-1-icb@fastmail.org> (raw)
smb2_get_info_sec() allocates the security descriptor reply with the
size that smb_acl_sec_desc_scratch_len() estimates. A compound response
pads the reply to 8 bytes inside that buffer, so after build_sec_desc()
the query fails with -EFBIG when the padded length does not fit. The
estimate is not padded, so a descriptor that fits the estimate can
still fail. A query with AdditionalInformation 0 always fails with
-EFBIG. Its reply is the 20-byte header, the estimate is 20 bytes, and
the padded length is 24. The client gets an error instead of the
header.
Round the allocation up to 8 bytes, as READ does for its data buffer.
Fixes: fda9522ed6af ("ksmbd: fix OOB write in QUERY_INFO for compound requests")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
---
The size check after build_sec_desc() is kept. It still makes sure the
descriptor and its padding fit in the buffer.
Tested on ksmbd-for-next 267029b35ad1 with KASAN. A query with
AdditionalInformation 0 now returns the 20-byte header, both alone and
in the middle of a compound. Replies for the other tested
AdditionalInformation values are unchanged. smbtorture results match
the base.
This patch was developed with LLM assistance.
fs/smb/server/smb2pdu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 29750970f8da..84f840f51297 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8510,11 +8510,13 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
scratch_len = smb_acl_sec_desc_scratch_len(&fattr, ppntsd,
ppntsd_size, addition_info);
- if (!scratch_len || scratch_len == SIZE_MAX) {
+ if (!scratch_len || scratch_len > SIZE_MAX - 7) {
rc = -EFBIG;
goto release_acl;
}
+ /* A compound response pads the descriptor to 8 bytes in this buffer */
+ scratch_len = ALIGN(scratch_len, 8);
pntsd = kvzalloc(scratch_len, KSMBD_DEFAULT_GFP);
if (!pntsd) {
rc = -ENOMEM;
--
2.47.3
reply other threads:[~2026-11-18 17:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261118173454.76416-1-icb@fastmail.org \
--to=icb@fastmail.org \
--cc=chenxiaosong@chenxiaosong.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manizada@pm.me \
--cc=senozhatsky@chromium.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 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®