Skip to contentSkip to conversation

ntfs3: align struct ATTR_LIST_ENTRY

PATCH In review Arnd Bergmann 2 participants 2 messages Dec 7, 2023 – Dec 8, 2023 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs3: align struct ATTR_LIST_ENTRY

From: Arnd Bergmann <[email protected]>

On architectures like i386 that don't enforce natural alignment of u64 struct members, so the recent change to remove the final 48 bits reduced the structure size from 32 to 28 bytes:

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct ATTR_LIST_ENTRY) == 0x20" fs/ntfs3/ntfs.h:530:1: note: in expansion of macro 'static_assert'

  530 | static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
      | ^~~~~~~~~~~~~

Add an alignment attribute that makes the structure the same across all architectures again.

Fixes d155617006eb ("fs/ntfs3: Fix detected field-spanning write (size 8) of single field "le->name"")
---
 fs/ntfs3/ntfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/ntfs.h +1 -1
index c8981429c721..2d409ac94cbb 100644
@@ -525,7 +525,7 @@ struct ATTR_LIST_ENTRY {
 	__le16 id;		// 0x18: struct ATTRIB ID.
 	__le16 name[];		// 0x1A: To get real name use name_off.
 
-}; // sizeof(0x20)
+} __aligned((8)); // sizeof(0x20)
 
 static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
 
Signature · 1 line
2.39.2
Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

On architectures like i386 that don't enforce natural alignment of u64 struct members, so the recent change to remove the final 48 bits reduced the structure size from 32 to 28 bytes:

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct ATTR_LIST_ENTRY) == 0x20" fs/ntfs3/ntfs.h:530:1: note: in expansion of macro 'static_assert'

Quoted 8 lines
  530 | static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
      | ^~~~~~~~~~~~~

Add an alignment attribute that makes the structure the same across all architectures again.

Fixes d155617006eb ("fs/ntfs3: Fix detected field-spanning write (size 8) of single field "le->name"")

Thanks.

Quoted 17 lines
---
 fs/ntfs3/ntfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/ntfs.h +1 -1
index c8981429c721..2d409ac94cbb 100644
@@ -525,7 +525,7 @@ struct ATTR_LIST_ENTRY {
 	__le16 id;		// 0x18: struct ATTRIB ID.
 	__le16 name[];		// 0x1A: To get real name use name_off.
 
-}; // sizeof(0x20)
+} __aligned((8)); // sizeof(0x20)
 
 static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
 
Signature · 1 line
~Randy