diff options
| author | Albert van der Linde <alinde@google.com> | 2020-07-16 07:04:53 +0000 |
|---|---|---|
| committer | Alexander Potapenko <ramosian.glider@gmail.com> | 2020-07-20 11:30:15 +0200 |
| commit | d7a01d53f700f7e15d3691fc593938d2cbac541e (patch) | |
| tree | 1003782dba9a47198e43617a4921924837c07fc9 | |
| parent | 849706788683939cd3ace2c1537b33cc7dd38a36 (diff) | |
sys/linux: add descriptions for raw character devices
| -rw-r--r-- | pkg/host/syscalls_linux.go | 4 | ||||
| -rw-r--r-- | sys/linux/dev_char_raw.txt | 57 |
2 files changed, 61 insertions, 0 deletions
diff --git a/pkg/host/syscalls_linux.go b/pkg/host/syscalls_linux.go index 18dc81d9e..7312fb8a7 100644 --- a/pkg/host/syscalls_linux.go +++ b/pkg/host/syscalls_linux.go @@ -235,6 +235,10 @@ func isSupportedSyzOpenDev(sandbox string, c *prog.Syscall) (bool, string) { if !ok { panic("first open arg is not a pointer to string const") } + if strings.Contains(fname, "/dev/raw/raw#") { + // For syz_open_dev$char_raw, these files don't exist initially. + return true, "" + } if !strings.Contains(fname, "#") { panic(fmt.Sprintf("%v does not contain # in the file name (should be openat)", c.Name)) } diff --git a/sys/linux/dev_char_raw.txt b/sys/linux/dev_char_raw.txt new file mode 100644 index 000000000..2c9ff06b0 --- /dev/null +++ b/sys/linux/dev_char_raw.txt @@ -0,0 +1,57 @@ +# Copyright 2020 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +# drivers/char/raw.c +include <linux/raw.h> + +resource fd_char_raw[fd] +resource fd_char_raw_ctl[fd] + +openat$char_raw_ctl(fd const[AT_FDCWD], file ptr[in, string["/dev/raw/rawctl"]], flags flags[open_flags], mode const[0]) fd_char_raw_ctl +# /dev/raw/raw# only exists if ioctl$RAW_CHAR_CTRL_SETBIND executed first. +syz_open_dev$char_raw(file ptr[in, string["/dev/raw/raw#"]], raw_minor proc[1, 2], flags flags[open_flags]) fd_char_raw + +read$char_raw(fd fd_char_raw, buf ptr[out, raw_char_buffer], count len[buf]) +write$char_raw(fd fd_char_raw, buf ptr[in, raw_char_buffer], count len[buf]) + +raw_char_buffer { + buf array[int8, 1:65536] +} [align[512]] + +# IOCTL on /dev/raw/rawctl +ioctl$RAW_CHAR_CTRL_SETBIND(fd fd_char_raw_ctl, cmd const[RAW_SETBIND], arg ptr[in, raw_bind_info]) +ioctl$RAW_CHAR_CTRL_GETBIND(fd fd_char_raw_ctl, cmd const[RAW_GETBIND], arg ptr[inout, raw_bind_info]) + +# TODO: add other suitable major types +raw_bind_info { + raw_minor proc[1, 2, int32] + block_major const[LOOP_MAJOR, int64] + block_minor proc[0, 1, int64] +} + +# IOCTL on /dev/raw/rawN +# similar to dev_block.txt - redefined for fd_char_raw +include <linux/blkdev.h> +ioctl$CHAR_RAW_FLSBUF(fd fd_char_raw, cmd const[BLKFLSBUF], arg ptr[in, intptr]) +ioctl$CHAR_RAW_ROSET(fd fd_char_raw, cmd const[BLKROSET], arg ptr[in, intptr]) +ioctl$CHAR_RAW_DISCARD(fd fd_char_raw, cmd const[BLKDISCARD], arg ptr[in, intptr]) +ioctl$CHAR_RAW_SECDISCARD(fd fd_char_raw, cmd const[BLKSECDISCARD], arg ptr[in, intptr]) +ioctl$CHAR_RAW_ZEROOUT(fd fd_char_raw, cmd const[BLKZEROOUT], arg ptr[in, blk_zone_range]) +ioctl$CHAR_RAW_REPORTZONE(fd fd_char_raw, cmd const[BLKREPORTZONE], arg ptr[in, blk_zone_report]) +ioctl$CHAR_RAW_RESETZONE(fd fd_char_raw, cmd const[BLKRESETZONE], arg ptr[in, blk_zone_range]) +ioctl$CHAR_RAW_RAGET(fd fd_char_raw, cmd const[BLKRAGET], arg ptr[out, intptr]) +ioctl$CHAR_RAW_ROGET(fd fd_char_raw, cmd const[BLKROGET], arg ptr[out, intptr]) +ioctl$CHAR_RAW_BSZGET(fd fd_char_raw, cmd const[BLKBSZGET], arg ptr[out, intptr]) +ioctl$CHAR_RAW_PBSZGET(fd fd_char_raw, cmd const[BLKPBSZGET], arg ptr[out, intptr]) +ioctl$CHAR_RAW_IOMIN(fd fd_char_raw, cmd const[BLKIOMIN], arg ptr[out, intptr]) +ioctl$CHAR_RAW_IOOPT(fd fd_char_raw, cmd const[BLKIOOPT], arg ptr[out, intptr]) +ioctl$CHAR_RAW_ALIGNOFF(fd fd_char_raw, cmd const[BLKALIGNOFF], arg ptr[out, intptr]) +ioctl$CHAR_RAW_SECTGET(fd fd_char_raw, cmd const[BLKSECTGET], arg ptr[out, intptr]) +ioctl$CHAR_RAW_ROTATIONAL(fd fd_char_raw, cmd const[BLKROTATIONAL], arg ptr[out, intptr]) +ioctl$CHAR_RAW_FRASET(fd fd_char_raw, cmd const[BLKFRASET], arg ptr[in, intptr]) +ioctl$CHAR_RAW_BSZSET(fd fd_char_raw, cmd const[BLKBSZSET], arg ptr[in, intptr]) +ioctl$CHAR_RAW_PG(fd fd_char_raw, cmd const[BLKPG], arg ptr[in, blkpg_ioctl_arg]) +ioctl$CHAR_RAW_RRPART(fd fd_char_raw, cmd const[BLKRRPART], arg const[0]) +ioctl$CHAR_RAW_GETSIZE(fd fd_char_raw, cmd const[BLKGETSIZE], arg ptr[out, intptr]) +ioctl$CHAR_RAW_GETSIZE64(fd fd_char_raw, cmd const[BLKGETSIZE64], arg ptr[out, int64]) +ioctl$CHAR_RAW_HDIO_GETGEO(fd fd_char_raw, cmd const[HDIO_GETGEO], arg ptr[out, hd_geometry]) |
