Commit 4fabc831 authored by Marcin Spiewak's avatar Marcin Spiewak Committed by Tomasz Zawadzki
Browse files

sock/uring: make 'buf' 8-byte aligned



In spdk_uring_sock structure, a padding is needed to keep
'buf' aligned to 8-bytes. 'struct cmsghdr' is mapped
to this buffer in uring_sock_group_impl_add_sock() function,
and while first element of this control message header
has a size of 8 bytes, the whole structure must be
8-byte aligned, otherwise UBSAN will generate
runtime error.

This patch is part of the fix for github issue 3090.

Change-Id: I4f0b99b4cec23f541024f2d4bbcc2ab49db6ed05
Signed-off-by: default avatarMarcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22741


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent 6e4e6cb3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -87,9 +87,16 @@ struct spdk_uring_sock {
	int					zcopy_send_flags;
	int					connection_status;
	int					placement_id;
	uint8_t                                 reserved[4];
	uint8_t					buf[SPDK_SOCK_CMG_INFO_SIZE];
	TAILQ_ENTRY(spdk_uring_sock)		link;
};
/* 'struct cmsghdr' is mapped to the buffer 'buf', and while first element
 * of this control message header has a size of 8 bytes, 'buf'
 * must be 8-byte aligned.
 */
SPDK_STATIC_ASSERT(offsetof(struct spdk_uring_sock, buf) % 8 == 0,
		   "Incorrect alignment: `buf` must be aligned to 8 bytes");

TAILQ_HEAD(pending_recv_list, spdk_uring_sock);