jail: fix capabilities
authorDaniel Golle <daniel@makrotopia.org>
Fri, 6 Nov 2020 18:42:25 +0000 (18:42 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 7 Nov 2020 04:37:03 +0000 (04:37 +0000)
commitb0de894830a93da5b303a3d89a42baf163d0a58c
treeb4ed8e973b06067e7d636bd5d214f4038f2280e9
parent75f2374f1656b6f2eee3fa0e3b871f5ddcbee1c4
jail: fix capabilities

Allocate enough stack space for capget()/capset() which requires
2*sizeof(struct __user_cap_data_struct), each containing 32-bit fields,
where the 2nd struct contains the bits for high (>32) capabilities.
Failing to do that not only leads to those high capabilities being
inaccessible but also overwrote the stack resulting in ujail hanging
infinitely instead of returning from applyOCIcapabilities().
Also adapt debugging output to 64-bit format.
Apart from that, don't set SECBIT_NO_SETUID_FIXUP when not actually
modifying capabilities explicitely, as that would result in ALL
capabilities retained in the subsequent setuid() call instead of
having them all dropped.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/capabilities.c
jail/jail.c