Skip to content

examples/link-cp: avoid misaligned struct io_data access#1586

Open
rootvector2 wants to merge 1 commit into
axboe:masterfrom
rootvector2:link-cp-aligned-iodata
Open

examples/link-cp: avoid misaligned struct io_data access#1586
rootvector2 wants to merge 1 commit into
axboe:masterfrom
rootvector2:link-cp-aligned-iodata

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

queue_rw_pair() places struct io_data at ptr + size, so for any block size not a multiple of 8 (the partial tail block of most copies) the io_data members are accessed through a misaligned pointer, which is undefined behavior and faults under -fsanitize=alignment. Allocate the struct first and point iov_base at data + 1, matching io_uring-cp.c; the free in handle_cqe then drops the base recomputation.

queue_rw_pair() placed struct io_data at ptr + size, so any block size
not a multiple of 8 (the partial tail block of a copy) accessed the
io_data members through a misaligned pointer, which is undefined
behavior and faults under -fsanitize=alignment. Allocate the struct
first and point iov_base at data + 1, matching io_uring-cp.c, and free
data directly.

Signed-off-by: rootvector2 <dxbnaveed.k@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant