From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: liuyong <pkfxxxing@gmail.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Paulo Alcantara <pc@manguebit.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y 3/3] smb: client: validate descriptor headers before query result allocation
Date: Wed, 25 Nov 2026 23:30:14 -0500 [thread overview]
Message-ID: <20261126042943.1964790-3-sashal@kernel.org> (raw)
In-Reply-To: <20261126042943.1964790-1-sashal@kernel.org>
From: liuyong <pkfxxxing@gmail.com>
[ Upstream commit ffb59029c0d52bf76fdd2678f5d6fd13e26220dd ]
query_info() uses the server's returned length instead of the caller's
minimum when a dynamic result is requested. A zero-length ACL response
can therefore return ZERO_SIZE_PTR to id_mode_to_cifs_acl(), whose
ownership-change path reads dacloffset before checking the header size.
A KASAN-enabled test shows a read at address 0x20 and a kernel Oops.
Validate the returned range and the caller's minimum before allocating
the dynamic result. Keep the reported length zero if validation fails.
Use the security descriptor header size as the minimum in SMB2_query_acl().
DACL-only and SACL-only xattr queries do not require owner and group SIDs,
so enforcing MIN_SEC_DESC_LEN would reject short descriptors that these
queries could previously return. The rewrite paths validate the required
owner/group SIDs and DACL separately before using their contents.
These issues were discovered and fixed by Qihoo 360's Tulongfeng
multi-agent system.
Fixes: 9ee2afe5207b ("cifs: prevent copying past input buffer boundaries")
Cc: stable@vger.kernel.org
Signed-off-by: liuyong <pkfxxxing@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsacl.h | 14 --------------
fs/smb/client/smb2pdu.c | 11 ++++++++++-
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/fs/smb/client/cifsacl.h b/fs/smb/client/cifsacl.h
index 31b51a8fc2561..ebc1b7c08c6ad 100644
--- a/fs/smb/client/cifsacl.h
+++ b/fs/smb/client/cifsacl.h
@@ -93,18 +93,4 @@ struct owner_group_sids {
struct owner_sid group;
} __packed;
-/*
- * Minimum security identifier can be one for system defined Users
- * and Groups such as NULL SID and World or Built-in accounts such
- * as Administrator and Guest and consists of
- * Revision + Num (Sub)Auths + Authority + Domain (one Subauthority)
- */
-#define MIN_SID_LEN (1 + 1 + 6 + 4) /* in bytes */
-
-/*
- * Minimum security descriptor can be one without any SACL and DACL and can
- * consist of revision, type, and two sids of minimum size for owner and group
- */
-#define MIN_SEC_DESC_LEN (sizeof(struct smb_ntsd) + (2 * MIN_SID_LEN))
-
#endif /* _CIFSACL_H */
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 6844bdfcc9b1b..bd61c10ec0f28 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3927,6 +3927,14 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
ses->Suid, info_class, (__u32)info_type);
if (dlen) {
+ rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
+ le32_to_cpu(rsp->OutputBufferLength),
+ &rsp_iov, min_len);
+ if (rc) {
+ *dlen = 0;
+ goto qinf_exit;
+ }
+
*dlen = le32_to_cpu(rsp->OutputBufferLength);
if (!*data) {
*data = kmalloc(*dlen, GFP_KERNEL);
@@ -3998,7 +4006,8 @@ SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
return query_info(xid, tcon, persistent_fid, volatile_fid,
0, SMB2_O_INFO_SECURITY, extra_info,
- SMB2_MAX_BUFFER_SIZE, MIN_SEC_DESC_LEN, data, plen);
+ SMB2_MAX_BUFFER_SIZE, sizeof(struct smb_ntsd),
+ data, plen);
}
int
--
2.53.0
prev parent reply other threads:[~2026-11-26 4:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:13 FAILED: patch "[PATCH] smb: client: validate descriptor headers before query result" failed to apply to 6.6-stable tree gregkh
2026-11-26 4:30 ` [PATCH 6.6.y 1/3] smb/client: Prevent error pointer dereference Sasha Levin
2026-11-26 4:30 ` [PATCH 6.6.y 2/3] cifs: Fix getting DACL-only xattr system.cifs_acl and system.smb3_acl Sasha Levin
2026-11-26 4:30 ` Sasha Levin [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=20261126042943.1964790-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=pc@manguebit.org \
--cc=pkfxxxing@gmail.com \
--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