2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-19 08:52:20 +00:00

imgutil: derive the seccomp filter length from the filter

This commit is contained in:
Markus Hilger
2026-11-12 15:42:18 +01:00
parent dade8ea706
commit 7108cdd3d9
+5 -4
View File
@@ -1460,15 +1460,16 @@ class FakeUname(object):
fd = -1
if self.machine in SECCOMP_ARCH:
arch, nruname, nrseccomp = SECCOMP_ARCH[self.machine]
filt = b''.join(struct.pack('<HBBI', *insn) for insn in (
filt = (
(0x20, 0, 0, 4), # load arch
(0x15, 0, 3, arch),
(0x20, 0, 0, 0), # load syscall number
(0x15, 0, 1, nruname),
(0x06, 0, 0, 0x7fc00000), # SECCOMP_RET_USER_NOTIF
(0x06, 0, 0, 0x7fff0000))) # SECCOMP_RET_ALLOW
fbuf = ctypes.create_string_buffer(filt)
prog = struct.pack('<HxxxxxxQ', 6, ctypes.addressof(fbuf))
(0x06, 0, 0, 0x7fff0000)) # SECCOMP_RET_ALLOW
fbuf = ctypes.create_string_buffer(
b''.join(struct.pack('<HBBI', *insn) for insn in filt))
prog = struct.pack('<HxxxxxxQ', len(filt), ctypes.addressof(fbuf))
libc.syscall.restype = ctypes.c_long
# SECCOMP_SET_MODE_FILTER with SECCOMP_FILTER_FLAG_NEW_LISTENER
fd = libc.syscall(nrseccomp, 1, 8, ctypes.c_char_p(prog))