]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: capabilities: prepare support for version 3
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 21 Jun 2024 22:15:20 +0000 (00:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Jun 2024 05:38:21 +0000 (07:38 +0200)
commite2e756a67d3ee9ad75dc0bee5ce9030569139d42
tree2122d0e46701b0a52280665562ba47d1ef855d6c
parentfcf1a0bcf539f71b2f7bea1e6070cbddf61531d1
MINOR: capabilities: prepare support for version 3

Commit e338d263a76a ("Add 64-bit capability support to the kernel")
introduces in the kernel _LINUX_CAPABILITY_VERSION_1 and
_LINUX_CAPABILITY_VERSION_2 and its corresponded magic numbers "1"
(_LINUX_CAPABILITY_U32S_1) and "2" (_LINUX_CAPABILITY_VERSION_2).

Capabilities sets, since this commit, are composed as an arrays of
 __user_cap_data_struct with length defined in version's magic number
(e.g. struct __user_cap_data_struct kdata[_LINUX_CAPABILITY_U32S_1]).

These magic numbers also help the kernel to figure out how many data
(in __user_cap_data_struct "units") it needs to copy_from/to_user in
capset/capget syscalls.

In order to use _LINUX_CAPABILITY_VERSION_3 in the next commit (it has the
same functionality as version 2), let's follow the kernel code and let's
allocate memory to store 32-capabilities as an array of
__user_cap_data_struct with the length of 1 (_LINUX_CAPABILITY_U32S_1).
src/linuxcap.c