Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C0A446C82A; Thu, 20 Aug 2026 17:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248429; cv=none; b=OzMByyp6pJx2GMfQmorj6/yH82r0VAtx7dFAAQs5OPQFVYHX18NOsVYajL5d4z1VlAzJaQl55w3WNZVEIcYmllwtP3dNL10Q8GuC3npyfowlB0sHCLWGKWwtaCElBJYaKvlOljV2TsSkqSm0i1+Wuswm5f53il2V3m7FZO4GsEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248429; c=relaxed/simple; bh=5kqXB5bmBxdynAG0GjciJ4DVh2jBqcBS9Hfkq8SS2NU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B0zZTyMu8PcDETKwOedQppgSFmD4MEqXS++g2qunXoj7c/MYyOaJIt6zkrO5VMTQYGItDyo9ZZFqAvkJj3rohZAIv+8nl3tjZqHVMbNPE3ersxX2eSH3ELcta97058JCtE6aG0VsZJZDLm3mZIYuqbKCvTUQi9CYly3anNtWRcU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qu4DVuod; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qu4DVuod" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7A2B1F000E9; Thu, 20 Aug 2026 17:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787248428; bh=DGqJn4Ir0PnPXotm0kqsHB5COlUREoOrsVng93t22zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qu4DVuodyX9MYKgH7SY6DGXvQlfRiAuLs8AvMtCfx99ysdC1jVqFtC9qVNTGGpxO2 MW/Z1XwJ6GLcQJusaV/Qs/kWurEfmEhGcHAgDKAUiKzctZ//gd0m0gVP8jkpCDovuD 1cUJRCI1ebnh0zNaG6Q6LKhOc3WhnKYLsRhhd/cI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haofeng Li , ChenXiaoSong , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.1 223/303] ksmbd: validate num_subauth when copying ACE in set_ntacl_dacl Date: Thu, 20 Aug 2026 16:55:59 +0200 Message-ID: <20260820145300.108122703@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145253.200766705@linuxfoundation.org> References: <20260820145253.200766705@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haofeng Li [ Upstream commit 47f0b34f6bc98ed85bfdc293e8f3e432ec24958d ] set_ntacl_dacl() copies each ACE from the attacker-controlled stored security descriptor verbatim into the response DACL without checking sid.num_subauth. The ACE bytes (including an unchecked num_subauth) originate from an authenticated SMB2_SET_INFO(SecInfo=DACL) that is stored raw via ksmbd_vfs_set_sd_xattr(); parse_dacl() rejects a bad ACE with `break` rather than an error, so parse_sec_desc() still returns success and the malformed SD reaches the xattr intact. On a subsequent SMB2_QUERY_INFO(SecInfo=DACL) for an inode carrying a POSIX access ACL, build_sec_desc() -> set_ntacl_dacl() -> set_posix_acl_entries_dacl() walks the copied ACEs and reads ntace->sid.sub_auth[ntace->sid.num_subauth - 1] with num_subauth taken straight from the stored SD. Since sub_auth[] is fixed at SID_MAX_SUB_AUTHORITIES (15), a crafted num_subauth (e.g. 255) drives an out-of-bounds heap read of ~1 KB with an offset fully controlled by an authenticated client. The sibling functions already gate this field: parse_dacl() -- num_subauth == 0 || > SID_MAX_SUB_AUTHORITIES parse_sid() -- num_subauth > SID_MAX_SUB_AUTHORITIES smb_copy_sid() -- min_t(u8, num_subauth, SID_MAX_SUB_AUTHORITIES) set_ntacl_dacl() is the lone inconsistent path that omits the check. Add the same num_subauth validation in set_ntacl_dacl() before copying the ACE, matching the gate already enforced by parse_dacl(). Signed-off-by: Haofeng Li Reviewed-by: ChenXiaoSong Suggested-by: Namjae Jeon Acked-by: Namjae Jeon Signed-off-by: Steve French Stable-dep-of: bbf0a8e93120 ("ksmbd: restore DACL size on check_add_overflow() to avoid malformed ACL") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/smbacl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/smb/server/smbacl.c +++ b/fs/smb/server/smbacl.c @@ -740,12 +740,18 @@ static void set_ntacl_dacl(struct user_n if (nt_ace_size > aces_size) break; + if (ntace->sid.num_subauth == 0 || + ntace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES) + goto next_ace; + memcpy((char *)pndace + size, ntace, nt_ace_size); if (check_add_overflow(size, nt_ace_size, &size)) break; + num_aces++; + +next_ace: aces_size -= nt_ace_size; ntace = (struct smb_ace *)((char *)ntace + nt_ace_size); - num_aces++; } }