2 * Copyright (c) 2000 Wichert Akkerman <wakkerma@debian.org>
3 * Copyright (c) 2011 Denys Vlasenko <dvlasenk@redhat.com>
4 * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
5 * Copyright (c) 2014-2018 The strace developers.
8 * SPDX-License-Identifier: LGPL-2.1-or-later
13 /* these constants are the same as in <linux/capability.h> */
18 #include "xlat/cap_mask0.h"
20 /* these constants are CAP_TO_INDEX'ed constants from <linux/capability.h> */
25 #include "xlat/cap_mask1.h"
27 /* these constants are the same as in <linux/capability.h> */
29 _LINUX_CAPABILITY_VERSION_1 = 0x19980330,
30 _LINUX_CAPABILITY_VERSION_2 = 0x20071026,
31 _LINUX_CAPABILITY_VERSION_3 = 0x20080522
34 #include "xlat/cap_version.h"
36 struct user_cap_header_struct {
41 struct user_cap_data_struct {
47 static const struct user_cap_header_struct *
48 get_cap_header(struct tcb *const tcp, const kernel_ulong_t addr)
50 static struct user_cap_header_struct header;
52 if (!addr || !verbose(tcp))
55 if (umove(tcp, addr, &header) < 0)
62 print_cap_header(struct tcb *const tcp, const kernel_ulong_t addr,
63 const struct user_cap_header_struct *const h)
71 printxval(cap_version, h->version,
72 "_LINUX_CAPABILITY_VERSION_???");
73 tprintf(", pid=%d}", h->pid);
77 print_cap_bits(const uint32_t lo, const uint32_t hi)
80 printflags(cap_mask0, lo, "CAP_???");
85 printflags(cap_mask1, hi, "CAP_???");
90 print_cap_data(struct tcb *const tcp, const kernel_ulong_t addr,
91 const struct user_cap_header_struct *const h)
93 struct user_cap_data_struct data[2];
101 if (_LINUX_CAPABILITY_VERSION_2 == h->version ||
102 _LINUX_CAPABILITY_VERSION_3 == h->version)
107 if (umoven_or_printaddr(tcp, addr, len * sizeof(data[0]), data))
110 tprints("{effective=");
111 print_cap_bits(data[0].effective, len > 1 ? data[1].effective : 0);
112 tprints(", permitted=");
113 print_cap_bits(data[0].permitted, len > 1 ? data[1].permitted : 0);
114 tprints(", inheritable=");
115 print_cap_bits(data[0].inheritable, len > 1 ? data[1].inheritable : 0);
121 const struct user_cap_header_struct *h;
124 h = get_cap_header(tcp, tcp->u_arg[0]);
125 print_cap_header(tcp, tcp->u_arg[0], h);
128 h = syserror(tcp) ? NULL : get_cap_header(tcp, tcp->u_arg[0]);
129 print_cap_data(tcp, tcp->u_arg[1], h);
136 const struct user_cap_header_struct *const h =
137 get_cap_header(tcp, tcp->u_arg[0]);
138 print_cap_header(tcp, tcp->u_arg[0], h);
140 print_cap_data(tcp, tcp->u_arg[1], h);