From nobody Sat Dec 27 09:02:11 2025 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 7EEB06D1B7; Thu, 21 Dec 2023 11:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="MmYKJO5n" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id CDA5F1FE6; Thu, 21 Dec 2023 11:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1703158148; bh=9Rn38mgkFfB/RmjsOLlzz6Pr1cAzEiI3A/7HJSLrTXg=; h=Date:To:CC:From:Subject; b=MmYKJO5nSAAVUQ3QGg7PtxmCHKfpDJNtV2ESHoHQ2fHOKCXzWBM08NKVN5A4QQAR4 E3Oyld0TAbtuX3195bdFkV/6s7gdBOQHomwRk0DdiNCoLhECj23PY/8X/XYYZlHE2G Od9T6ej3Swumr15SZcaOi0qKZJT0GjEanQ/UMkMw= Received: from [172.16.192.129] (192.168.211.178) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Thu, 21 Dec 2023 14:35:39 +0300 Message-ID: <894db108-509b-4026-a90e-666a759a3f9f@paragon-software.com> Date: Thu, 21 Dec 2023 14:35:39 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: CC: , From: Konstantin Komarov Subject: [PATCH] fs/ntfs3: Disable ATTR_LIST_ENTRY size check Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) The use of sizeof(struct ATTR_LIST_ENTRY) has been replaced with le_size(0) due to alignment peculiarities on different platforms. Reported-by: kernel test robot Closes:=20 https://lore.kernel.org/oe-kbuild-all/202312071005.g6YrbaIe-lkp@intel.com/ Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrlist.c | 8 ++++---- =C2=A0fs/ntfs3/ntfs.h=C2=A0=C2=A0=C2=A0=C2=A0 | 2 -- =C2=A02 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c index 7c01735d1219..48e7da47c6b7 100644 --- a/fs/ntfs3/attrlist.c +++ b/fs/ntfs3/attrlist.c @@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct=20 ntfs_inode *ni, =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 size_t off; =C2=A0=C2=A0=C2=A0=C2=A0 u16 sz; +=C2=A0=C2=A0=C2=A0 const unsigned le_min_size =3D le_size(0); =C2=A0=C2=A0=C2=A0=C2=A0 if (!le) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le =3D ni->attr_list.le; =C2=A0=C2=A0=C2=A0=C2=A0 } else { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sz =3D le16_to_cpu(le->size); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (sz < sizeof(struct ATTR_LIST_ENT= RY)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (sz < le_min_size) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Impossib= le 'cause we should not return such le. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } @@ -141,7 +142,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct=20 ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 /* Check boundary. */ =C2=A0=C2=A0=C2=A0=C2=A0 off =3D PtrOffset(ni->attr_list.le, le); -=C2=A0=C2=A0=C2=A0 if (off + sizeof(struct ATTR_LIST_ENTRY) > ni->attr_lis= t.size) { +=C2=A0=C2=A0=C2=A0 if (off + le_min_size > ni->attr_list.size) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* The regular end of list. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -149,8 +150,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct=20 ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 sz =3D le16_to_cpu(le->size); =C2=A0=C2=A0=C2=A0=C2=A0 /* Check le for errors. */ -=C2=A0=C2=A0=C2=A0 if (sz < sizeof(struct ATTR_LIST_ENTRY) || -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 off + sz > ni->attr_list.size || +=C2=A0=C2=A0=C2=A0 if (sz < le_min_size || off + sz > ni->attr_list.size || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sz < le->name_off + le->name_l= en * sizeof(short)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index c8981429c721..9c7478150a03 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -527,8 +527,6 @@ struct ATTR_LIST_ENTRY { =C2=A0}; // sizeof(0x20) -static_assert(sizeof(struct ATTR_LIST_ENTRY) =3D=3D 0x20); - =C2=A0static inline u32 le_size(u8 name_len) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 return ALIGN(offsetof(struct ATTR_LIST_ENTRY, nam= e) + --=20 2.34.1