Skip to content

Commit 52b111e

Browse files
committed
executor: disable /dev/[k]?mem access through CAP_SYS_RAWIO
Currently, syz-kconf disables CONFIG_DEVMEM and CONFIG_DEVKMEM but on some setups, these nodes might be needed by various system daemons. To allow these daemons to work while fuzzing, we need to re-enable those CONFIGs. On the other hand, we really don't want fuzzing to break the machine by accessing these nodes. Since their access is guarded by a capability, we can have syz-executor drop that capability as part of the shared "drop_caps()" logic. That capability has a slightly larger scope than guarding /dev/mem and /dev/kmem but it seems to me that the rest is all equally risky and could break the system in all sorts of unexpected way so dropping the capability seems to be the right thing to do anyway.
1 parent bf27483 commit 52b111e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

dashboard/config/linux/bits/base.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,6 @@ config:
190190
# We use GVNIC on Google Cloud.
191191
- GVE: [-arm, -riscv, -s390, -timeouts_emu]
192192

193-
# If syzkaller gets to /dev/{mem,kmem,ioport}, it will destroy the machine.
194-
# It managed to do so with some mount's, chdir's and bogus file names.
195-
# These are not needed for fuzzing, so completely disabling them is
196-
# the simplest and the most reliable option.
197-
- DEVMEM: n
198-
- DEVKMEM: n
199-
- DEVPORT: n
200-
201193
# Disable magic SysRq completely, as it can be reached over USB and through tty.
202194
- MAGIC_SYSRQ: n
203195
# We don't need it and it enables MAGIC_SYSRQ and KPROBES.

executor/common_linux.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4166,7 +4166,12 @@ static void drop_caps(void)
41664166
// which could be used to enfore safe limits without droppping CAP_SYS_NICE, but we don't have it yet.
41674167
// See the following bug for details:
41684168
// https://groups.google.com/forum/#!topic/syzkaller-bugs/G6Wl_PKPIWI
4169-
const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE);
4169+
//
4170+
// CAP_SYS_RAWIO gives direct access to various low level interfaces
4171+
// like iopl, ioperm, /proc/kcore, FIBMAP, MSRs, mmap_min_addr, pci,
4172+
// /dev/mem, /dev/kmem, low level SCSI operations, or various other
4173+
// interfaces that can directly corrupt low level kernel states.
4174+
const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE) | (1 << CAP_SYS_RAWIO);
41704175
cap_data[0].effective &= ~drop;
41714176
cap_data[0].permitted &= ~drop;
41724177
cap_data[0].inheritable &= ~drop;

0 commit comments

Comments
 (0)