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

Add static analysis to CI to determine redundant seccomp rules #4924

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove some redundant seccomp entries from allow lists
These have been determined by static analysis of a Firecracker binary
(see also follow up commits): The removed seccomp rules here trigger
syscalls that are either not present at all in the entire Firecracker
binary, or are not reachable from the entry point of a specific
Firecracker thread (this analysis has only been done for the vcpu thread
for now, due to being fairly tricky).

Some explanations for why some of these entries are no longer needed can
be found below

- The `uname` syscall was used back when we supported 4.14, to query the
  host kernel version and disable specific Firecracker features that
  were not supported pre-5.10 (io_uring and hugepages for memfd). With
  4.14 support dropped, there are no such checks anymore.
- Various KVM_SET_* ioctls do not need to be allowed on the vcpu thread,
  because they are all called _before_ the vcpu seccomp filters are
  installed (as they are only used during snapshot restore / when
  preparing KVM state for boot).
- on aarch64, we can additionally remove KVM_{SET,GET}VCPU_EVENTS, as we
  never call this ioctl on arm (only on x86)

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Dec 16, 2024
commit dc21eefd425e804e7071798488fa8ef71c919224
52 changes: 0 additions & 52 deletions resources/seccomp/aarch64-unknown-linux-musl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
{
"syscall": "close"
},
{
"syscall": "uname",
"comment": "Used for getting the kernel version, for validating io_uring support"
},
{
"syscall": "eventfd2",
"comment": "Used for creating io_uring completion event, on drive patch"
Expand Down Expand Up @@ -970,42 +966,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1074048665,
"comment": "KVM_SET_MP_STATE"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 2151722655,
"comment": "KVM_GET_VCPU_EVENTS"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1077980832,
"comment": "KVM_SET_VCPU_EVENTS"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand All @@ -1018,18 +978,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1074835116,
"comment": "KVM_SET_ONE_REG"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand Down
154 changes: 3 additions & 151 deletions resources/seccomp/x86_64-unknown-linux-musl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
{
"syscall": "close"
},
{
"syscall": "uname",
"comment": "Used for getting the kernel version, for validating io_uring support"
},
{
"syscall": "eventfd2",
"comment": "Used for creating io_uring completion event, on drive patch"
Expand Down Expand Up @@ -111,8 +107,8 @@
"comment": "sigaltstack is used by Rust stdlib to remove alternative signal stack during thread teardown."
},
{
"syscall": "getrandom",
"comment": "getrandom is used by aws-lc library which we consume in virtio-rng"
"syscall": "getrandom",
"comment": "getrandom is used by aws-lc library which we consume in virtio-rng"
},
{
"syscall": "accept4",
Expand Down Expand Up @@ -214,7 +210,7 @@
},
{
"syscall": "madvise",
"comment": "Used by the VirtIO balloon device and by musl for some customer workloads. It is also used by aws-lc during random number generation. They setup a memory page that mark with MADV_WIPEONFORK to be able to detect forks. They also call it with -1 to see if madvise is supported in certain platforms."
"comment": "Used by the VirtIO balloon device and by musl for some customer workloads. It is also used by aws-lc during random number generation. They setup a memory page that mark with MADV_WIPEONFORK to be able to detect forks. They also call it with -1 to see if madvise is supported in certain platforms."
},
{
"syscall": "mmap",
Expand Down Expand Up @@ -978,18 +974,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1074048665,
"comment": "KVM_SET_MP_STATE"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand All @@ -1002,18 +986,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1077980832,
"comment": "KVM_SET_VCPU_EVENTS"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand All @@ -1038,78 +1010,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1074310800,
"comment": "KVM_SET_CPUID2"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1140895375,
"comment": "KVM_SET_LAPIC"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1074310793,
"comment": "KVM_SET_MSRS"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1083223682,
"comment": "KVM_SET_REGS"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1094233732,
"comment": "KVM_SET_SREGS"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 2154868383,
"comment": "KVM_GET_PIT2"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand Down Expand Up @@ -1158,18 +1058,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1082175138,
"comment": "KVM_SET_DEBUGREGS"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand All @@ -1182,18 +1070,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1342221989,
"comment": "KVM_SET_XSAVE"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand All @@ -1206,30 +1082,6 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 1099476647,
"comment": "KVM_SET_XCRS"
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 44706,
"comment": "KVM_SET_TSC_KHZ"
}
]
},
{
"syscall": "ioctl",
"args": [
Expand Down
Loading