[sanitizer] Support v2 and v3 capabilities
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 24 Feb 2023 12:10:15 +0000 (13:10 +0100)
committerIlya Leoshkevich <iii@linux.ibm.com>
Fri, 24 Feb 2023 13:12:11 +0000 (14:12 +0100)
commit0ce057c5925d8bcb3b3835d439b5465c01812424
treeba479c687e9cd41a39db10e862560d6cec4e48f4
parentf8f329a224d8323dcc1fe20a71c87d6025480055
[sanitizer] Support v2 and v3 capabilities

capget() and capset() may read or write more than one cap_user_data_t,
depending on the version field of cap_user_header_t. Currently the
code assumes it's just one, so MSan complains if an application uses
version 2 or 3, where two cap_user_data_ts are used.

Parse the header in order to determine the number of cap_user_data_ts.
Also add a test.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143660
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
compiler-rt/test/sanitizer_common/TestCases/Linux/cap.c [new file with mode: 0644]