From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795051949; b=UPMHad6zFZ/aSy1yv5Y8C3Uo78KtHMlQ+fJICmFWcumTJDJo+WIkHVeAiAMUgxgwjxO/ gULwcJB1XPPQV2DRErFaqobEp6yPOcHl0E7Hk22D0aZ78WVL2jQ7XH0oSCmp8upN8iFKz lkyC1Sz5ecpUcoHPItD4+Z04RhWuh93MCrjLmbhspsfR9SjS7C/CLv/UUjTvzEFLxi4Am tvd1nX049CHyHPmFu00dZSQpBBw1SUGuorcopY3gxF624EdTpQf7qX2EPmC5MBhL6k7gJ KQ6urLNm0PP+pOGYFH9TyUeJVj0erONPTd2+UiKydDQ0AbgUR/zDsdXP3CTLVS4qWbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795051949; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=b7xIfQYVPyjlNEx8yf9hASuFBuALKaefWy7g/GG3hLI=; b=jmFH0Dlu6xxw0hpybPKjqmGTi7g/5CIRIMDgNWwjBlEW49aUTsJ3zNb6vfoXLfKCLifF 1uKflrJODlbkrVpEArZ1dPAngC0X+rYLsYC9QzhTjTDkfwUfX6cL18gp7UJwLXER311Vk dcUYCOgh0e+AU4o9so7Mba1gp0WYtzxivySPSDAR8GhQvCtxr0KcKKyDWizhFy4RBEcXq C1ajJdAQtJ1I5bVbtw5a6fmwFk75axcB2eRM0L4H0RS0J1qKz5WanBz+D5GsG4+SRuhG/ KuDaCRVLaQylD1RFw7dZE1uGR1gSAQEXH1oe0Zz390p841L0XBej4kKLjp5KX1rdgjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="Fo/rTubq"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 423DD606A332; Thu, 19 Nov 2026 01:32:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Fo/rTubq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9961D1F000C4; Thu, 19 Nov 2026 01:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795051949; bh=b7xIfQYVPyjlNEx8yf9hASuFBuALKaefWy7g/GG3hLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fo/rTubqSATvT+YR5DeIgWj7Zc8yocdrUu2B5V7EsuysX5UmHyrPyfCdXINurKygU BS4LlYyUvvWw8oc9LV9GM/dMH+v5nVlCZYiDP/DsRtDn48jIL4TxnXN4K49DnrEPoB MmaVcH5CqZpwMxG61l/sCp0qmpQVxpf9PqlrNptU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ratnaker Gautam , Namjae Jeon , Sasha Levin Subject: [PATCH 5.15 0390/2214] ksmbd: validate security descriptor offsets before pointer arithmetic Date: Wed, 18 Nov 2026 15:34:26 +0100 Message-ID: <20261118150026.272148532@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon [ Upstream commit 3474e1a304fbf9f7c996b24adcd519e031227a90 ] parse_sec_desc() constructs SID and DACL pointers by adding untrusted 32-bit offsets to the security descriptor before checking their bounds. The existing checks reject offsets into the descriptor header, but do not reject offsets beyond the descriptor's length. On a 32-bit kernel, a large offset can wrap the pointer before the descriptor. The end-only checks in parse_sid() and parse_dacl() can then accept it, allowing an authenticated SMB2 SET_INFO request to access memory outside the security descriptor and fault the kernel. Check each nonzero offset against acl_len before constructing its pointer. Initialize the optional owner and group SID pointers to NULL so an omitted SID remains absent when parsing the DACL. The 5.15 tree keeps this code in fs/ksmbd/smbacl.c and uses a void parse_dacl(). Preserve those interfaces in this backport. Fixes: 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers") Cc: stable@vger.kernel.org Reported-by: Ratnaker Gautam Signed-off-by: Namjae Jeon (cherry picked from commit 3474e1a304fbf9f7c996b24adcd519e031227a90) Signed-off-by: Ratnaker Gautam Signed-off-by: Sasha Levin --- fs/ksmbd/smbacl.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/ksmbd/smbacl.c b/fs/ksmbd/smbacl.c index 05c7682257571..515830f75b2de 100644 --- a/fs/ksmbd/smbacl.c +++ b/fs/ksmbd/smbacl.c @@ -830,7 +830,7 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, int acl_len, struct smb_fattr *fattr) { int rc = 0; - struct smb_sid *owner_sid_ptr, *group_sid_ptr; + struct smb_sid *owner_sid_ptr = NULL, *group_sid_ptr = NULL; struct smb_acl *dacl_ptr; /* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + acl_len; __u32 dacloffset; @@ -842,12 +842,7 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, if (acl_len < sizeof(struct smb_ntsd)) return -EINVAL; - owner_sid_ptr = (struct smb_sid *)((char *)pntsd + - le32_to_cpu(pntsd->osidoffset)); - group_sid_ptr = (struct smb_sid *)((char *)pntsd + - le32_to_cpu(pntsd->gsidoffset)); dacloffset = le32_to_cpu(pntsd->dacloffset); - dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset); ksmbd_debug(SMB, "revision %d type 0x%x ooffset 0x%x goffset 0x%x sacloffset 0x%x dacloffset 0x%x\n", pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), @@ -863,6 +858,12 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, pntsd->type = cpu_to_le16(DACL_PRESENT); if (pntsd->osidoffset) { + if (le32_to_cpu(pntsd->osidoffset) < sizeof(struct smb_ntsd) || + le32_to_cpu(pntsd->osidoffset) >= acl_len) + return -EINVAL; + + owner_sid_ptr = (struct smb_sid *)((char *)pntsd + + le32_to_cpu(pntsd->osidoffset)); rc = parse_sid(owner_sid_ptr, end_of_acl); if (rc) { pr_err("%s: Error %d parsing Owner SID\n", __func__, rc); @@ -878,6 +879,12 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, } if (pntsd->gsidoffset) { + if (le32_to_cpu(pntsd->gsidoffset) < sizeof(struct smb_ntsd) || + le32_to_cpu(pntsd->gsidoffset) >= acl_len) + return -EINVAL; + + group_sid_ptr = (struct smb_sid *)((char *)pntsd + + le32_to_cpu(pntsd->gsidoffset)); rc = parse_sid(group_sid_ptr, end_of_acl); if (rc) { pr_err("%s: Error %d mapping Owner SID to gid\n", @@ -899,6 +906,10 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, pntsd->type |= cpu_to_le16(DACL_PROTECTED); if (dacloffset) { + if (dacloffset < sizeof(struct smb_ntsd) || dacloffset >= acl_len) + return -EINVAL; + + dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset); parse_dacl(user_ns, dacl_ptr, end_of_acl, owner_sid_ptr, group_sid_ptr, fattr); } -- 2.53.0