Skip to content

sys/linux: add syzkaller defintions to fuzz ublk driver#7039

Open
tejavojjala wants to merge 12 commits intogoogle:masterfrom
tejavojjala:google-ublk
Open

sys/linux: add syzkaller defintions to fuzz ublk driver#7039
tejavojjala wants to merge 12 commits intogoogle:masterfrom
tejavojjala:google-ublk

Conversation

@tejavojjala
Copy link
Copy Markdown

@tejavojjala tejavojjala commented Apr 2, 2026

No description provided.

@tejavojjala tejavojjala marked this pull request as ready for review April 2, 2026 18:56
@tejavojjala tejavojjala force-pushed the google-ublk branch 5 times, most recently from 8f35a37 to a6e1b67 Compare April 3, 2026 09:02
Comment thread executor/common_linux.h Outdated
Comment thread executor/common_linux.h Outdated
Comment thread pkg/vminfo/linux_syscalls.go Outdated
Comment thread executor/common_linux.h

#if SYZ_EXECUTOR || __NR_syz_ublk_setup_io_uring || __NR_syz_ublk_setup_queues

static long syz_ublk_setup_io_uring(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this one could also be a syzlang description? Compared to other new pseudo syscalls, syz_ublk_setup_io_uring seems to do little on top of the already existing syz_io_uring_setup.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't get what you mean by that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that syz_ublk_setup_io_uring is just too simple to warrant a pseudo syscall - it only sets a few flags and calls syz_io_uring_setup.

But it seems that there's no easy way to enforce certain flags in syzlang, so let it be as is for now.

Comment thread sys/linux/ublk.txt.const Outdated
Comment thread executor/common_linux.h
@tejavojjala tejavojjala force-pushed the google-ublk branch 3 times, most recently from 1d16e62 to 0986cc0 Compare April 10, 2026 01:54
@pimyn-girgis
Copy link
Copy Markdown
Collaborator

@tejavojjala I don't believe you're in the contributors file, please sign the Google CLA if you haven't already, and add your name to the file as a first commit
https://github.com/google/syzkaller?tab=contributing-ov-file

@tejavojjala
Copy link
Copy Markdown
Author

@tejavojjala I don't believe you're in the contributors file, please sign the Google CLA if you haven't already, and add your name to the file as a first commit https://github.com/google/syzkaller?tab=contributing-ov-file

Missed it. Done.

@tejavojjala tejavojjala force-pushed the google-ublk branch 2 times, most recently from ca02db5 to df84d10 Compare April 13, 2026 18:39
Comment thread pkg/vminfo/linux_syscalls.go
@tejavojjala tejavojjala requested a review from a-nogikh April 14, 2026 15:06
@a-nogikh
Copy link
Copy Markdown
Collaborator

@tejavojjala
Copy link
Copy Markdown
Author

Please note this CI check failure:

https://github.com/google/syzkaller/actions/runs/24360466136/job/71226046590?pr=7039

Yeah, it is failing on presubmit_old. It couldn't find the kernel header linux/ublk_cmd.h in older versions I believe.

The only way I could think of to fix this is to copy the struct definitions I need into executor/common_linux.h. Is there a better alternative to fix this?

@a-nogikh
Copy link
Copy Markdown
Collaborator

Oh, interesting.

AFAIK so far we've just copy-pasted the structures / consts to common_linux.h in such cases, which is kind of sad as the file is already huge. On the other hand, it's the only way to make sure that a syzkaller built in an older environment can still fuzz latest kernels.

Just in case: @dvyukov do you see any simpler workarounds here?

@dvyukov
Copy link
Copy Markdown
Collaborator

dvyukov commented Apr 20, 2026

Just in case: @dvyukov do you see any simpler workarounds here?

There are no simpler workarounds for this on Linux. The Linux kernel also copies all definitions for unit tests.

@tejavojjala
Copy link
Copy Markdown
Author

Just in case: @dvyukov do you see any simpler workarounds here?

There are no simpler workarounds for this on Linux. The Linux kernel also copies all definitions for unit tests.

Thanks, copied the required definitions.

@a-nogikh
Copy link
Copy Markdown
Collaborator

https://github.com/google/syzkaller/actions/runs/24686410856/job/72197305890?pr=7039

ci / old still fails, though now with different errors.

Teja Vojjala added 12 commits April 20, 2026 20:40
The existing io_uring_sqe type only 64 bytes of data.
For ioring_op_uring_cmds, 128 bytes are used to support 80 bytes
of uring cmd data
ublk needs IORING_SETUP_SQE128 | IORING_SETUP_CQE32 to work
Without this, the cmds would just fail and fuzzer wastes time
All ublk ctrl commands operate on a particular device.
Instead of submitting control commands with random device ids
using syz_io_uring_submit, its better to record the ublk dev id
as a resource using a custom syzcall.

This also lets us capture the fuzzer generated dev info which we
can use in subsequent syzcalls
I added customer syzcalls to initialize queues and process IO on it

The queue initialization complex is pretty complex and it would be
very hard for the fuzzer to get it right due to the mmap setup and
submitting and SQE with appropriate details for every slot in queue
to indicate ublk readiness of the queue

Also, we need to provide a custom syscall to process io on queue.
Once cqe is advanced, we need to send a response back to make progress
It can be hard for fuzzer to figure out the flow by itself
@tejavojjala
Copy link
Copy Markdown
Author

https://github.com/google/syzkaller/actions/runs/24686410856/job/72197305890?pr=7039
ci / old still fails, though now with different errors.

I am not sure why. When i run syz-env make presubmit_old locally, it does succeed. Taking a look

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.

4 participants