aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux/init.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-09-13 12:00:58 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-09-13 12:02:45 +0200
commit61ed43a86a3721708aeeee72b23bfa1eacd921b2 (patch)
tree1eed00dae3f4e2881650f53f34362b33960a0caf /sys/linux/init.go
parent0e29942f77715486995d996f80f82742812d75a2 (diff)
sys/linux: prohibit EXT4_IOC_SHUTDOWN
EXT4_IOC_SHUTDOWN EXT4_IOC_SHUTDOWN on root fs effectively brings the machine down in weird ways.
Diffstat (limited to 'sys/linux/init.go')
-rw-r--r--sys/linux/init.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/linux/init.go b/sys/linux/init.go
index 1400ce182..d4ab7da70 100644
--- a/sys/linux/init.go
+++ b/sys/linux/init.go
@@ -19,6 +19,8 @@ func InitTarget(target *prog.Target) {
SYSLOG_ACTION_SIZE_UNREAD: target.ConstMap["SYSLOG_ACTION_SIZE_UNREAD"],
FIFREEZE: target.ConstMap["FIFREEZE"],
FITHAW: target.ConstMap["FITHAW"],
+ EXT4_IOC_SHUTDOWN: target.ConstMap["EXT4_IOC_SHUTDOWN"],
+ EXT4_IOC_MIGRATE: target.ConstMap["EXT4_IOC_MIGRATE"],
PTRACE_TRACEME: target.ConstMap["PTRACE_TRACEME"],
CLOCK_REALTIME: target.ConstMap["CLOCK_REALTIME"],
ARCH_SET_FS: target.ConstMap["ARCH_SET_FS"],
@@ -91,6 +93,8 @@ type arch struct {
SYSLOG_ACTION_SIZE_UNREAD uint64
FIFREEZE uint64
FITHAW uint64
+ EXT4_IOC_SHUTDOWN uint64
+ EXT4_IOC_MIGRATE uint64
PTRACE_TRACEME uint64
CLOCK_REALTIME uint64
ARCH_SET_FS uint64
@@ -115,9 +119,15 @@ func (arch *arch) sanitizeCall(c *prog.Call) {
// Freeze kills machine. Though, it is an interesting functions,
// so we need to test it somehow.
// TODO: not required if executor drops privileges.
+ // Fortunately, the value does not conflict with any other ioctl commands for now.
if uint64(uint32(cmd.Val)) == arch.FIFREEZE {
cmd.Val = arch.FITHAW
}
+ // EXT4_IOC_SHUTDOWN on root fs effectively brings the machine down in weird ways.
+ // Fortunately, the value does not conflict with any other ioctl commands for now.
+ if uint64(uint32(cmd.Val)) == arch.EXT4_IOC_SHUTDOWN {
+ cmd.Val = arch.EXT4_IOC_MIGRATE
+ }
case "ptrace":
req := c.Args[0].(*prog.ConstArg)
// PTRACE_TRACEME leads to unkillable processes, see: