Skip to content

io_uring: don't segfault if pi_chk isn't specified - #2030

Merged
axboe merged 1 commit into
axboe:masterfrom
calebsander:fix/prchk-segfault
Dec 16, 2025
Merged

axboe merged 1 commit into
axboe:masterfrom
calebsander:fix/prchk-segfault

Conversation

@calebsander

Copy link
Copy Markdown
Contributor

If fio is run with md_per_io_size but no pi_chk argument, fio_ioring_io_u_init() passes NULL to strstr(), which segfaults. Use the struct ioring_options prchk flags instead, which have already been parsed from pi_chk in parse_prchk_flags().

If fio is run with md_per_io_size but no pi_chk argument,
fio_ioring_io_u_init() passes NULL to strstr(), which segfaults. Use the
struct ioring_options prchk flags instead, which have already been
parsed from pi_chk in parse_prchk_flags().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
@vincentkfu

Copy link
Copy Markdown
Collaborator

Can you share the job that triggers this issue?

I think the change is good, actually, but am having trouble understanding how the issue occurs.

parse_prchk_flags() relies on pi_chk being non-NULL in order to set bits in prchk. If checking pi_chk fails in fio_ioring_io_u_init() how could it have succeeded in parse_prchk_flags()?

It might be reasonable also to just change the default for pi_chk to an empty string.

@calebsander

Copy link
Copy Markdown
Contributor Author

The segfault can be reproduced with --ioengine io_uring and --md_per_io_size but no --pi_chk:

$ fio --name md --ioengine io_uring --md_per_io_size 1024 --filename /dev/nvme*n*
md: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=io_uring, iodepth=1
fio-3.41
Starting 1 process
fio: pid=138727, got signal=11


Run status group 0 (all jobs):

Disk stats (read/write):
  ublkb0: ios=0/0, sectors=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%
free(): double free detected in tcache 2
Aborted (core dumped)

parse_prchk_flags() relies on pi_chk being non-NULL in order to set bits in prchk. If checking pi_chk fails in fio_ioring_io_u_init() how could it have succeeded in parse_prchk_flags()?

I'm not sure what you mean. parse_prchk_flags() always succeeds, there is no failure case. If pi_chk is omitted (!o->pi_chk), o->prchk will just stay as 0.

@vincentkfu

Copy link
Copy Markdown
Collaborator

Ok I see now. Thanks for the fix. I could not trigger the issue with io_uring_cmd but it does appear with io_uring.

@axboe
axboe merged commit 3a4c1dd into axboe:master Dec 16, 2025
14 of 17 checks passed
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.

3 participants

⌂ 换网址