Skip to content

Commit f9865f5

Browse files
committed
smb: smb2pdu.h: Use static_assert() to check struct sizes
JIRA: https://issues.redhat.com/browse/RHEL-57983 commit 5b4f3af Author: Gustavo A. R. Silva <gustavoars@kernel.org> Date: Thu Aug 8 16:04:04 2024 -0600 smb: smb2pdu.h: Use static_assert() to check struct sizes Commit 9f9bef9 ("smb: smb2pdu.h: Avoid -Wflex-array-member-not-at-end warnings") introduced tagged `struct create_context_hdr`. We want to ensure that when new members need to be added to the flexible structure, they are always included within this tagged struct. So, we use `static_assert()` to ensure that the memory layout for both the flexible structure and the tagged struct is the same after any changes. Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent 59bd52e commit f9865f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/smb/common/smb2pdu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,8 @@ struct create_context {
11781178
);
11791179
__u8 Buffer[];
11801180
} __packed;
1181+
static_assert(offsetof(struct create_context, Buffer) == sizeof(struct create_context_hdr),
1182+
"struct member likely outside of __struct_group()");
11811183

11821184
struct smb2_create_req {
11831185
struct smb2_hdr hdr;

0 commit comments

Comments
 (0)