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 687A93093C6; Sat, 30 May 2026 16:38:20 +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=1780159101; cv=none; b=LYl40fwrE/P7/gH/gNSyzl6oYRsufXbyb7Ugplp7RvwP31H+hs+Ra8dZpizk1BG/PwfQrC6OBLjpo7z9RByrjOTvpoO22oIs07gX7RLIZ3Ust7I4qEx57cK7rEAwW2bTr/0bo0H5ejZuecWjdpawsY9H9BJK9+PiGgjHaC0wFBE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780159101; c=relaxed/simple; bh=Z57CO0rU9J6pOGhPuhoEdc9Wo3nK54lZxws/sj5zzbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uaDZiJTruLWCF2B8VKff15XacsNGl4nt+h/fwo461hqysOapLmM5/H1rZTP/nwd307CONq+p2u+I/pZYh5Sk6IcB6dT8xrE7/kVQdaBntU3MZSny99BHfhvifUi8cHnQIjQR463lgko5HCryP2aSVkL7UQTWPTq7QszVpf/u1v4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PobORPan; 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="PobORPan" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 569F41F00893; Sat, 30 May 2026 16:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780159100; bh=h6o6/PPCRJo1sQvwIGZwwA2afMLnMy5DVjf2xgGTubw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PobORPanclcMS5yiD8ufjjtig4JJ3hHeEBdcV5GH3ENYFbU1/9UqCU43Odv0UjlHR YqNAAerW89Fwo/khijs+rYSEa1fFwajv2dAdprhsYMNOyx8DJizdZ1m1yZaM4nuCdq iIXrkXcyZw9Bg3aKARPerjUgLS54ngIOZgeuJsDM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey , linux-cifs@vger.kernel.org, stable@kernel.org, Steve French Subject: [PATCH 6.1 071/969] ksmbd: require 3 sub-authorities before reading sub_auth[2] Date: Sat, 30 May 2026 17:53:15 +0200 Message-ID: <20260530160302.327288399@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org 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: Greg Kroah-Hartman commit 53370cf9090777774e07fd9a8ebce67c6cc333ab upstream. parse_dacl() compares each ACE SID against sid_unix_NFS_mode and on match reads sid.sub_auth[2] as the file mode. If sid_unix_NFS_mode is the prefix S-1-5-88-3 with num_subauth = 2 then compare_sids() compares only min(num_subauth, 2) sub-authorities so a client SID with num_subauth = 2 and sub_auth = {88, 3} will match. If num_subauth = 2 and the ACE is placed at the very end of the security descriptor, sub_auth[2] will be 4 bytes past end_of_acl. The out-of-band bytes will then be masked to the low 9 bits and applied as the file's POSIX mode, probably not something that is good to have happen. Fix this up by forcing the SID to actually carry a third sub-authority before reading it at all. Cc: Namjae Jeon Cc: Steve French Cc: Sergey Senozhatsky Cc: Tom Talpey Cc: linux-cifs@vger.kernel.org Cc: Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/smbacl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/smb/server/smbacl.c +++ b/fs/smb/server/smbacl.c @@ -451,7 +451,8 @@ static void parse_dacl(struct user_names ppace[i]->access_req = smb_map_generic_desired_access(ppace[i]->access_req); - if (!(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) { + if (ppace[i]->sid.num_subauth >= 3 && + !(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) { fattr->cf_mode = le32_to_cpu(ppace[i]->sid.sub_auth[2]); break;