Skip to contentSkip to conversation

ntfs: avoid unnecessary padding in uapi structure

PATCH Applied Arnd Bergmann 3 participants 3 messages Oct 13 – Oct 14 NTFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs: avoid unnecessary padding in uapi structure

From: Arnd Bergmann <[email protected]>

Building the uapi headers with -Wpadded shows a warning that may indicate an incompatibility:

./usr/include/linux/ntfs.h:91:1: error: padding struct size to alignment boundary with 4 bytes [-Werror=padded]

This is relatively harmless here as the 64-bit members force natural alignment, so this is not a problem for compat ioctls, and I checked that the padding word is still initialized by means of using kvzalloc() to allocate it, but it's better to avoid the padding out of principle.

Change the reserved member to use a 64-bit type so the name field starts after the structure and all padding is explicit.

---
 include/uapi/linux/ntfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/ntfs.h +1 -1
index f5b3d4997a56..89467ba07262 100644
@@ -86,7 +86,7 @@ struct ntfs_stream_entry {
 	__aligned_u64 alloc_size;
 	__u32 name_len;
 	__u32 name_offset;
-	__u32 reserved;
+	__aligned_u64 reserved;
 	__u8 name[];
 };
 
Signature · 1 line
2.53.0
Reviewed-by Baolin Liu on v1 1/1
#1 lore raw
Quoted 26 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building the uapi headers with -Wpadded shows a warning that may indicate an incompatibility:

./usr/include/linux/ntfs.h:91:1: error: padding struct size to alignment boundary with 4 bytes [-Werror=padded]

This is relatively harmless here as the 64-bit members force natural alignment, so this is not a problem for compat ioctls, and I checked that the padding word is still initialized by means of using kvzalloc() to allocate it, but it's better to avoid the padding out of principle.

Change the reserved member to use a 64-bit type so the name field starts after the structure and all padding is explicit.

---
  include/uapi/linux/ntfs.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/ntfs.h +0 -0
index f5b3d4997a56..89467ba07262 100644

include/uapi/linux/ntfs.h struct ntfs_stream_entry { · line 92

Quoted 8 lines
include/uapi/linux/ntfs.h +1 -1
@@ -86,7 +86,7 @@ struct ntfs_stream_entry {
  	__aligned_u64 alloc_size;
  	__u32 name_len;
  	__u32 name_offset;
-	__u32 reserved;
+	__aligned_u64 reserved;
  	__u8 name[];
  };
 

Looks good to me.

maintainer Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building the uapi headers with -Wpadded shows a warning that may indicate an incompatibility:

./usr/include/linux/ntfs.h:91:1: error: padding struct size to alignment boundary with 4 bytes [-Werror=padded]

This is relatively harmless here as the 64-bit members force natural alignment, so this is not a problem for compat ioctls, and I checked that the padding word is still initialized by means of using kvzalloc() to allocate it, but it's better to avoid the padding out of principle.

Quoted 4 lines

Change the reserved member to use a 64-bit type so the name field starts after the structure and all padding is explicit.

Applied it to #ntfs-next.
Thanks!