-
Notifications
You must be signed in to change notification settings - Fork 1.3k
executor: determine the next free loop device #6418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
executor: determine the next free loop device #6418
Conversation
When setting up loop devices, syz_mount_image() and reset_loop() use "/dev/loop/<<procid>>" as the loop device name. The variable <<procid>> is always 0 (it is never initialized) and so the loop device is always "/dev/loop0" (see [*] for example). On many systems, "/dev/loop0" doesn't exist a priori and loop devices must be explicitly created. Fix executor/common_linux.h to do just that. I have not faced a C reproducer that included syz_read_part_table(), so the changes to that function are purely speculative. Please verify. [*] https://syzkaller.appspot.com/bug?extid=fa7122891ab9e0bbc6a7
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I have reported this problem previously; most recently here: https://groups.google.com/g/syzkaller-bugs/c/cHt6CZXzszA/m/8_ZzfdipAAAJ It seems that the people running syzbot are perfectly happy spamming people with huge amounts of bug reports, but nobody gives a damn about fixing problems with those reports. |
|
LOOP_CTL_GET_FREE looks racy, so it may have questionable effects during fuzzing. |
LOOP_CTL_GET_FREE will create a new loop device if none exist or if all the existing ones are in use. So yes, it will race with other processes that randomly open /dev/loop* devices, but no, it will not race with other processes using LOOP_CTL_GET_FREE. Note that the fuzzing happens in the filesystem that is loop mounted. Creating the loop device is just part of setting things up so that that filesystem can be mounted. |
|
https://github.com/google/syzkaller/blob/master/executor/executor_runner.h#L683-L719 isn't actually included in repro.c. |
It's not marking the loop device as bound: |
These are included here: Lines 793 to 826 in 1956824
|
Ah, right, it's still racy, and setup_loop_device() will even blindly call ioctl(loopfd, LOOP_CLR_FD, 0) on loop devices that it finds busy. That could all be fixed to make repro.c programs run correctly even when other programs are "consuming" /dev/loop* devices at the same time. The case I'm running into again and again is when /dev/loop0 doesn't exist and LOOP_CTL_GET_FREE needs to be called to create it. |
It would have to be included in repro.c. When I build and run repro.c, that code won't execute. |
C repros are minimized and can be larger or smaller (include/exclude more code). |
When setting up loop devices, syz_mount_image() and reset_loop() use "/dev/loop/<>" as the loop device name. The variable <> is always 0 (it is never initialized) and so the loop device is always "/dev/loop0" (see [*] for example).
On many systems, "/dev/loop0" doesn't exist a priori and loop devices must be explicitly created. Fix executor/common_linux.h to do just that.
I have not faced a C reproducer that included syz_read_part_table(), so the changes to that function are purely speculative. Please verify.
[*] https://syzkaller.appspot.com/bug?extid=fa7122891ab9e0bbc6a7
Before sending a pull request, please review Contribution Guidelines:
https://github.com/google/syzkaller/blob/master/docs/contributing.md