Skip to content
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

vm/adb: a more reliable way to delete broken symlinks #4372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
vm/adb: a more reliable way to delete broken symlinks
When fuzzing Android, the executor sometimes leaves broken symlinks that
point to non-existent directories. The command that adb.go was using to
delete the leftover symlinks:
  `find /data/syzkaller* -type l -exec unlink {} \;`
actually choked on such files and led to syzkaller rebooting the device
indefinitely.
Parse the output of `find /data/syzkaller*` to obtain the list of broken
symlinks and pass them to `unlink` one by one.

Fixes #2831.
  • Loading branch information
ramosian-glider committed Dec 1, 2023
commit 78b0f6ecefc92c7b20bd57dd80d1c19160cb19e1
7 changes: 5 additions & 2 deletions vm/adb/adb.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
// Remove temp files from previous runs.
// rm chokes on bad symlinks so we must remove them first
if _, err := inst.adb("shell", "ls /data/syzkaller*"); err == nil {
if _, err := inst.adb("shell", "find /data/syzkaller* -type l -exec unlink {} \\;"+
" && rm -Rf /data/syzkaller*"); err != nil {
if _, err := inst.adb("shell", "find /data/syzkaller* 2>&1 | grep 'No such file' "+
"| sed 's/.*\\/data/\\/data/;s/:.*//' | xargs -r unlink"); err != nil {
return nil, err
}
if _, err := inst.adb("shell", "rm -Rf /data/syzkaller*"); err != nil {
return nil, err
}
}
Expand Down
Loading