From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com [35.162.73.231]) (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 8276E36B043 for ; Thu, 30 Apr 2026 08:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.162.73.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777539174; cv=none; b=o2AenrU3lF/Pi3mHkvIJEfIENMROenRYuXTFVNLdq+z9sL00j1BwtK3RT7u1O/38bOf9IyQFwbCo1pqatN8LPrT/lpoipssoXiHDEkG0vCZXsNCVXRyhSBTqgWklStoEBiHDI9COLyd/A2Oa7bxOFXkXTQD8vCzGwBW1zqfzOag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777539174; c=relaxed/simple; bh=M62EI5Mu5WxwDQuwYxcl9pu3zFbB4oajFWySVOikOwY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=PiXDoD9QVDw9NxG459pjThuGWMBuJRYdeFi/L3wTvGs5t6acUbCCL9OKBBLblyPJijtdqyIEMh9Qs/OR8+uWchUmEzONWb+7wqXs0kp8EzMF3SOYzPjYK80u2zgbpKcdjh9MwmRzChrlo28U94aJVLmKkU2YH+jRIy/gpp4UvrU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=CmuUr5qf; arc=none smtp.client-ip=35.162.73.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="CmuUr5qf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1777539173; x=1809075173; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GDI1eH8kw9PQ5e3/aO/48yjtkGcQsC1i9WD6WyAITMg=; b=CmuUr5qfP9r3mDKF3v+aTZmcfXrLNiaP/Lvn8L9zyp42KWpv2rGCn6D5 WKkdFQq0NdUlnjQt8irdPhh8b3IvqegUKNr/Uw09DaQFxUu0ZJUzFccGI AdMxe/Gh3VmNlLbdv6vM1av/rBQXeM88m3nxvrnoKZXc0EvOkcDJMlJjw YMmug74YdwjwZVfT+/PBuEa63IYSo1H3hQXfLzvaQB8ZQfPHhz/xtxbh0 Z1mq05v/DAIm/Z/5PnEQmxn59giPR3gxGBlGbvGIUor/91Bl/Qy9qZ12t buQGMsx+TukWanQT231UfJtL6p+6EEeZpy+OcV+83UJnCIeWwrdGaK6De w==; X-CSE-ConnectionGUID: Zxb30sHcSLK9PoGWVFu8MQ== X-CSE-MsgGUID: OP9njLT1TY6fJ5YivpoyjQ== X-IronPort-AV: E=Sophos;i="6.23,207,1770595200"; d="scan'208";a="18349848" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 08:52:48 +0000 Received: from EX19MTAUWA002.ant.amazon.com [205.251.233.234:17214] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.8.77:2525] with esmtp (Farcaster) id c1b1f43f-57ce-491c-9786-4ab49d329f3b; Thu, 30 Apr 2026 08:52:48 +0000 (UTC) X-Farcaster-Flow-ID: c1b1f43f-57ce-491c-9786-4ab49d329f3b Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 30 Apr 2026 08:52:47 +0000 Received: from dev-dsk-doebel-1a-7b355d76.us-east-1.amazon.com (10.169.119.5) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 30 Apr 2026 08:52:47 +0000 From: Bjoern Doebel To: CC: Bjoern Doebel , Subject: [PATCH] smb: client: use kzalloc to zero-initialize security descriptor buffer Date: Thu, 30 Apr 2026 08:52:28 +0000 Message-ID: <20260430085232.1213357-1-doebel@amazon.de> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D041UWB003.ant.amazon.com (10.13.139.176) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Commit 62e7dd0a39c2d ("smb: common: change the data type of num_aces to le16") split struct smb_acl's __le32 num_aces field into __le16 num_aces and __le16 reserved. The reserved field corresponds to Sbz2 in the MS-DTYP ACL wire format, which must be zero [1]. When building an ACL descriptor in build_sec_desc(), we are using a kmalloc()'ed descriptor buffer and writing the fields explicitly using le16() writes now. This never writes to the 2 byte reserved field, leaving it as uninitialized heap data. When the reserved field happens to contain non-zero slab garbage, Samba rejects the security descriptor with "ndr_pull_security_descriptor failed: Range Error", causing chmod to fail with EINVAL. Change kmalloc() to kzalloc() to ensure the entire buffer is zero-initialized. Fixes: 62e7dd0a39c2d ("smb: common: change the data type of num_aces to le16") Cc: stable@vger.kernel.org Signed-off-by: Bjoern Doebel Assisted-by: Kiro:claude-opus-4.6 [1] https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/20233ed8-a6c6-4097-aafa-dd545ed24428 --- fs/smb/client/cifsacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index ec5d477793040..a2750f1e3d90b 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -1732,7 +1732,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, * descriptor parameters, and security descriptor itself */ nsecdesclen = max_t(u32, nsecdesclen, DEFAULT_SEC_DESC_LEN); - pnntsd = kmalloc(nsecdesclen, GFP_KERNEL); + pnntsd = kzalloc(nsecdesclen, GFP_KERNEL); if (!pnntsd) { kfree(pntsd); cifs_put_tlink(tlink); -- 2.48.2 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597