From mboxrd@z Thu Jan 1 00:00:00 1970 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 E4BDC44D685; Thu, 30 Jul 2026 15:26:02 +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=1785425164; cv=none; b=ttxqAkd5gC6EZ7V6ru39Mll5IYd/UmjI3+aUj8sCNJ9EoXQ6uAh0eLJkCfirYawwhMTmicyE4hlFPkC75NUPumtTx0pF3N9ZlBsWGcY1lkbHYbXnsAucx/+EJK/AjtSVUO67b/DGsxccs4Kyo+5exZbSkryW7JTGlNU5MejR33k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785425164; c=relaxed/simple; bh=Z5lw7sWnvOLwH3J+DCUDRrlSYd76dlizWzXEDX29sGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YijE6HBe9breNOopK7KjGiDcJ1Vi4PzQuF4Ke+cmkjivJFRuFCrJv8t/MncWP3aqeOlogcdFgnbHI8kTWMMOQWP9SEx04jR4z4BLIjrVjAzyyxFcKcjyqa6vwqpBV5BKwGNKKD0qfk6VkxIOUJL1MdNGyhX228+dZ8RkZ8NwKnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R1JcE7sr; 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="R1JcE7sr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B91B1F000E9; Thu, 30 Jul 2026 15:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785425162; bh=fouabNf9QbAfmIiu3/WAi1OYTLvaeZFF7NxGKjOTdCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R1JcE7srZOpDJ69EXXhIyk/K6XYSjeRDHubqgW/C0du1lJDCP9a97YATsmpX1ECWP grds4USp2gq5Wi9tXBXKFTEgTNwVcxZ1blL1kXwDF2hw9/sabBCOUP9np27nojbRaU 4QksyQYUUeNFUVSfxpwSw1nXcgrra+WebSkm3xuo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, LocalHost , Namjae Jeon , Steve French , Wentao Guan , Sasha Levin Subject: [PATCH 6.18 602/675] ksmbd: validate ACE size against SID sub-authorities Date: Thu, 30 Jul 2026 16:15:32 +0200 Message-ID: <20260730141457.910698999@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon commit 5152c6d49e3fd4e9f2e857c57527aead752f1f87 upstream. set_ntacl_dacl() validates sid.num_subauth before copying an ACE, but does not verify that the declared ACE size contains all sub-authorities described by that field. An undersized ACE can therefore be copied and later make the POSIX ACL deduplication walk inspect data beyond the copied ACE boundary. The existing initial bound check is also too small. It only ensures that the ACE size field is accessible before set_ntacl_dacl() reads sid.num_subauth farther into the input buffer. Require enough input for the fixed SID header before accessing num_subauth, reject ACEs smaller than that header, and skip ACEs whose declared size cannot contain the complete SID. This makes the validation consistent with the other ACE walk paths. Reported-by: LocalHost Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Wentao Guan Signed-off-by: Sasha Levin --- fs/smb/server/smbacl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c index b0677e095c3292..d3d0a22620f96d 100644 --- a/fs/smb/server/smbacl.c +++ b/fs/smb/server/smbacl.c @@ -743,15 +743,22 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap, for (i = 0; i < nt_num_aces; i++) { unsigned short nt_ace_size; - if (offsetof(struct smb_ace, access_req) > aces_size) + if (aces_size < offsetof(struct smb_ace, sid) + + CIFS_SID_BASE_SIZE) break; nt_ace_size = le16_to_cpu(ntace->size); - if (nt_ace_size > aces_size) + if (nt_ace_size > aces_size || + nt_ace_size < offsetof(struct smb_ace, sid) + + CIFS_SID_BASE_SIZE) break; if (ntace->sid.num_subauth == 0 || - ntace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES) + ntace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES || + nt_ace_size < offsetof(struct smb_ace, sid) + + CIFS_SID_BASE_SIZE + + sizeof(__le32) * + ntace->sid.num_subauth) goto next_ace; memcpy((char *)pndace + size, ntace, nt_ace_size); -- 2.53.0