| 1 |
|
| 2 |
%{ |
| 3 |
// Be sure we have the __NR_* defines. |
| 4 |
#include <asm/unistd.h> |
| 5 |
#include "linux/compat_unistd.h" |
| 6 |
|
| 7 |
// Be sure we have the SYS_* defines. |
| 8 |
#include <linux/net.h> |
| 9 |
#include "linux/compat_net.h" |
| 10 |
|
| 11 |
#ifdef CONFIG_COMPAT |
| 12 |
// Be sure we have 'SHMCTL', etc. defined. |
| 13 |
#include <linux/ipc.h> |
| 14 |
#ifndef SEMOP |
| 15 |
#define SEMOP 1 |
| 16 |
#endif |
| 17 |
#ifndef SEMCTL |
| 18 |
#define SEMCTL 3 |
| 19 |
#endif |
| 20 |
#ifndef SEMTIMEDOP |
| 21 |
#define SEMTIMEDOP 4 |
| 22 |
#endif |
| 23 |
#ifndef MSGSND |
| 24 |
#define MSGSND 11 |
| 25 |
#endif |
| 26 |
#ifndef MSGRCV |
| 27 |
#define MSGRCV 12 |
| 28 |
#endif |
| 29 |
#ifndef MSGCTL |
| 30 |
#define MSGCTL 14 |
| 31 |
#endif |
| 32 |
#ifndef SHMCTL |
| 33 |
#define SHMCTL 24 |
| 34 |
#endif |
| 35 |
#endif |
| 36 |
|
| 37 |
/* deprecation: struct compat_*time* aliases moved to this header */ |
| 38 |
#if defined(STAPCONF_TIME32_H) |
| 39 |
#include <linux/time32.h> |
| 40 |
/* further deprecation: struct compat_*time* aliases renamed to old_*time* */ |
| 41 |
#elif defined(STAPCONF_TIME32_OLD_H) |
| 42 |
#include <linux/time32.h> |
| 43 |
#define compat_time_t old_time32_t |
| 44 |
#define compat_timeval old_timeval32 |
| 45 |
#define timeval old_timeval32 |
| 46 |
#define compat_timespec old_timespec32 |
| 47 |
#define timespec old_timespec32 |
| 48 |
#define compat_itimerspec old_itimerspec32 |
| 49 |
#define itimerspec old_itimerspec32 |
| 50 |
#define ns_to_compat_timeval ns_to_old_timeval32 |
| 51 |
#define get_compat_itimerspec64 get_old_itimerspec32 |
| 52 |
#define put_compat_itimerspec64 put_old_itimerspec32 |
| 53 |
#define compat_get_timespec64 get_old_timespec32 |
| 54 |
#define compat_put_timespec64 put_old_timespec32 |
| 55 |
/* in kernel/time/itimer.c */ |
| 56 |
struct old_itimerval32 { |
| 57 |
struct old_timeval32 it_interval; |
| 58 |
struct old_timeval32 it_value; |
| 59 |
}; |
| 60 |
#define compat_itimerval old_itimerval32 |
| 61 |
#define itimerval old_itimerval32 |
| 62 |
#define timex old_timex32 |
| 63 |
#endif |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
/* |
| 68 |
* Simple lookup functions for mapping values to names |
| 69 |
* using embedded C. Use these functions to create safe, |
| 70 |
* consistent lookups. |
| 71 |
*/ |
| 72 |
|
| 73 |
// Get _stp_val_array and _stp_lookup_* definitions. |
| 74 |
#include "linux/syscalls-common.h" |
| 75 |
|
| 76 |
// Get _stp_syscall_get_nr() definitions. |
| 77 |
#include "syscall.h" |
| 78 |
|
| 79 |
static void |
| 80 |
_stp_lookup_str2(const _stp_val_array * const array, long val, char *ptr, |
| 81 |
int len, int base) |
| 82 |
{ |
| 83 |
int i = 0, slen; |
| 84 |
while (array[i].name) { |
| 85 |
if (array[i].val == val) { |
| 86 |
strlcat (ptr, array[i].name, len); |
| 87 |
return; |
| 88 |
} |
| 89 |
i++; |
| 90 |
} |
| 91 |
slen = strlen(ptr); |
| 92 |
if (base == 10) |
| 93 |
_stp_snprintf(ptr + slen, len - slen, "%ld", val); |
| 94 |
else if (base == 8) |
| 95 |
_stp_snprintf(ptr + slen, len - slen, "%#lo", val); |
| 96 |
else |
| 97 |
_stp_snprintf(ptr + slen, len - slen, "0x%lx", val); |
| 98 |
} |
| 99 |
|
| 100 |
static inline void |
| 101 |
_stp_lookup_str(const _stp_val_array * const array, long val, char *ptr, |
| 102 |
int len) |
| 103 |
{ |
| 104 |
_stp_lookup_str2(array, val, ptr, len, 16); |
| 105 |
} |
| 106 |
|
| 107 |
static void |
| 108 |
_stp_lookup_or_str2(const _stp_val_array * const array, long val, char *ptr, |
| 109 |
int len, int base) |
| 110 |
{ |
| 111 |
int i = 0, flag = 0, slen; |
| 112 |
|
| 113 |
if (val == 0) { |
| 114 |
_stp_lookup_str2(array, val, ptr, len, base); |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 118 |
while (array[i].name) { |
| 119 |
if (array[i].val & val) { |
| 120 |
if (flag) |
| 121 |
strlcat(ptr, "|", len); |
| 122 |
strlcat(ptr, array[i].name, len); |
| 123 |
val &= (~array[i].val); |
| 124 |
flag = 1; |
| 125 |
} |
| 126 |
i++; |
| 127 |
} |
| 128 |
if (val) { |
| 129 |
if (flag) |
| 130 |
strlcat(ptr, "|", len); |
| 131 |
slen = strlen(ptr); |
| 132 |
if (base == 10) |
| 133 |
_stp_snprintf(ptr + slen, len - slen, "%ld", val); |
| 134 |
else if (base == 8) |
| 135 |
_stp_snprintf(ptr + slen, len - slen, "%#lo", val); |
| 136 |
else |
| 137 |
_stp_snprintf(ptr + slen, len - slen, "0x%lx", val); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
static inline void |
| 142 |
_stp_lookup_or_str(const _stp_val_array * const array, long val, char *ptr, |
| 143 |
int len) |
| 144 |
{ |
| 145 |
_stp_lookup_or_str2(array, val, ptr, len, 16); |
| 146 |
} |
| 147 |
%} |
| 148 |
|
| 149 |
%{ |
| 150 |
#ifdef CONFIG_COMPAT |
| 151 |
#include <linux/compat.h> |
| 152 |
|
| 153 |
#ifndef STAPCONF_SIGSET_FROM_COMPAT_EXPORTED |
| 154 |
void |
| 155 |
sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
| 156 |
void |
| 157 |
sigset_from_compat(sigset_t *set, compat_sigset_t *compat) |
| 158 |
{ |
| 159 |
switch (_NSIG_WORDS) { |
| 160 |
case 4: set->sig[3] = compat->sig[6] | (((long)compat->sig[7]) << 32 ); |
| 161 |
fallthrough; |
| 162 |
case 3: set->sig[2] = compat->sig[4] | (((long)compat->sig[5]) << 32 ); |
| 163 |
fallthrough; |
| 164 |
case 2: set->sig[1] = compat->sig[2] | (((long)compat->sig[3]) << 32 ); |
| 165 |
fallthrough; |
| 166 |
case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 ); |
| 167 |
} |
| 168 |
} |
| 169 |
#endif /* STAPCONF_SIGSET_FROM_COMPAT_EXPORTED */ |
| 170 |
#endif /* CONFIG_COMPAT */ |
| 171 |
|
| 172 |
%} |
| 173 |
|
| 174 |
# |
| 175 |
# Given a userspace pointer to a timeval, |
| 176 |
# copy and decode it and return a string. |
| 177 |
# |
| 178 |
function _struct_timeval_u:string(uaddr:long, n:long) |
| 179 |
%{ /* pure */ |
| 180 |
/* The utimes() syscall switched from using struct timeval to using |
| 181 |
* struct __kernel_old_timeval in kernel version 5.5-rc1, see |
| 182 |
* https://elixir.bootlin.com/linux/v5.5-rc1/source/fs/utimes.c#L198 |
| 183 |
* This applies to select() and settimeofday() syscalls as well. |
| 184 |
*/ |
| 185 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0) |
| 186 |
#define __TVSTRUCT timeval |
| 187 |
#else |
| 188 |
#define __TVSTRUCT __kernel_old_timeval |
| 189 |
#endif |
| 190 |
int n = (int)STAP_ARG_n; |
| 191 |
struct __TVSTRUCT tv[2]; /* maximum enforced below */ |
| 192 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 193 |
|
| 194 |
if (ptr == NULL || n < 1 || n > 2) |
| 195 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 196 |
else { |
| 197 |
if (_stp_copy_from_user((char*)&tv, ptr, |
| 198 |
n*sizeof(struct __TVSTRUCT)) == 0) { |
| 199 |
if (n == 2) |
| 200 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 201 |
"[%ld.%06ld][%ld.%.06ld]", |
| 202 |
(long)tv[0].tv_sec, (long)tv[0].tv_usec, |
| 203 |
(long)tv[1].tv_sec, (long)tv[1].tv_usec); |
| 204 |
else |
| 205 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 206 |
"[%ld.%06ld]", (long)tv[0].tv_sec, |
| 207 |
(long)tv[0].tv_usec); |
| 208 |
} |
| 209 |
else |
| 210 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 211 |
(unsigned long)ptr); |
| 212 |
} |
| 213 |
%} |
| 214 |
|
| 215 |
function _struct_compat_timeval_u:string(uaddr:long, n:long) |
| 216 |
%{ /* pure */ |
| 217 |
#ifdef CONFIG_COMPAT |
| 218 |
int n = (int)STAP_ARG_n; |
| 219 |
struct compat_timeval tv[2]; /* maximum enforced below */ |
| 220 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 221 |
|
| 222 |
if (ptr == NULL || n < 1 || n > 2) |
| 223 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 224 |
else { |
| 225 |
if (_stp_copy_from_user((char*)&tv, ptr, |
| 226 |
n*sizeof(struct compat_timeval)) == 0) { |
| 227 |
if (n == 2) |
| 228 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 229 |
"[%ld.%06ld][%ld.%.06ld]", |
| 230 |
(long)tv[0].tv_sec, |
| 231 |
(long)tv[0].tv_usec, |
| 232 |
(long)tv[1].tv_sec, |
| 233 |
(long)tv[1].tv_usec); |
| 234 |
else |
| 235 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 236 |
"[%ld.%06ld]", (long)tv[0].tv_sec, |
| 237 |
(long)tv[0].tv_usec); |
| 238 |
} |
| 239 |
else |
| 240 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 241 |
(unsigned long)ptr); |
| 242 |
} |
| 243 |
#endif |
| 244 |
%} |
| 245 |
|
| 246 |
function _struct_timezone_u:string(uaddr:long) |
| 247 |
%{ /* pure */ |
| 248 |
struct timezone tz; |
| 249 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 250 |
|
| 251 |
if (ptr == NULL) |
| 252 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 253 |
else { |
| 254 |
if (_stp_copy_from_user((char*)&tz, ptr, |
| 255 |
sizeof(struct timezone)) == 0) |
| 256 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "[%d, %d]", |
| 257 |
tz.tz_minuteswest, tz.tz_dsttime); |
| 258 |
else |
| 259 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 260 |
(unsigned long)ptr); |
| 261 |
} |
| 262 |
%} |
| 263 |
|
| 264 |
%{ |
| 265 |
// Needed for the following four functions |
| 266 |
// _struct_utimbuf_actime, _struct_utimbuf_modtime, |
| 267 |
// _struct_compat_utimbuf_actime, _struct_compat_utimbuf_modtime |
| 268 |
#include <linux/utime.h> |
| 269 |
%} |
| 270 |
|
| 271 |
function _stp_clock_nanosleep_flags_str:string(flags:long) |
| 272 |
%{ /* pure */ /* unprivileged */ |
| 273 |
static const _stp_val_array nanosleep_flags_list[] = { |
| 274 |
V(TIMER_ABSTIME), |
| 275 |
{0, NULL} |
| 276 |
}; |
| 277 |
_stp_lookup_str(nanosleep_flags_list, (unsigned int)STAP_ARG_flags, |
| 278 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 279 |
%} |
| 280 |
|
| 281 |
// Returns the value of the actime field of a utimbuf in user space |
| 282 |
// at the given address, or zero on when userspace data is not accessible. |
| 283 |
function _struct_utimbuf_actime:long(uaddr:long) |
| 284 |
%{ /* pure */ |
| 285 |
struct utimbuf ubuf; |
| 286 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 287 |
|
| 288 |
if (ptr == NULL) |
| 289 |
STAP_RETVALUE = 0; |
| 290 |
else |
| 291 |
if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) |
| 292 |
STAP_RETVALUE = ubuf.actime; |
| 293 |
else |
| 294 |
STAP_RETVALUE = 0; |
| 295 |
%} |
| 296 |
|
| 297 |
// Returns the value of the modtime field of a utimbuf in user space |
| 298 |
// at the given address, or zero on when userspace data is not accessible. |
| 299 |
function _struct_utimbuf_modtime:long(uaddr:long) |
| 300 |
%{ /* pure */ |
| 301 |
struct utimbuf ubuf; |
| 302 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 303 |
|
| 304 |
if (ptr == NULL) |
| 305 |
STAP_RETVALUE = 0; |
| 306 |
else |
| 307 |
if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) |
| 308 |
STAP_RETVALUE = ubuf.modtime; |
| 309 |
else |
| 310 |
STAP_RETVALUE = 0; |
| 311 |
%} |
| 312 |
|
| 313 |
// Returns the value of the actime field of a compat_utimbuf in user space |
| 314 |
// at the given address, or zero on when userspace data is not accessible. |
| 315 |
function _struct_compat_utimbuf_actime:long(uaddr:long) |
| 316 |
%{ /* pure */ |
| 317 |
#ifdef CONFIG_COMPAT |
| 318 |
#if defined(STAPCONF_COMPAT_UTIMBUF) |
| 319 |
struct compat_utimbuf ubuf; |
| 320 |
#else |
| 321 |
struct old_utimbuf32 ubuf; |
| 322 |
#endif |
| 323 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 324 |
|
| 325 |
if (ptr == NULL) |
| 326 |
STAP_RETVALUE = 0; |
| 327 |
else |
| 328 |
if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) |
| 329 |
STAP_RETVALUE = ubuf.actime; |
| 330 |
else |
| 331 |
STAP_RETVALUE = 0; |
| 332 |
#endif |
| 333 |
%} |
| 334 |
|
| 335 |
// Returns the value of the modtime field of a compat_utimbuf in user space |
| 336 |
// at the given address, or zero on when userspace data is not accessible. |
| 337 |
function _struct_compat_utimbuf_modtime:long(uaddr:long) |
| 338 |
%{ /* pure */ |
| 339 |
#ifdef CONFIG_COMPAT |
| 340 |
#if defined(STAPCONF_COMPAT_UTIMBUF) |
| 341 |
struct compat_utimbuf ubuf; |
| 342 |
#else |
| 343 |
struct old_utimbuf32 ubuf; |
| 344 |
#endif |
| 345 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 346 |
|
| 347 |
if (ptr == NULL) |
| 348 |
STAP_RETVALUE = 0; |
| 349 |
else |
| 350 |
if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) |
| 351 |
STAP_RETVALUE = ubuf.modtime; |
| 352 |
else |
| 353 |
STAP_RETVALUE = 0; |
| 354 |
#endif |
| 355 |
%} |
| 356 |
|
| 357 |
function _struct_timespec_u:string(uaddr:long, n:long) |
| 358 |
%{ /* pure */ |
| 359 |
#define STP_UTIME_NOW ((1l << 30) - 1l) |
| 360 |
#define STP_UTIME_OMIT ((1l << 30) - 2l) |
| 361 |
int n = (int)STAP_ARG_n; |
| 362 |
struct timespec ts[2]; /* maximum enforced below */ |
| 363 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 364 |
|
| 365 |
if (ptr == NULL || n < 1 || n > 2) |
| 366 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 367 |
else { |
| 368 |
if (_stp_copy_from_user((char *)&ts, ptr, |
| 369 |
n*sizeof(struct timespec))) { |
| 370 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 371 |
(unsigned long)ptr); |
| 372 |
} |
| 373 |
else { |
| 374 |
char *str; |
| 375 |
int len, i = 0; |
| 376 |
ptr = STAP_RETVALUE; |
| 377 |
while (i < n) { |
| 378 |
str = NULL; |
| 379 |
if (ts[i].tv_nsec == STP_UTIME_NOW) |
| 380 |
str = "UTIME_NOW"; |
| 381 |
else if (ts[i].tv_nsec == STP_UTIME_OMIT) |
| 382 |
str = "UTIME_OMIT"; |
| 383 |
if (str) |
| 384 |
len = snprintf(ptr, MAXSTRINGLEN, |
| 385 |
"[%s]", str); |
| 386 |
else |
| 387 |
len = snprintf(ptr, MAXSTRINGLEN, |
| 388 |
"[%ld.%09ld]", |
| 389 |
(long)ts[i].tv_sec, |
| 390 |
(long)ts[i].tv_nsec); |
| 391 |
ptr += len; |
| 392 |
i++; |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
#undef STP_UTIME_NOW |
| 397 |
#undef STP_UTIME_OMIT |
| 398 |
%} |
| 399 |
|
| 400 |
function _struct_compat_timespec_u:string(uaddr:long, n:long) |
| 401 |
%{ /* pure */ |
| 402 |
#ifdef CONFIG_COMPAT |
| 403 |
#define STP_UTIME_NOW ((1l << 30) - 1l) |
| 404 |
#define STP_UTIME_OMIT ((1l << 30) - 2l) |
| 405 |
int n = (int)STAP_ARG_n; |
| 406 |
struct compat_timespec ts[2]; /* maximum, enforced below */ |
| 407 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 408 |
|
| 409 |
if (ptr == NULL || n < 1 || n > 2) |
| 410 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 411 |
else { |
| 412 |
if (_stp_copy_from_user((char *)&ts, ptr, |
| 413 |
n*sizeof(struct compat_timespec))) { |
| 414 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 415 |
(unsigned long)ptr); |
| 416 |
} |
| 417 |
else { |
| 418 |
char *str; |
| 419 |
int len, i = 0; |
| 420 |
ptr = STAP_RETVALUE; |
| 421 |
while (i < n) { |
| 422 |
str = NULL; |
| 423 |
if (ts[i].tv_nsec == STP_UTIME_NOW) |
| 424 |
str = "UTIME_NOW"; |
| 425 |
else if (ts[i].tv_nsec == STP_UTIME_OMIT) |
| 426 |
str = "UTIME_OMIT"; |
| 427 |
if (str) |
| 428 |
len = snprintf(ptr, MAXSTRINGLEN, |
| 429 |
"[%s]", str); |
| 430 |
else |
| 431 |
len = snprintf(ptr, MAXSTRINGLEN, |
| 432 |
"[%ld.%09ld]", |
| 433 |
(long)ts[i].tv_sec, |
| 434 |
(long)ts[i].tv_nsec); |
| 435 |
ptr += len; |
| 436 |
i++; |
| 437 |
} |
| 438 |
} |
| 439 |
} |
| 440 |
#undef STP_UTIME_NOW |
| 441 |
#undef STP_UTIME_OMIT |
| 442 |
#endif |
| 443 |
%} |
| 444 |
|
| 445 |
|
| 446 |
function _struct_itimerspec_u:string(uaddr:long) |
| 447 |
%{ /* pure */ |
| 448 |
struct itimerspec its; |
| 449 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 450 |
|
| 451 |
if (ptr == NULL) |
| 452 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 453 |
else { |
| 454 |
if(_stp_copy_from_user((char *)&its, ptr,sizeof(struct itimerspec))) |
| 455 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 456 |
(unsigned long)ptr); |
| 457 |
else |
| 458 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "[%d.%06d,%d.%06d]", |
| 459 |
(int)its.it_interval.tv_sec, (int)its.it_interval.tv_nsec, |
| 460 |
(int)its.it_value.tv_sec, (int)its.it_value.tv_nsec); |
| 461 |
} |
| 462 |
%} |
| 463 |
|
| 464 |
function _struct_compat_itimerspec_u:string(uaddr:long) |
| 465 |
%{ /* pure */ |
| 466 |
#ifdef CONFIG_COMPAT |
| 467 |
struct compat_itimerspec its; |
| 468 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 469 |
|
| 470 |
if (ptr == NULL) |
| 471 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 472 |
else { |
| 473 |
if (_stp_copy_from_user((char *)&its, ptr, sizeof(its))) |
| 474 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 475 |
(unsigned long)ptr); |
| 476 |
else |
| 477 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 478 |
"[%d.%06d,%d.%06d]", |
| 479 |
(int)its.it_interval.tv_sec, |
| 480 |
(int)its.it_interval.tv_nsec, |
| 481 |
(int)its.it_value.tv_sec, |
| 482 |
(int)its.it_value.tv_nsec); |
| 483 |
} |
| 484 |
#endif |
| 485 |
%} |
| 486 |
|
| 487 |
function _struct_itimerval_u:string(uaddr:long) |
| 488 |
%{ /* pure */ |
| 489 |
struct itimerval itv; |
| 490 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 491 |
|
| 492 |
if (ptr == NULL) |
| 493 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 494 |
else { |
| 495 |
if(_stp_copy_from_user((char *)&itv,ptr,sizeof(struct itimerval))) |
| 496 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 497 |
(unsigned long)ptr); |
| 498 |
else |
| 499 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "[%d.%06d,%d.%06d]", |
| 500 |
(int)itv.it_interval.tv_sec, (int)itv.it_interval.tv_usec, |
| 501 |
(int)itv.it_value.tv_sec, (int)itv.it_value.tv_usec); |
| 502 |
} |
| 503 |
%} |
| 504 |
|
| 505 |
function _struct_compat_itimerval_u:string(uaddr:long) |
| 506 |
%{ /* pure */ |
| 507 |
#ifdef CONFIG_COMPAT |
| 508 |
struct compat_itimerval itv; |
| 509 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 510 |
|
| 511 |
if (ptr == NULL) |
| 512 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 513 |
else { |
| 514 |
if(_stp_copy_from_user((char *)&itv,ptr,sizeof(struct compat_itimerval))) |
| 515 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 516 |
(unsigned long)ptr); |
| 517 |
else |
| 518 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "[%d.%06d,%d.%06d]", |
| 519 |
(int)itv.it_interval.tv_sec, (int)itv.it_interval.tv_usec, |
| 520 |
(int)itv.it_value.tv_sec, (int)itv.it_value.tv_usec); |
| 521 |
} |
| 522 |
#endif |
| 523 |
%} |
| 524 |
|
| 525 |
%{ |
| 526 |
// Needed for @__private30 function _struct_sockaddr_u_impl. Unfortunately cannot be |
| 527 |
// inlined into the function since these header files define static |
| 528 |
// functions themselves. |
| 529 |
#include <linux/socket.h> |
| 530 |
#include <linux/in.h> |
| 531 |
#include <linux/netlink.h> |
| 532 |
%} |
| 533 |
|
| 534 |
%{ |
| 535 |
// Enum for _struct_sockaddr_u_* functions. |
| 536 |
typedef enum { |
| 537 |
SA_PRETTY = 1, |
| 538 |
SA_IP_ADDR = 2, |
| 539 |
SA_TCP_PORT = 4, |
| 540 |
SA_FAMILY = 8, |
| 541 |
SA_IPV6_FLOWINFO = 16, |
| 542 |
SA_IPV6_SCOPE_ID = 32, |
| 543 |
} sa_dispatch; |
| 544 |
%} |
| 545 |
|
| 546 |
function _struct_sockaddr_u_ip_addr:string(uaddr:long, len:long) |
| 547 |
{ |
| 548 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_IP_ADDR")); |
| 549 |
} |
| 550 |
|
| 551 |
function _struct_sockaddr_u_tcp_port:string(uaddr:long, len:long) |
| 552 |
{ |
| 553 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_TCP_PORT")); |
| 554 |
} |
| 555 |
|
| 556 |
@__private30 function _struct_sockaddr_u_ip_addr_tcp_port:string(uaddr:long, len:long) |
| 557 |
{ |
| 558 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_IP_ADDR") | @const("SA_TCP_PORT")); |
| 559 |
} |
| 560 |
|
| 561 |
function _struct_sockaddr_u_sa_family:string(uaddr:long, len:long) |
| 562 |
{ |
| 563 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_FAMILY")); |
| 564 |
} |
| 565 |
|
| 566 |
function _struct_sockaddr_u_ipv6_flowinfo:string(uaddr:long, len:long) |
| 567 |
{ |
| 568 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_IPV6_FLOWINFO")); |
| 569 |
} |
| 570 |
|
| 571 |
function _struct_sockaddr_u_ipv6_scope_id:string(uaddr:long, len:long) |
| 572 |
{ |
| 573 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_IPV6_SCOPE_ID")); |
| 574 |
} |
| 575 |
|
| 576 |
function _struct_sockaddr_u:string(uaddr:long, len:long) |
| 577 |
{ |
| 578 |
return _struct_sockaddr_u_impl(uaddr, len, @const("SA_PRETTY")); |
| 579 |
} |
| 580 |
|
| 581 |
%{ |
| 582 |
#define STAP_NEED_CONTEXT_SOCKADDR_BIG_BUFFERS 1 |
| 583 |
%} |
| 584 |
|
| 585 |
@__private30 function _struct_sockaddr_u_impl:string(uaddr:long, len:long, what:long) |
| 586 |
%{ /* pure */ |
| 587 |
|
| 588 |
|
| 589 |
#include <linux/version.h> |
| 590 |
#include <linux/in6.h> |
| 591 |
#include <linux/un.h> |
| 592 |
#include <linux/if_packet.h> |
| 593 |
|
| 594 |
sa_dispatch what = (sa_dispatch)STAP_ARG_what; |
| 595 |
|
| 596 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 597 |
size_t len = clamp_t(size_t, STAP_ARG_len, 0, 128); |
| 598 |
struct sockaddr *sa = (struct sockaddr *)CONTEXT->buf; |
| 599 |
|
| 600 |
char *stap_retvalue = (char *)(unsigned long)STAP_RETVALUE; |
| 601 |
int maxstringlen = MAXSTRINGLEN; |
| 602 |
size_t n; |
| 603 |
|
| 604 |
if (ptr == NULL) |
| 605 |
{ |
| 606 |
strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 607 |
return; |
| 608 |
} |
| 609 |
|
| 610 |
// This helps handle variable lenght sockaddr_un. |
| 611 |
// Some application - like systemd - sends path string |
| 612 |
// without ending null character. Kernel will handle this |
| 613 |
// but we need pretty output without random memory stuff. |
| 614 |
memset(CONTEXT->buf, 0, 128); |
| 615 |
|
| 616 |
if (_stp_copy_from_user(CONTEXT->buf, ptr, len)) |
| 617 |
{ |
| 618 |
strlcpy(STAP_RETVALUE, "{...}", MAXSTRINGLEN); |
| 619 |
return; |
| 620 |
} |
| 621 |
|
| 622 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) |
| 623 |
#define LPORT (inet->inet.num) |
| 624 |
#define DADDR (&inet->inet.daddr) |
| 625 |
#else |
| 626 |
#define LPORT (inet->num) |
| 627 |
#define DADDR (&inet->daddr) |
| 628 |
#endif |
| 629 |
|
| 630 |
// Use kernel builtin instead of picking up user space ntohs (function). |
| 631 |
#define _stp_ntohs be16_to_cpu |
| 632 |
|
| 633 |
if ((sa->sa_family == AF_INET) && (len == sizeof(struct sockaddr_in))) |
| 634 |
{ |
| 635 |
struct sockaddr_in *sin = (struct sockaddr_in *)CONTEXT->buf; |
| 636 |
|
| 637 |
if (what & SA_PRETTY) |
| 638 |
{ |
| 639 |
#ifndef NIPQUAD_FMT // kver >= 2.6.36 |
| 640 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "{AF_INET, %pI4, %d}", |
| 641 |
&sin->sin_addr, _stp_ntohs(sin->sin_port)); |
| 642 |
#else |
| 643 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 644 |
"{AF_INET, " NIPQUAD_FMT ", %d}", |
| 645 |
NIPQUAD(sin->sin_addr), _stp_ntohs(sin->sin_port)); |
| 646 |
#endif |
| 647 |
return; |
| 648 |
} |
| 649 |
|
| 650 |
if (what & SA_FAMILY) |
| 651 |
{ |
| 652 |
n = strlcpy(stap_retvalue, "AF_INET", maxstringlen); |
| 653 |
// (n - 1) mean: cut of null char |
| 654 |
stap_retvalue += (n); |
| 655 |
maxstringlen -= (n - 1); |
| 656 |
} |
| 657 |
|
| 658 |
if (what & SA_IP_ADDR) |
| 659 |
{ |
| 660 |
#ifndef NIPQUAD_FMT // kver >= 2.6.36 |
| 661 |
n = snprintf(stap_retvalue, maxstringlen, "%pI4", &sin->sin_addr); |
| 662 |
#else |
| 663 |
n = snprintf(stap_retvalue, maxstringlen, NIPQUAD_FMT, |
| 664 |
NIPQUAD(sin->sin_addr)); |
| 665 |
#endif |
| 666 |
// (n - 1) mean: cut of null char |
| 667 |
stap_retvalue += (n); |
| 668 |
maxstringlen -= (n - 1); |
| 669 |
} |
| 670 |
|
| 671 |
if (what & SA_TCP_PORT) |
| 672 |
{ |
| 673 |
n = snprintf(stap_retvalue, maxstringlen, "%d", |
| 674 |
_stp_ntohs(sin->sin_port)); |
| 675 |
// (n - 1) mean: cut of null char |
| 676 |
stap_retvalue += (n); |
| 677 |
maxstringlen -= (n - 1); |
| 678 |
} |
| 679 |
} |
| 680 |
// Why 2 * sizeof (char) here? |
| 681 |
// Because I want to support abstract sockets with |
| 682 |
// at least one usable byte after initial \0 char. |
| 683 |
// Unnamed sockets aren't supported yet. |
| 684 |
else if ((sa->sa_family == AF_UNIX) |
| 685 |
&& ((len == sizeof(struct sockaddr_un)) |
| 686 |
|| (len >= ((sizeof(sa_family_t)) + (2 * sizeof(char)))))) |
| 687 |
{ |
| 688 |
struct sockaddr_un *sun = (struct sockaddr_un *)CONTEXT->buf; |
| 689 |
if (what & SA_PRETTY) |
| 690 |
{ |
| 691 |
|
| 692 |
// Support for abstract sockets |
| 693 |
if (sun->sun_path[0] == '\0') |
| 694 |
{ |
| 695 |
// Abstract sockets aren't string oriented. |
| 696 |
// We need conversion on this place. |
| 697 |
// No check of ret value, because _stp_text_str returns |
| 698 |
// "<unknown>" if bad things happen. |
| 699 |
|
| 700 |
_stp_text_str(CONTEXT->out_str, &sun->sun_path[1], |
| 701 |
len - sizeof(sa_family_t), MAXSTRINGLEN - 1, 0, 0, 1); |
| 702 |
|
| 703 |
// Why a precision of (MAXSTRINGLEN - 18) here? To |
| 704 |
// make sure the formatted string doesn't get |
| 705 |
// truncated by a long out_str variable, we'll specify |
| 706 |
// the maximum number of characters to add from |
| 707 |
// out_str. That number is MAXSTRINGLEN - 17 (the |
| 708 |
// length of the 'static' part of the format string) - |
| 709 |
// 1 (for the formatted string's null character). |
| 710 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 711 |
"{AF_UNIX, \"\\000%.*s\"}", (MAXSTRINGLEN - 18), |
| 712 |
CONTEXT->out_str); |
| 713 |
} else |
| 714 |
{ |
| 715 |
// Just cut path if is too long |
| 716 |
CONTEXT->buf[127] = '\0'; |
| 717 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "{AF_UNIX, \"%s\"}", |
| 718 |
sun->sun_path); |
| 719 |
} |
| 720 |
} else if (what & SA_FAMILY) |
| 721 |
{ |
| 722 |
strlcpy(STAP_RETVALUE, "AF_UNIX", MAXSTRINGLEN); |
| 723 |
} else |
| 724 |
{ |
| 725 |
strlcpy(STAP_RETVALUE, "", MAXSTRINGLEN); |
| 726 |
} |
| 727 |
} |
| 728 |
else if ((sa->sa_family == AF_NETLINK) |
| 729 |
&& (len == sizeof(struct sockaddr_nl))) |
| 730 |
{ |
| 731 |
struct sockaddr_nl *nl = (struct sockaddr_nl *)CONTEXT->buf; |
| 732 |
|
| 733 |
if (what & SA_PRETTY) { |
| 734 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 735 |
"{AF_NETLINK, pid=%d, groups=%08x}", |
| 736 |
nl->nl_pid, nl->nl_groups); |
| 737 |
} else if (what & SA_FAMILY) |
| 738 |
{ |
| 739 |
strlcpy(STAP_RETVALUE, "AF_NETLINK", MAXSTRINGLEN); |
| 740 |
} else |
| 741 |
{ |
| 742 |
strlcpy(STAP_RETVALUE, "", MAXSTRINGLEN); |
| 743 |
} |
| 744 |
} |
| 745 |
else if ((sa->sa_family == AF_INET6) |
| 746 |
&& (len == sizeof(struct sockaddr_in6))) |
| 747 |
{ |
| 748 |
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)CONTEXT->buf; |
| 749 |
|
| 750 |
if (what & SA_PRETTY) |
| 751 |
{ |
| 752 |
#ifndef NIP6_FMT // kver >= 2.6.36 |
| 753 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 754 |
"{AF_INET6, %pI6, %d}", &sin->sin6_addr, |
| 755 |
_stp_ntohs(sin->sin6_port)); |
| 756 |
#else |
| 757 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 758 |
"{AF_INET6, " NIP6_FMT ", %d}", NIP6(sin->sin6_addr), |
| 759 |
_stp_ntohs(sin->sin6_port)); |
| 760 |
#endif |
| 761 |
return; |
| 762 |
} |
| 763 |
|
| 764 |
if (what & SA_FAMILY) |
| 765 |
{ |
| 766 |
n = strlcpy(stap_retvalue, "AF_INET6", maxstringlen); |
| 767 |
// (n - 1) mean: cut of null char |
| 768 |
stap_retvalue += (n); |
| 769 |
maxstringlen -= (n - 1); |
| 770 |
} |
| 771 |
|
| 772 |
if (what & SA_IP_ADDR) |
| 773 |
{ |
| 774 |
#ifndef NIP6_FMT // kver >= 2.6.36 |
| 775 |
n = snprintf(stap_retvalue, maxstringlen, |
| 776 |
"%pI6", &sin->sin6_addr); |
| 777 |
#else |
| 778 |
n = snprintf(stap_retvalue, maxstringlen, |
| 779 |
NIP6_FMT, NIP6(sin->sin6_addr)); |
| 780 |
#endif |
| 781 |
// (n - 1) mean: cut of null char |
| 782 |
stap_retvalue += (n); |
| 783 |
maxstringlen -= (n - 1); |
| 784 |
} |
| 785 |
|
| 786 |
if (what & SA_TCP_PORT) |
| 787 |
{ |
| 788 |
n = snprintf(stap_retvalue, maxstringlen, |
| 789 |
"%d", _stp_ntohs(sin->sin6_port)); |
| 790 |
// (n - 1) mean: cut of null char |
| 791 |
stap_retvalue += (n); |
| 792 |
maxstringlen -= (n - 1); |
| 793 |
} |
| 794 |
|
| 795 |
if (what & SA_IPV6_FLOWINFO) |
| 796 |
{ |
| 797 |
n = snprintf(stap_retvalue, maxstringlen, |
| 798 |
"%d", sin->sin6_flowinfo); |
| 799 |
// (n - 1) mean: cut of null char |
| 800 |
stap_retvalue += (n); |
| 801 |
maxstringlen -= (n - 1); |
| 802 |
} |
| 803 |
|
| 804 |
if (what & SA_IPV6_SCOPE_ID) |
| 805 |
{ |
| 806 |
n = snprintf(stap_retvalue, maxstringlen, |
| 807 |
"%d", sin->sin6_flowinfo); |
| 808 |
// (n - 1) mean: cut of null char |
| 809 |
stap_retvalue += (n); |
| 810 |
maxstringlen -= (n - 1); |
| 811 |
} |
| 812 |
} |
| 813 |
else if ((sa->sa_family == AF_PACKET) |
| 814 |
&& (len == sizeof(struct sockaddr_ll))) |
| 815 |
{ |
| 816 |
struct sockaddr_ll *sll = (struct sockaddr_ll *)CONTEXT->buf; |
| 817 |
|
| 818 |
if (what & SA_PRETTY) |
| 819 |
{ |
| 820 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 821 |
"{AF_PACKET, proto=%d, ind=%d, hatype=%d, pkttype=%d, halen=%d, addr=0x%llx}", |
| 822 |
(int)sll->sll_protocol, sll->sll_ifindex, |
| 823 |
(int)sll->sll_hatype, (int)sll->sll_pkttype, |
| 824 |
(int)sll->sll_halen, |
| 825 |
(long long)(*(uint64_t *)sll->sll_addr)); |
| 826 |
} else if (what & SA_FAMILY) |
| 827 |
{ |
| 828 |
strlcpy(STAP_RETVALUE, "AF_PACKET", MAXSTRINGLEN); |
| 829 |
} else |
| 830 |
{ |
| 831 |
strlcpy(STAP_RETVALUE, "", MAXSTRINGLEN); |
| 832 |
} |
| 833 |
} |
| 834 |
else |
| 835 |
{ |
| 836 |
if (len >= sizeof(sa_family_t)) |
| 837 |
{ |
| 838 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 839 |
"{unknown sockaddr with sa=%d, salen=%d}", |
| 840 |
sa->sa_family, (int) len); |
| 841 |
} |
| 842 |
else |
| 843 |
{ |
| 844 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 845 |
"{unknown sockaddr with salen=%d}", (int)len); |
| 846 |
} |
| 847 |
} |
| 848 |
%} |
| 849 |
|
| 850 |
function _struct_rlimit_u:string(uaddr:long) |
| 851 |
%{ /* pure */ |
| 852 |
struct rlimit rl; |
| 853 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 854 |
|
| 855 |
if (ptr == NULL) |
| 856 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 857 |
else { |
| 858 |
if (_stp_copy_from_user((char *)&rl, ptr, sizeof(struct rlimit)) == 0) |
| 859 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "[%ld,%ld]", |
| 860 |
rl.rlim_cur, rl.rlim_max); |
| 861 |
else |
| 862 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 863 |
(unsigned long)ptr); |
| 864 |
} |
| 865 |
%} |
| 866 |
|
| 867 |
function _fildes_index_u:long (uaddr:long, index:long) |
| 868 |
%{ /* pure */ |
| 869 |
int fd[2]; |
| 870 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 871 |
|
| 872 |
if (ptr == NULL || !(STAP_ARG_index == 0 || STAP_ARG_index == 1)) |
| 873 |
STAP_RETVALUE = 0; |
| 874 |
else { |
| 875 |
if (_stp_copy_from_user((char *)&fd, ptr, 2*sizeof(int)) == 0) |
| 876 |
STAP_RETVALUE = fd[STAP_ARG_index]; |
| 877 |
else |
| 878 |
STAP_RETVALUE = 0; |
| 879 |
} |
| 880 |
%} |
| 881 |
|
| 882 |
|
| 883 |
function __sem_flags:string(semflg:long) |
| 884 |
%{ /* pure */ /* unprivileged */ |
| 885 |
long semflg = STAP_ARG_semflg; |
| 886 |
char *str = STAP_RETVALUE; |
| 887 |
int mode; |
| 888 |
int len; |
| 889 |
int flag = 0; |
| 890 |
|
| 891 |
mode = semflg & S_IRWXUGO; |
| 892 |
semflg &= ~S_IRWXUGO; |
| 893 |
|
| 894 |
str[0] = '\0'; |
| 895 |
if (semflg & IPC_CREAT) { |
| 896 |
strlcat(str, "IPC_CREAT", MAXSTRINGLEN); |
| 897 |
semflg &= ~IPC_CREAT; |
| 898 |
flag = 1; |
| 899 |
} |
| 900 |
if (semflg & IPC_EXCL) { |
| 901 |
if (flag) |
| 902 |
strlcat(str, "|", MAXSTRINGLEN); |
| 903 |
strlcat(str, "IPC_EXCL", MAXSTRINGLEN); |
| 904 |
semflg &= ~IPC_EXCL; |
| 905 |
flag = 1; |
| 906 |
} |
| 907 |
if (semflg) { |
| 908 |
if (flag) |
| 909 |
strlcat(str, "|", MAXSTRINGLEN); |
| 910 |
len = strlen(str); |
| 911 |
_stp_snprintf(str + len, MAXSTRINGLEN - len, "0x%lx", semflg); |
| 912 |
flag = 1; |
| 913 |
} |
| 914 |
if (mode) { |
| 915 |
if (flag) |
| 916 |
strlcat(str, "|", MAXSTRINGLEN); |
| 917 |
len = strlen(str); |
| 918 |
_stp_snprintf(str + len, MAXSTRINGLEN - len, "%#o", mode); |
| 919 |
} |
| 920 |
%} |
| 921 |
|
| 922 |
%(systemtap_v <= "3.2" %? |
| 923 |
@__private30 function __user_pointer:long (addr:long) |
| 924 |
{ |
| 925 |
return user_long_error(addr) |
| 926 |
} |
| 927 |
%) |
| 928 |
|
| 929 |
/* This function copies an argv from userspace. */ |
| 930 |
function __get_argv:string(argv:long, first:long) |
| 931 |
{ |
| 932 |
%( CONFIG_64BIT == "y" %? |
| 933 |
str = "[" |
| 934 |
if (first && argv) |
| 935 |
# 8 == sizeof(long) on a 64-bit OS |
| 936 |
argv += (8 * first) |
| 937 |
while (argv) { |
| 938 |
try { |
| 939 |
vstr = user_long_error(argv) |
| 940 |
} catch { |
| 941 |
if (len) |
| 942 |
str .= ", " |
| 943 |
str .= sprintf("0x%x", argv) |
| 944 |
break |
| 945 |
} |
| 946 |
if (vstr == 0) |
| 947 |
break |
| 948 |
|
| 949 |
if (len) |
| 950 |
str .= ", " |
| 951 |
str .= user_string_quoted(vstr) |
| 952 |
|
| 953 |
newlen = strlen(str) |
| 954 |
if (newlen == len) |
| 955 |
break |
| 956 |
len = newlen |
| 957 |
# 8 == sizeof(long) on a 64-bit OS |
| 958 |
argv += 8 |
| 959 |
} |
| 960 |
str .= "]" |
| 961 |
return str |
| 962 |
%: |
| 963 |
return __get_compat_argv(argv, first) |
| 964 |
%) |
| 965 |
} |
| 966 |
|
| 967 |
/* This function copies an argv from userspace. */ |
| 968 |
function __get_compat_argv:string(argv:long, first:long) |
| 969 |
{ |
| 970 |
str = "[" |
| 971 |
if (first && argv) |
| 972 |
# 4 == sizeof(long) on a 32-bit OS |
| 973 |
argv += (4 * first) |
| 974 |
while (argv) { |
| 975 |
try { |
| 976 |
vstr = user_long_error(argv) & 0xffffffff |
| 977 |
} catch { |
| 978 |
if (len) |
| 979 |
str .= ", " |
| 980 |
str .= sprintf("0x%x", argv) |
| 981 |
break |
| 982 |
} |
| 983 |
if (vstr == 0) |
| 984 |
break |
| 985 |
|
| 986 |
if (len) |
| 987 |
str .= ", " |
| 988 |
str .= user_string_quoted(vstr) |
| 989 |
|
| 990 |
newlen = strlen(str) |
| 991 |
if (newlen == len) |
| 992 |
break |
| 993 |
len = newlen |
| 994 |
# 4 == sizeof(long) on a 32-bit OS |
| 995 |
argv += 4 |
| 996 |
} |
| 997 |
str .= "]" |
| 998 |
return str |
| 999 |
} |
| 1000 |
|
| 1001 |
%( systemtap_v <= "3.2" %? |
| 1002 |
/* |
| 1003 |
* The __count_envp() and __count_compat_envp() functions aren't |
| 1004 |
* used anywhere, so let's deprecate them. |
| 1005 |
*/ |
| 1006 |
|
| 1007 |
/* Count the number of environment variables. */ |
| 1008 |
function __count_envp:string(envp:long) |
| 1009 |
{ |
| 1010 |
%( CONFIG_64BIT == "y" %? |
| 1011 |
__argc = 0 |
| 1012 |
while (envp) { |
| 1013 |
# We can call 'user_long(envp)' here because we don't |
| 1014 |
# need to know the difference between a bad address |
| 1015 |
# and just getting a 0. |
| 1016 |
vstr = user_long(envp) |
| 1017 |
if (vstr == 0) |
| 1018 |
break |
| 1019 |
|
| 1020 |
__argc++ |
| 1021 |
# 8 == sizeof(long) on a 64-bit OS |
| 1022 |
envp += 8 |
| 1023 |
} |
| 1024 |
return sprintf("[/* %d var%s */]", __argc, __argc != 1 ? "s" : "") |
| 1025 |
%: |
| 1026 |
return __count_compat_envp(envp) |
| 1027 |
%) |
| 1028 |
} |
| 1029 |
|
| 1030 |
function __count_compat_envp:string(envp:long) |
| 1031 |
{ |
| 1032 |
__argc = 0 |
| 1033 |
while (envp) { |
| 1034 |
# We can call 'user_long(envp)' here because we don't |
| 1035 |
# need to know the difference between a bad address |
| 1036 |
# and just getting a 0. |
| 1037 |
vstr = user_long(envp) |
| 1038 |
if (vstr == 0) |
| 1039 |
break |
| 1040 |
|
| 1041 |
__argc++ |
| 1042 |
# 4 == sizeof(long) on a 32-bit OS |
| 1043 |
envp += 4 |
| 1044 |
} |
| 1045 |
return sprintf("[/* %d var%s */]", __argc, __argc != 1 ? "s" : "") |
| 1046 |
} |
| 1047 |
%) |
| 1048 |
|
| 1049 |
%(systemtap_v <= "2.7" %? |
| 1050 |
/* |
| 1051 |
* This function isn't actually used anywhere, so let's deprecate it. |
| 1052 |
* |
| 1053 |
* Return the symbolic string representation |
| 1054 |
* of the struct timex.mode member of adjtimex |
| 1055 |
* consult `man adjtimex` for more information |
| 1056 |
* CALLERS: |
| 1057 |
* syscall.adjtimex |
| 1058 |
*/ |
| 1059 |
function _adjtx_mode_str(f) { |
| 1060 |
if((f & 32769) == 32769) bs="ADJ_OFFSET_SINGLESHOT|".bs |
| 1061 |
if(f & 16384) bs="ADJ_TICK|".bs |
| 1062 |
if(f & 32) bs="ADJ_TIMECONST|".bs |
| 1063 |
if(f & 16) bs="ADJ_STATUS|".bs |
| 1064 |
if(f & 8) bs="ADJ_ESTERROR|".bs |
| 1065 |
if(f & 4) bs="ADJ_MAXERROR|".bs |
| 1066 |
if(f & 2) bs="ADJ_FREQUENCY|".bs |
| 1067 |
if(f & 1 && ((f & 32769) != 32769)) bs="ADJ_OFFSET|".bs |
| 1068 |
return substr(bs,0,strlen(bs)-1) |
| 1069 |
} |
| 1070 |
%) |
| 1071 |
|
| 1072 |
%{ |
| 1073 |
#include <linux/random.h> |
| 1074 |
|
| 1075 |
static const _stp_val_array _stp_getrandom_list[] = { |
| 1076 |
#ifdef GRND_NONBLOCK |
| 1077 |
V(GRND_NONBLOCK), |
| 1078 |
#endif |
| 1079 |
#ifdef GRND_RANDOM |
| 1080 |
V(GRND_RANDOM), |
| 1081 |
#endif |
| 1082 |
{0, NULL} |
| 1083 |
}; |
| 1084 |
%} |
| 1085 |
|
| 1086 |
function _getrandom_flags_str:string(flag:long) |
| 1087 |
%{ /* pure */ /* unprivileged */ |
| 1088 |
unsigned int grflag = (unsigned int)STAP_ARG_flag; |
| 1089 |
_stp_lookup_or_str(_stp_getrandom_list, grflag, STAP_RETVALUE, MAXSTRINGLEN); |
| 1090 |
%} |
| 1091 |
|
| 1092 |
%{ |
| 1093 |
#if (defined(CONFIG_INOTIFY) || defined(CONFIG_INOTIFY_USER)) |
| 1094 |
#include <linux/inotify.h> |
| 1095 |
#endif |
| 1096 |
|
| 1097 |
/* Ignore helper events IN_CLOSE and IN_MOVE, which are just |
| 1098 |
* combinations of other events. */ |
| 1099 |
|
| 1100 |
static const _stp_val_array _stp_inotify_watch_mask_list[] = { |
| 1101 |
V(IN_ACCESS), |
| 1102 |
V(IN_MODIFY), |
| 1103 |
V(IN_ATTRIB), |
| 1104 |
V(IN_CLOSE_WRITE), |
| 1105 |
V(IN_CLOSE_NOWRITE), |
| 1106 |
V(IN_OPEN), |
| 1107 |
V(IN_MOVED_FROM), |
| 1108 |
V(IN_MOVED_TO), |
| 1109 |
V(IN_CREATE), |
| 1110 |
V(IN_DELETE), |
| 1111 |
V(IN_DELETE_SELF), |
| 1112 |
V(IN_MOVE_SELF), |
| 1113 |
V(IN_UNMOUNT), |
| 1114 |
V(IN_Q_OVERFLOW), |
| 1115 |
V(IN_IGNORED), |
| 1116 |
V(IN_ONLYDIR), |
| 1117 |
V(IN_DONT_FOLLOW), |
| 1118 |
#ifdef IN_EXCL_UNLINK |
| 1119 |
V(IN_EXCL_UNLINK), |
| 1120 |
#endif |
| 1121 |
V(IN_MASK_ADD), |
| 1122 |
V(IN_ISDIR), |
| 1123 |
V(IN_ONESHOT), |
| 1124 |
{0, NULL} |
| 1125 |
}; |
| 1126 |
%} |
| 1127 |
|
| 1128 |
function _inotify_watch_mask_str:string(mask:long) |
| 1129 |
%{ /* pure */ /* unprivileged */ |
| 1130 |
uint32_t mask = (uint32_t)STAP_ARG_mask; |
| 1131 |
_stp_lookup_or_str(_stp_inotify_watch_mask_list, mask, STAP_RETVALUE, |
| 1132 |
MAXSTRINGLEN); |
| 1133 |
%} |
| 1134 |
|
| 1135 |
/* |
| 1136 |
* Return the symbolic string representation |
| 1137 |
* of the how argument given in *sigprocmask |
| 1138 |
* consult `man sigprocmask` for more info |
| 1139 |
* CALLERS: |
| 1140 |
* syscall.sigprocmask |
| 1141 |
* syscall.rt_sigprocmask |
| 1142 |
*/ |
| 1143 |
function _sigprocmask_how_str:string(how:long) |
| 1144 |
%{ /* pure */ /* unprivileged */ |
| 1145 |
int len; |
| 1146 |
char *str = STAP_RETVALUE; |
| 1147 |
switch (STAP_ARG_how) { |
| 1148 |
case SIG_BLOCK: |
| 1149 |
strlcpy(str, "SIG_BLOCK", MAXSTRINGLEN); |
| 1150 |
break; |
| 1151 |
case SIG_UNBLOCK: |
| 1152 |
strlcpy(str, "SIG_UNBLOCK", MAXSTRINGLEN); |
| 1153 |
break; |
| 1154 |
case SIG_SETMASK: |
| 1155 |
strlcpy(str, "SIG_SETMASK", MAXSTRINGLEN); |
| 1156 |
break; |
| 1157 |
default: |
| 1158 |
snprintf(str, MAXSTRINGLEN, "0x%lx", (long)STAP_ARG_how); |
| 1159 |
} |
| 1160 |
%} |
| 1161 |
|
| 1162 |
/* |
| 1163 |
* Return the symbolic string representation |
| 1164 |
* of the which argument given to setitimer |
| 1165 |
* consult `man setitimer` for more info |
| 1166 |
* CALLERS: |
| 1167 |
* syscall.getitimer |
| 1168 |
* syscall.setitimer |
| 1169 |
* INCLUDE: <linux/time.h> |
| 1170 |
*/ |
| 1171 |
%{ |
| 1172 |
#include <linux/time.h> |
| 1173 |
static const _stp_val_array _stp_itimer_which_list[] = { |
| 1174 |
V(ITIMER_REAL), |
| 1175 |
V(ITIMER_VIRTUAL), |
| 1176 |
V(ITIMER_PROF), |
| 1177 |
{0, NULL} |
| 1178 |
}; |
| 1179 |
%} |
| 1180 |
function _itimer_which_str:string(which:long) |
| 1181 |
%{ /* pure */ /* unprivileged */ |
| 1182 |
_stp_lookup_str(_stp_itimer_which_list, (unsigned int)STAP_ARG_which, |
| 1183 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1184 |
%} |
| 1185 |
|
| 1186 |
/* |
| 1187 |
* Return the command name for nfsservctl() |
| 1188 |
* nfsservctl was removed in kernel 3.0/2.6.40. |
| 1189 |
*/ |
| 1190 |
%( kernel_v < "2.6.40" && CONFIG_NFSD == "[ym]" %? |
| 1191 |
%{ |
| 1192 |
#include <linux/sunrpc/svc.h> |
| 1193 |
#include <linux/nfsd/nfsfh.h> |
| 1194 |
#include <linux/nfsd/syscall.h> |
| 1195 |
static const _stp_val_array _stp_nfsctl_cmd_list[] = { |
| 1196 |
V(NFSCTL_SVC), |
| 1197 |
V(NFSCTL_ADDCLIENT), |
| 1198 |
V(NFSCTL_DELCLIENT), |
| 1199 |
V(NFSCTL_EXPORT), |
| 1200 |
V(NFSCTL_UNEXPORT), |
| 1201 |
#ifdef NFSCTL_UGIDUPDATE |
| 1202 |
V(NFSCTL_UGIDUPDATE), |
| 1203 |
#endif |
| 1204 |
#ifdef NFSCTL_GETFH |
| 1205 |
V(NFSCTL_GETFH), |
| 1206 |
#endif |
| 1207 |
V(NFSCTL_GETFD), |
| 1208 |
V(NFSCTL_GETFS), |
| 1209 |
{0, NULL} |
| 1210 |
}; |
| 1211 |
%} |
| 1212 |
|
| 1213 |
function _nfsctl_cmd_str:string(cmd:long) |
| 1214 |
%{ /* pure */ /* unprivileged */ |
| 1215 |
_stp_lookup_str(_stp_nfsctl_cmd_list, (unsigned int)STAP_ARG_cmd, |
| 1216 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1217 |
%} |
| 1218 |
%) |
| 1219 |
|
| 1220 |
/* |
| 1221 |
* Return the symbolic string representation |
| 1222 |
* of the clockid argument given to create_timer |
| 1223 |
* consult `man create_timer` for more info |
| 1224 |
* CALLERS: |
| 1225 |
* syscall.timer_create |
| 1226 |
* syscall.clock_settime |
| 1227 |
* syscall.clock_gettime |
| 1228 |
* syscall.clock_getres |
| 1229 |
* syscall.clock_nanosleep |
| 1230 |
*/ |
| 1231 |
%{ |
| 1232 |
#include <linux/time.h> |
| 1233 |
|
| 1234 |
static const _stp_val_array _stp_wc_str_list[] = { |
| 1235 |
V(CLOCK_REALTIME), |
| 1236 |
V(CLOCK_MONOTONIC), |
| 1237 |
V(CLOCK_PROCESS_CPUTIME_ID), |
| 1238 |
V(CLOCK_THREAD_CPUTIME_ID), |
| 1239 |
#ifdef CLOCK_MONOTONIC_RAW |
| 1240 |
V(CLOCK_MONOTONIC_RAW), |
| 1241 |
#endif |
| 1242 |
#ifdef CLOCK_REALTIME_COARSE |
| 1243 |
V(CLOCK_REALTIME_COARSE), |
| 1244 |
#endif |
| 1245 |
#ifdef CLOCK_MONOTONIC_COARSE |
| 1246 |
V(CLOCK_MONOTONIC_COARSE), |
| 1247 |
#endif |
| 1248 |
#ifdef CLOCK_BOOTTIME |
| 1249 |
V(CLOCK_BOOTTIME), |
| 1250 |
#endif |
| 1251 |
#ifdef CLOCK_REALTIME_ALARM |
| 1252 |
V(CLOCK_REALTIME_ALARM), |
| 1253 |
#endif |
| 1254 |
#ifdef CLOCK_BOOTTIME_ALARM |
| 1255 |
V(CLOCK_BOOTTIME_ALARM), |
| 1256 |
#endif |
| 1257 |
V(CLOCK_SGI_CYCLE), |
| 1258 |
#ifdef CLOCK_TAI |
| 1259 |
V(CLOCK_TAI), |
| 1260 |
#endif |
| 1261 |
{0, NULL} |
| 1262 |
}; |
| 1263 |
%} |
| 1264 |
|
| 1265 |
function _get_wc_str:string(wc:long) |
| 1266 |
%{ /* pure */ /* unprivileged */ |
| 1267 |
unsigned int clkid = (unsigned int)STAP_ARG_wc; |
| 1268 |
_stp_lookup_str(_stp_wc_str_list, clkid, STAP_RETVALUE, MAXSTRINGLEN); |
| 1269 |
%} |
| 1270 |
|
| 1271 |
%{ |
| 1272 |
#include <linux/fcntl.h> |
| 1273 |
|
| 1274 |
static const _stp_val_array _stp_flock_cmd_list[] = { |
| 1275 |
V(LOCK_SH), |
| 1276 |
V(LOCK_EX), |
| 1277 |
V(LOCK_NB), |
| 1278 |
V(LOCK_UN), |
| 1279 |
V(LOCK_MAND), |
| 1280 |
V(LOCK_READ), |
| 1281 |
V(LOCK_WRITE), |
| 1282 |
V(LOCK_RW), |
| 1283 |
{0, NULL} |
| 1284 |
}; |
| 1285 |
|
| 1286 |
static const _stp_val_array _stp_pipe2_flags_list[] = { |
| 1287 |
#ifdef O_NONBLOCK |
| 1288 |
V(O_NONBLOCK), |
| 1289 |
#endif |
| 1290 |
#ifdef O_CLOEXEC |
| 1291 |
V(O_CLOEXEC), |
| 1292 |
#endif |
| 1293 |
#ifdef O_DIRECT |
| 1294 |
V(O_DIRECT), |
| 1295 |
#endif |
| 1296 |
{0, NULL} |
| 1297 |
}; |
| 1298 |
%} |
| 1299 |
|
| 1300 |
function _flock_cmd_str:string(c:long) |
| 1301 |
%{ /* pure */ /* unprivileged */ |
| 1302 |
_stp_lookup_or_str(_stp_flock_cmd_list, (unsigned int)STAP_ARG_c, |
| 1303 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1304 |
%} |
| 1305 |
|
| 1306 |
/* `man 2 pipe2` for more information */ |
| 1307 |
function _sys_pipe2_flag_str:string (f:long) |
| 1308 |
%{ /* pure */ /* unprivileged */ |
| 1309 |
unsigned int flags = STAP_ARG_f; |
| 1310 |
|
| 1311 |
_stp_lookup_or_str(_stp_pipe2_flags_list, flags, STAP_RETVALUE, |
| 1312 |
MAXSTRINGLEN); |
| 1313 |
%} |
| 1314 |
|
| 1315 |
%{ |
| 1316 |
#include <linux/fcntl.h> |
| 1317 |
|
| 1318 |
static const _stp_val_array _stp_open_mode_flags_list[] = { |
| 1319 |
#ifdef O_CREAT |
| 1320 |
V(O_CREAT), |
| 1321 |
#endif |
| 1322 |
#ifdef O_EXCL |
| 1323 |
V(O_EXCL), |
| 1324 |
#endif |
| 1325 |
#ifdef O_NOCTTY |
| 1326 |
V(O_NOCTTY), |
| 1327 |
#endif |
| 1328 |
#ifdef O_TRUNC |
| 1329 |
V(O_TRUNC), |
| 1330 |
#endif |
| 1331 |
#ifdef O_APPEND |
| 1332 |
V(O_APPEND), |
| 1333 |
#endif |
| 1334 |
#ifdef O_NONBLOCK |
| 1335 |
V(O_NONBLOCK), |
| 1336 |
#endif |
| 1337 |
|
| 1338 |
/* Here's a comment from the kernel source: |
| 1339 |
* |
| 1340 |
* ==== |
| 1341 |
* Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using |
| 1342 |
* the O_SYNC flag. We continue to use the existing numerical value |
| 1343 |
* for O_DSYNC semantics now, but using the correct symbolic name for it. |
| 1344 |
* This new value is used to request true Posix O_SYNC semantics. It is |
| 1345 |
* defined in this strange way to make sure applications compiled against |
| 1346 |
* new headers get at least O_DSYNC semantics on older kernels. |
| 1347 |
* ==== |
| 1348 |
* |
| 1349 |
* On RHEL6 (2.6.32-431.3.1.el6.x86_64), the user headers are ahead of |
| 1350 |
* the kernel source and define O_DSYNC, but the kernel just ignores |
| 1351 |
* the extra bit set. We'll try to handle it here. |
| 1352 |
*/ |
| 1353 |
#ifndef O_DSYNC |
| 1354 |
{ O_SYNC | 04000000, "O_SYNC" }, |
| 1355 |
#endif |
| 1356 |
#ifdef O_SYNC |
| 1357 |
V(O_SYNC), |
| 1358 |
#endif |
| 1359 |
#ifdef O_DSYNC |
| 1360 |
V(O_DSYNC), |
| 1361 |
#endif |
| 1362 |
#ifdef O_ASYNC |
| 1363 |
V(O_ASYNC), |
| 1364 |
#elif defined(FASYNC) |
| 1365 |
{ FASYNC, "O_ASYNC" }, |
| 1366 |
#endif |
| 1367 |
#ifdef O_DIRECT |
| 1368 |
V(O_DIRECT), |
| 1369 |
#endif |
| 1370 |
#ifdef O_LARGEFILE |
| 1371 |
V(O_LARGEFILE), |
| 1372 |
#endif |
| 1373 |
#ifdef O_DIRECTORY |
| 1374 |
V(O_DIRECTORY), |
| 1375 |
#endif |
| 1376 |
#ifdef O_NOFOLLOW |
| 1377 |
V(O_NOFOLLOW), |
| 1378 |
#endif |
| 1379 |
#ifdef O_NOATIME |
| 1380 |
V(O_NOATIME), |
| 1381 |
#endif |
| 1382 |
#ifdef O_CLOEXEC |
| 1383 |
V(O_CLOEXEC), |
| 1384 |
#endif |
| 1385 |
#ifdef O_PATH |
| 1386 |
V(O_PATH), |
| 1387 |
#endif |
| 1388 |
{0, NULL} |
| 1389 |
}; |
| 1390 |
%} |
| 1391 |
|
| 1392 |
/* `man 2 open` for more information */ |
| 1393 |
function _sys_open_flag_str:string (f:long) |
| 1394 |
%{ /* pure */ /* unprivileged */ |
| 1395 |
int flags = (int)STAP_ARG_f; |
| 1396 |
int acc = flags & O_ACCMODE; |
| 1397 |
|
| 1398 |
switch (acc) { |
| 1399 |
case O_WRONLY: |
| 1400 |
strlcpy (STAP_RETVALUE, "O_WRONLY", MAXSTRINGLEN); |
| 1401 |
break; |
| 1402 |
case O_RDWR: |
| 1403 |
strlcpy (STAP_RETVALUE, "O_RDWR", MAXSTRINGLEN); |
| 1404 |
break; |
| 1405 |
default: |
| 1406 |
strlcpy (STAP_RETVALUE, "O_RDONLY", MAXSTRINGLEN); |
| 1407 |
} |
| 1408 |
|
| 1409 |
flags &= ~O_ACCMODE; |
| 1410 |
if (flags) { |
| 1411 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 1412 |
_stp_lookup_or_str(_stp_open_mode_flags_list, flags, |
| 1413 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1414 |
} |
| 1415 |
%} |
| 1416 |
|
| 1417 |
%{ |
| 1418 |
/* Notice that the kernel defines and the user defines are named |
| 1419 |
* differently. */ |
| 1420 |
static const _stp_val_array _stp_access_mode_list[] = { |
| 1421 |
{0, "F_OK"}, |
| 1422 |
{MAY_READ, "R_OK"}, |
| 1423 |
{MAY_WRITE, "W_OK"}, |
| 1424 |
{MAY_EXEC, "X_OK"}, |
| 1425 |
{0, NULL} |
| 1426 |
}; |
| 1427 |
%} |
| 1428 |
|
| 1429 |
/* `man 2 open` for more information */ |
| 1430 |
function _access_mode_str:string(mode:long) |
| 1431 |
%{ /* pure */ /* unprivileged */ |
| 1432 |
unsigned int mode = (unsigned int)STAP_ARG_mode; |
| 1433 |
_stp_lookup_or_str(_stp_access_mode_list, mode, STAP_RETVALUE, |
| 1434 |
MAXSTRINGLEN); |
| 1435 |
%} |
| 1436 |
|
| 1437 |
%{ |
| 1438 |
static const _stp_val_array _stp_faccessat2_flags_list[] = { |
| 1439 |
{0x100, "AT_SYMLINK_NOFOLLOW"}, |
| 1440 |
{0x200, "AT_EACCESS"}, |
| 1441 |
{0, NULL} |
| 1442 |
}; |
| 1443 |
%} |
| 1444 |
|
| 1445 |
function _faccessat2_flags_str:string(flags:long) |
| 1446 |
%{ /* pure */ /* unprivileged */ |
| 1447 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 1448 |
_stp_lookup_or_str(_stp_faccessat2_flags_list, flags, STAP_RETVALUE, |
| 1449 |
MAXSTRINGLEN); |
| 1450 |
%} |
| 1451 |
|
| 1452 |
|
| 1453 |
/* `man 2 open` for more information */ |
| 1454 |
@__private30 function _sys_open_mode_str(f) |
| 1455 |
{ |
| 1456 |
if ((f & @const("S_IRWXU")) |
| 1457 |
== @const("S_IRWXU")) bs="S_IRWXU|".bs |
| 1458 |
else { |
| 1459 |
if (f & @const("S_IRUSR")) bs="S_IRUSR|" . bs |
| 1460 |
if (f & @const("S_IWUSR")) bs="S_IWUSR|" . bs |
| 1461 |
if (f & @const("S_IXUSR")) bs="S_IXUSR|" . bs |
| 1462 |
} |
| 1463 |
if ((f & @const("S_IRWXG")) |
| 1464 |
== @const("S_IRWXG")) bs="S_IRWXG|" . bs |
| 1465 |
else { |
| 1466 |
if (f & @const("S_IRGRP")) bs="S_IRGRP|" . bs |
| 1467 |
if (f & @const("S_IWGRP")) bs="S_IWGRP|" . bs |
| 1468 |
if (f & @const("S_IXGRP")) bs="S_IXGRP|" . bs |
| 1469 |
} |
| 1470 |
if ((f & @const("S_IRWXO")) |
| 1471 |
== @const("S_IRWXO")) bs="S_IRWXO|" . bs |
| 1472 |
else { |
| 1473 |
if (f & @const("S_IROTH")) bs="S_IROTH|" . bs |
| 1474 |
if (f & @const("S_IWOTH")) bs="S_IWOTH|" . bs |
| 1475 |
if (f & @const("S_IXOTH")) bs="S_IXOTH|" . bs |
| 1476 |
} |
| 1477 |
return (strlen(bs) > 0) ? substr(bs, 0, strlen(bs) - 1) : sprintf("%#o", f) |
| 1478 |
} |
| 1479 |
|
| 1480 |
/* `man 2 mknod` for more information */ |
| 1481 |
function _mknod_mode_str:string(mode:long) |
| 1482 |
{ |
| 1483 |
type = mode & @const("S_IFMT") |
| 1484 |
mode &= ~@const("S_IFMT") |
| 1485 |
if (type == @const("S_IFREG")) |
| 1486 |
return sprintf("S_IFREG|%#o", mode) |
| 1487 |
if (type == @const("S_IFCHR")) |
| 1488 |
return sprintf("S_IFCHR|%#o", mode) |
| 1489 |
if (type == @const("S_IFBLK")) |
| 1490 |
return sprintf("S_IFBLK|%#o", mode) |
| 1491 |
if (type == @const("S_IFIFO")) |
| 1492 |
return sprintf("S_IFIFO|%#o", mode) |
| 1493 |
if (type == @const("S_IFSOCK")) |
| 1494 |
return sprintf("S_IFSOCK|%#o", mode) |
| 1495 |
return sprintf("%#o", type | mode) |
| 1496 |
} |
| 1497 |
|
| 1498 |
%{ |
| 1499 |
#include <linux/mman.h> |
| 1500 |
|
| 1501 |
static const _stp_val_array _stp_msync_flag_list[] = { |
| 1502 |
V(MS_ASYNC), |
| 1503 |
V(MS_INVALIDATE), |
| 1504 |
V(MS_SYNC), |
| 1505 |
{0, NULL} |
| 1506 |
}; |
| 1507 |
%} |
| 1508 |
|
| 1509 |
/* `man msync` for more information */ |
| 1510 |
function _msync_flag_str:string(f:long) |
| 1511 |
%{ /* pure */ /* unprivileged */ |
| 1512 |
uint32_t flags = (uint32_t)STAP_ARG_f; |
| 1513 |
_stp_lookup_or_str(_stp_msync_flag_list, flags, STAP_RETVALUE, |
| 1514 |
MAXSTRINGLEN); |
| 1515 |
%} |
| 1516 |
|
| 1517 |
%{ |
| 1518 |
#include <uapi/linux/wait.h> |
| 1519 |
|
| 1520 |
static const _stp_val_array _stp_wait4_op_list[] = { |
| 1521 |
V(WNOHANG), |
| 1522 |
#if !defined(WSTOPPED) && defined(WUNTRACED) |
| 1523 |
V(WUNTRACED), |
| 1524 |
#endif |
| 1525 |
V(WEXITED), |
| 1526 |
#ifdef WSTOPPED |
| 1527 |
V(WSTOPPED), |
| 1528 |
#endif |
| 1529 |
V(WCONTINUED), |
| 1530 |
V(WNOWAIT), |
| 1531 |
V(__WNOTHREAD), |
| 1532 |
V(__WALL), |
| 1533 |
V(__WCLONE), |
| 1534 |
{0, NULL} |
| 1535 |
}; |
| 1536 |
|
| 1537 |
%} |
| 1538 |
|
| 1539 |
%(systemtap_v <= "2.7" %? |
| 1540 |
function _internal_wait_opt_str:string(f:long, bit_num:long, bit_str:string) |
| 1541 |
%{ /* pure */ /* unprivileged */ |
| 1542 |
/* ignore bit_num and bit_str */ |
| 1543 |
_stp_lookup_or_str(_stp_wait4_op_list, (unsigned int)STAP_ARG_f, |
| 1544 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1545 |
%} |
| 1546 |
|
| 1547 |
/* `man waitid` for more information */ |
| 1548 |
function _waitid_opt_str:string(f:long) |
| 1549 |
%{ /* pure */ /* unprivileged */ |
| 1550 |
_stp_lookup_or_str(_stp_wait4_op_list, (unsigned int)STAP_ARG_f, |
| 1551 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1552 |
%} |
| 1553 |
%) |
| 1554 |
|
| 1555 |
/* `man wait4` for more information */ |
| 1556 |
function _wait4_opt_str:string(f:long) |
| 1557 |
%{ /* pure */ /* unprivileged */ |
| 1558 |
_stp_lookup_or_str(_stp_wait4_op_list, (unsigned int)STAP_ARG_f, |
| 1559 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1560 |
%} |
| 1561 |
|
| 1562 |
function WIFEXITED(f) { |
| 1563 |
return (f & 0x7f) == 0 |
| 1564 |
} |
| 1565 |
|
| 1566 |
function WEXITSTATUS(f) { |
| 1567 |
return (f & 0xff00) >> 8 |
| 1568 |
} |
| 1569 |
|
| 1570 |
@__private30 function WIFSIGNALED(f) { |
| 1571 |
return (f & 0x7f) != 0 && (f & 0x7f) != 0x7f |
| 1572 |
} |
| 1573 |
|
| 1574 |
@__private30 function WCOREDUMP(f) { |
| 1575 |
return f & 0x80 |
| 1576 |
} |
| 1577 |
|
| 1578 |
function WTERMSIG(f) { |
| 1579 |
return f & 0x7f |
| 1580 |
} |
| 1581 |
|
| 1582 |
@__private30 function WIFSTOPPED(f) { |
| 1583 |
return (f & 0xff) == 0x7f |
| 1584 |
} |
| 1585 |
|
| 1586 |
@__private30 function WSTOPSIG(f) { |
| 1587 |
return (f & 0xff00) >> 8 |
| 1588 |
} |
| 1589 |
|
| 1590 |
@__private30 function WIFCONTINUED(f) { |
| 1591 |
return f == 0xffff |
| 1592 |
} |
| 1593 |
|
| 1594 |
@__private30 function _ptrace_event_name(f) |
| 1595 |
{ |
| 1596 |
if (f == @const("PTRACE_EVENT_FORK")) |
| 1597 |
return "PTRACE_EVENT_FORK" |
| 1598 |
if (f == @const("PTRACE_EVENT_VFORK")) |
| 1599 |
return "PTRACE_EVENT_VFORK" |
| 1600 |
if (f == @const("PTRACE_EVENT_CLONE")) |
| 1601 |
return "PTRACE_EVENT_CLONE" |
| 1602 |
if (f == @const("PTRACE_EVENT_EXEC")) |
| 1603 |
return "PTRACE_EVENT_EXEC" |
| 1604 |
if (f == @const("PTRACE_EVENT_VFORK_DONE")) |
| 1605 |
return "PTRACE_EVENT_VFORK_DONE" |
| 1606 |
if (f == @const("PTRACE_EVENT_EXIT")) |
| 1607 |
return "PTRACE_EVENT_EXIT" |
| 1608 |
return "" |
| 1609 |
} |
| 1610 |
|
| 1611 |
/* `man 2 wait` for more information */ |
| 1612 |
function _wait_status_str(f) { |
| 1613 |
if ((f >> 16) != 0) |
| 1614 |
tail = sprintf (" | 0x%x", f & ~0xffff) |
| 1615 |
else |
| 1616 |
tail = "" |
| 1617 |
|
| 1618 |
if (WIFEXITED(f)) |
| 1619 |
return sprintf ("WEXITSTATUS=%d", WEXITSTATUS(f)).tail |
| 1620 |
if (WIFSIGNALED(f)) { |
| 1621 |
if (WCOREDUMP(f)) |
| 1622 |
return "WCOREDUMP".tail |
| 1623 |
return sprintf ("WTERMSIG=%s", _signal_name(WTERMSIG(f))).tail |
| 1624 |
} |
| 1625 |
if (WIFSTOPPED(f)) |
| 1626 |
{ |
| 1627 |
if (WSTOPSIG(f) == @const("SIGTRAP")) |
| 1628 |
{ |
| 1629 |
event = _ptrace_event_name (f >> 16) |
| 1630 |
if (event != "") |
| 1631 |
tail = " | ".event." << 8" |
| 1632 |
} |
| 1633 |
return sprintf ("WSTOPSIG=%s", _signal_name(WSTOPSIG(f))).tail |
| 1634 |
} |
| 1635 |
if (WIFCONTINUED(f)) |
| 1636 |
return "WIFCONTINUED".tail |
| 1637 |
return sprintf ("?=0x%x", f) |
| 1638 |
} |
| 1639 |
|
| 1640 |
%{ |
| 1641 |
#include <linux/seccomp.h> |
| 1642 |
static const _stp_val_array _stp_seccomp_flags_list[] = { |
| 1643 |
#ifdef SECCOMP_FILTER_FLAG_TSYNC |
| 1644 |
V(SECCOMP_FILTER_FLAG_TSYNC), |
| 1645 |
#endif |
| 1646 |
{0, NULL} |
| 1647 |
}; |
| 1648 |
|
| 1649 |
static const _stp_val_array _stp_seccomp_mode_list[] = { |
| 1650 |
#ifdef SECCOMP_MODE_DISABLED |
| 1651 |
V(SECCOMP_MODE_DISABLED), |
| 1652 |
#endif |
| 1653 |
#ifdef SECCOMP_MODE_STRICT |
| 1654 |
V(SECCOMP_MODE_STRICT), |
| 1655 |
#endif |
| 1656 |
#ifdef SECCOMP_MODE_FILTER |
| 1657 |
V(SECCOMP_MODE_FILTER), |
| 1658 |
#endif |
| 1659 |
{0, NULL} |
| 1660 |
}; |
| 1661 |
%} |
| 1662 |
|
| 1663 |
function _seccomp_flags_str:string(flags:long) |
| 1664 |
%{ /* pure */ /* unprivileged */ |
| 1665 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 1666 |
_stp_lookup_str(_stp_seccomp_flags_list, flags, STAP_RETVALUE, MAXSTRINGLEN); |
| 1667 |
%} |
| 1668 |
|
| 1669 |
%{ |
| 1670 |
static const _stp_val_array _stp_msg_flags_list[] = { |
| 1671 |
V(MSG_OOB), |
| 1672 |
V(MSG_PEEK), |
| 1673 |
V(MSG_DONTROUTE), |
| 1674 |
V(MSG_TRYHARD), |
| 1675 |
V(MSG_CTRUNC), |
| 1676 |
V(MSG_PROBE), |
| 1677 |
V(MSG_TRUNC), |
| 1678 |
V(MSG_DONTWAIT), |
| 1679 |
V(MSG_EOR), |
| 1680 |
V(MSG_WAITALL), |
| 1681 |
V(MSG_FIN), |
| 1682 |
V(MSG_SYN), |
| 1683 |
V(MSG_CONFIRM), |
| 1684 |
V(MSG_RST), |
| 1685 |
V(MSG_ERRQUEUE), |
| 1686 |
V(MSG_NOSIGNAL), |
| 1687 |
V(MSG_MORE), |
| 1688 |
#ifdef MSG_WAITFORONE |
| 1689 |
V(MSG_WAITFORONE), |
| 1690 |
#endif |
| 1691 |
#ifdef MSG_SENDPAGE_NOTLAST |
| 1692 |
V(MSG_SENDPAGE_NOTLAST), |
| 1693 |
#endif |
| 1694 |
V(MSG_EOF), |
| 1695 |
#ifdef MSG_FASTOPEN |
| 1696 |
V(MSG_FASTOPEN), |
| 1697 |
#endif |
| 1698 |
#ifdef MSG_CMSG_CLOEXEC |
| 1699 |
V(MSG_CMSG_CLOEXEC), |
| 1700 |
#endif |
| 1701 |
{0, NULL} |
| 1702 |
}; |
| 1703 |
%} |
| 1704 |
|
| 1705 |
function _msg_flags_str:string(flags:long) |
| 1706 |
%{ /* pure */ /* unprivileged */ |
| 1707 |
// Ignore MSG_CMSG_COMPAT in flags. |
| 1708 |
_stp_lookup_or_str(_stp_msg_flags_list, |
| 1709 |
(STAP_ARG_flags & ~MSG_CMSG_COMPAT), STAP_RETVALUE, |
| 1710 |
MAXSTRINGLEN); |
| 1711 |
%} |
| 1712 |
|
| 1713 |
%(systemtap_v <= "2.5" %? |
| 1714 |
function _sendflags_str:string(flags:long) |
| 1715 |
{ |
| 1716 |
return _msg_flags_str(flags) |
| 1717 |
} |
| 1718 |
function _recvflags_str:string(flags:long) |
| 1719 |
{ |
| 1720 |
return _msg_flags_str(flags) |
| 1721 |
} |
| 1722 |
%) |
| 1723 |
|
| 1724 |
%{ |
| 1725 |
#ifdef __NR_memfd_create |
| 1726 |
#include <uapi/linux/memfd.h> |
| 1727 |
#endif |
| 1728 |
static const _stp_val_array _stp_mfd_flags_list[] = { |
| 1729 |
#ifdef MFD_CLOEXEC |
| 1730 |
V(MFD_CLOEXEC), |
| 1731 |
#endif |
| 1732 |
#ifdef MFD_ALLOW_SEALING |
| 1733 |
V(MFD_ALLOW_SEALING), |
| 1734 |
#endif |
| 1735 |
#ifdef O_CLOEXEC |
| 1736 |
V(O_CLOEXEC), |
| 1737 |
#endif |
| 1738 |
{0, NULL} |
| 1739 |
}; |
| 1740 |
%} |
| 1741 |
|
| 1742 |
function _mfd_flags_str:string(flags:long) |
| 1743 |
%{ /* pure */ /* unprivileged */ |
| 1744 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 1745 |
_stp_lookup_or_str(_stp_mfd_flags_list, flags, STAP_RETVALUE, MAXSTRINGLEN); |
| 1746 |
%} |
| 1747 |
|
| 1748 |
%{ |
| 1749 |
#include <linux/mman.h> |
| 1750 |
static const _stp_val_array _stp_mlock2_flags_list[] = { |
| 1751 |
#ifdef MLOCK_ONFAULT |
| 1752 |
V(MLOCK_ONFAULT), |
| 1753 |
#endif |
| 1754 |
{0, NULL} |
| 1755 |
}; |
| 1756 |
%} |
| 1757 |
/* `man mlock2` for more information */ |
| 1758 |
function _stp_mlock2_str:string(flags:long) |
| 1759 |
%{ /* pure */ /* unprivileged */ |
| 1760 |
uint32_t flags = (uint32_t)STAP_ARG_flags; |
| 1761 |
_stp_lookup_or_str(_stp_mlock2_flags_list, flags, STAP_RETVALUE, |
| 1762 |
MAXSTRINGLEN); |
| 1763 |
%} |
| 1764 |
|
| 1765 |
%{ |
| 1766 |
#include <linux/mman.h> |
| 1767 |
static const _stp_val_array _stp_mlockall_flags_list[] = { |
| 1768 |
V(MCL_CURRENT), |
| 1769 |
V(MCL_FUTURE), |
| 1770 |
#ifdef MCL_ONFAULT |
| 1771 |
V(MCL_ONFAULT), |
| 1772 |
#endif |
| 1773 |
{0, NULL} |
| 1774 |
}; |
| 1775 |
%} |
| 1776 |
/* `man mlockall` for more information */ |
| 1777 |
function _mlockall_flags_str:string(flags:long) |
| 1778 |
%{ /* pure */ /* unprivileged */ |
| 1779 |
uint32_t flags = (uint32_t)STAP_ARG_flags; |
| 1780 |
_stp_lookup_or_str(_stp_mlockall_flags_list, flags, STAP_RETVALUE, |
| 1781 |
MAXSTRINGLEN); |
| 1782 |
%} |
| 1783 |
|
| 1784 |
%{ |
| 1785 |
static const _stp_val_array _stp_module_flags_list[] = { |
| 1786 |
V(O_TRUNC), |
| 1787 |
V(O_NONBLOCK), |
| 1788 |
{0, NULL} |
| 1789 |
}; |
| 1790 |
%} |
| 1791 |
|
| 1792 |
/* used by sys_delete_module */ |
| 1793 |
function _module_flags_str:string(flags:long) |
| 1794 |
%{ /* pure */ /* unprivileged */ |
| 1795 |
_stp_lookup_or_str(_stp_module_flags_list, (unsigned int)STAP_ARG_flags, |
| 1796 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1797 |
%} |
| 1798 |
|
| 1799 |
%{ |
| 1800 |
#include <linux/sched.h> |
| 1801 |
#if defined(STAPCONF_LINUX_SCHED_HEADERS) |
| 1802 |
#include <uapi/linux/sched/types.h> |
| 1803 |
#endif |
| 1804 |
|
| 1805 |
static const _stp_val_array _stp_sched_policy_list[] = { |
| 1806 |
{SCHED_NORMAL, "SCHED_OTHER"}, // SCHED_NORMAL==SCHED_OTHER |
| 1807 |
V(SCHED_FIFO), |
| 1808 |
V(SCHED_RR), |
| 1809 |
V(SCHED_BATCH), |
| 1810 |
#ifdef SCHED_IDLE |
| 1811 |
V(SCHED_IDLE), |
| 1812 |
#endif |
| 1813 |
#ifdef SCHED_DEADLINE |
| 1814 |
V(SCHED_DEADLINE), |
| 1815 |
#endif |
| 1816 |
{0, NULL} |
| 1817 |
}; |
| 1818 |
%} |
| 1819 |
|
| 1820 |
function _sched_policy_str:string(policy:long) |
| 1821 |
%{ /* pure */ /* unprivileged */ |
| 1822 |
unsigned int policy = (unsigned int)STAP_ARG_policy; |
| 1823 |
int len; |
| 1824 |
|
| 1825 |
#ifdef SCHED_RESET_ON_FORK |
| 1826 |
if (((int)STAP_ARG_policy > 0) && (policy & SCHED_RESET_ON_FORK)) { |
| 1827 |
strlcpy(STAP_RETVALUE, "SCHED_RESET_ON_FORK|", MAXSTRINGLEN); |
| 1828 |
policy &= ~SCHED_RESET_ON_FORK; |
| 1829 |
} |
| 1830 |
#endif |
| 1831 |
len = strlen(STAP_RETVALUE); |
| 1832 |
_stp_lookup_str(_stp_sched_policy_list, policy, STAP_RETVALUE + len, |
| 1833 |
MAXSTRINGLEN - len); |
| 1834 |
%} |
| 1835 |
|
| 1836 |
%{ |
| 1837 |
static const _stp_val_array _stp_priority_which_list[] = { |
| 1838 |
V(PRIO_PROCESS), |
| 1839 |
V(PRIO_PGRP), |
| 1840 |
V(PRIO_USER), |
| 1841 |
{0, NULL} |
| 1842 |
}; |
| 1843 |
%} |
| 1844 |
|
| 1845 |
function _priority_which_str:string(which:long) |
| 1846 |
%{ /* pure */ /* unprivileged */ |
| 1847 |
_stp_lookup_str(_stp_priority_which_list, (unsigned int)STAP_ARG_which, |
| 1848 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1849 |
%} |
| 1850 |
|
| 1851 |
%{ |
| 1852 |
static const _stp_val_array _stp_shutdown_how_list[] = { |
| 1853 |
V(SHUT_RD), |
| 1854 |
V(SHUT_WR), |
| 1855 |
V(SHUT_RDWR), |
| 1856 |
{0, NULL} |
| 1857 |
}; |
| 1858 |
%} |
| 1859 |
|
| 1860 |
function _shutdown_how_str:string(how:long) |
| 1861 |
%{ /* pure */ /* unprivileged */ |
| 1862 |
_stp_lookup_str(_stp_shutdown_how_list, (unsigned int)STAP_ARG_how, |
| 1863 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1864 |
%} |
| 1865 |
|
| 1866 |
%{ |
| 1867 |
// Needed for function __reboot_magic_str:string. Unfortunately cannot |
| 1868 |
// be inlined into the function since these header file defines static |
| 1869 |
// functions on some architectures. |
| 1870 |
#include <linux/reboot.h> |
| 1871 |
|
| 1872 |
static const _stp_val_array _stp_reboot_magic_list[] = { |
| 1873 |
V(LINUX_REBOOT_MAGIC1), |
| 1874 |
V(LINUX_REBOOT_MAGIC2), |
| 1875 |
V(LINUX_REBOOT_MAGIC2A), |
| 1876 |
V(LINUX_REBOOT_MAGIC2B), |
| 1877 |
V(LINUX_REBOOT_MAGIC2C), |
| 1878 |
{0, NULL} |
| 1879 |
}; |
| 1880 |
%} |
| 1881 |
|
| 1882 |
function _reboot_magic_str:string(magic:long) |
| 1883 |
%{ /* pure */ /* unprivileged */ |
| 1884 |
unsigned int magic = (unsigned int)STAP_ARG_magic; |
| 1885 |
_stp_lookup_str(_stp_reboot_magic_list, magic, STAP_RETVALUE, |
| 1886 |
MAXSTRINGLEN); |
| 1887 |
%} |
| 1888 |
|
| 1889 |
%{ |
| 1890 |
#include <linux/reboot.h> |
| 1891 |
static const _stp_val_array _stp_reboot_flag_list[] = { |
| 1892 |
V(LINUX_REBOOT_CMD_RESTART), |
| 1893 |
V(LINUX_REBOOT_CMD_HALT), |
| 1894 |
V(LINUX_REBOOT_CMD_CAD_ON), |
| 1895 |
V(LINUX_REBOOT_CMD_CAD_OFF), |
| 1896 |
V(LINUX_REBOOT_CMD_POWER_OFF), |
| 1897 |
V(LINUX_REBOOT_CMD_RESTART2), |
| 1898 |
V(LINUX_REBOOT_CMD_SW_SUSPEND), |
| 1899 |
V(LINUX_REBOOT_CMD_KEXEC), |
| 1900 |
{0, NULL} |
| 1901 |
}; |
| 1902 |
%} |
| 1903 |
|
| 1904 |
function _reboot_flag_str:string(flag:long) |
| 1905 |
%{ /* pure */ /* unprivileged */ |
| 1906 |
unsigned int flag = (unsigned int)STAP_ARG_flag; |
| 1907 |
_stp_lookup_str(_stp_reboot_flag_list, flag, STAP_RETVALUE, |
| 1908 |
MAXSTRINGLEN); |
| 1909 |
%} |
| 1910 |
|
| 1911 |
%{ |
| 1912 |
#include <linux/wait.h> |
| 1913 |
static const _stp_val_array _stp_waitid_which_list[] = { |
| 1914 |
V(P_ALL), |
| 1915 |
V(P_PID), |
| 1916 |
V(P_PGID), |
| 1917 |
{0, NULL} |
| 1918 |
}; |
| 1919 |
%} |
| 1920 |
|
| 1921 |
function _waitid_which_str:string(flag:long) |
| 1922 |
%{ /* pure */ /* unprivileged */ |
| 1923 |
_stp_lookup_str(_stp_waitid_which_list, (unsigned int)STAP_ARG_flag, |
| 1924 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 1925 |
%} |
| 1926 |
|
| 1927 |
%{ |
| 1928 |
#include <linux/futex.h> |
| 1929 |
|
| 1930 |
// We need the following defines to have a value for the |
| 1931 |
// @__futex_argstr() macro. |
| 1932 |
#ifndef FUTEX_WAIT_BITSET |
| 1933 |
#define FUTEX_WAIT_BITSET 9 |
| 1934 |
#endif |
| 1935 |
#ifndef FUTEX_WAKE_BITSET |
| 1936 |
#define FUTEX_WAKE_BITSET 10 |
| 1937 |
#endif |
| 1938 |
#ifndef FUTEX_WAIT_REQUEUE_PI |
| 1939 |
#define FUTEX_WAIT_REQUEUE_PI 11 |
| 1940 |
#endif |
| 1941 |
#ifndef FUTEX_CMP_REQUEUE_PI |
| 1942 |
#define FUTEX_CMP_REQUEUE_PI 12 |
| 1943 |
#endif |
| 1944 |
#ifndef FUTEX_PRIVATE_FLAG |
| 1945 |
#define FUTEX_PRIVATE_FLAG 128 |
| 1946 |
#endif |
| 1947 |
#ifndef FUTEX_WAIT_BITSET_PRIVATE |
| 1948 |
#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG) |
| 1949 |
#endif |
| 1950 |
#ifndef FUTEX_WAKE_BITSET_PRIVATE |
| 1951 |
#define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG) |
| 1952 |
#endif |
| 1953 |
#ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE |
| 1954 |
#define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | \ |
| 1955 |
FUTEX_PRIVATE_FLAG) |
| 1956 |
#endif |
| 1957 |
#ifndef FUTEX_CMP_REQUEUE_PI_PRIVATE |
| 1958 |
#define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | \ |
| 1959 |
FUTEX_PRIVATE_FLAG) |
| 1960 |
#endif |
| 1961 |
|
| 1962 |
static const _stp_val_array _stp_futex_op_list[] = { |
| 1963 |
V(FUTEX_WAIT), |
| 1964 |
V(FUTEX_WAKE), |
| 1965 |
V(FUTEX_FD), |
| 1966 |
V(FUTEX_REQUEUE), |
| 1967 |
V(FUTEX_CMP_REQUEUE), |
| 1968 |
V(FUTEX_WAKE_OP), |
| 1969 |
V(FUTEX_LOCK_PI), |
| 1970 |
V(FUTEX_UNLOCK_PI), |
| 1971 |
V(FUTEX_TRYLOCK_PI), |
| 1972 |
V(FUTEX_WAIT_BITSET), |
| 1973 |
V(FUTEX_WAKE_BITSET), |
| 1974 |
V(FUTEX_WAIT_REQUEUE_PI), |
| 1975 |
V(FUTEX_CMP_REQUEUE_PI), |
| 1976 |
V(FUTEX_WAIT_PRIVATE), |
| 1977 |
V(FUTEX_WAKE_PRIVATE), |
| 1978 |
V(FUTEX_REQUEUE_PRIVATE), |
| 1979 |
V(FUTEX_CMP_REQUEUE_PRIVATE), |
| 1980 |
V(FUTEX_WAKE_OP_PRIVATE), |
| 1981 |
V(FUTEX_LOCK_PI_PRIVATE), |
| 1982 |
V(FUTEX_UNLOCK_PI_PRIVATE), |
| 1983 |
V(FUTEX_TRYLOCK_PI_PRIVATE), |
| 1984 |
V(FUTEX_WAIT_BITSET_PRIVATE), |
| 1985 |
V(FUTEX_WAKE_BITSET_PRIVATE), |
| 1986 |
V(FUTEX_WAIT_REQUEUE_PI_PRIVATE), |
| 1987 |
V(FUTEX_CMP_REQUEUE_PI_PRIVATE), |
| 1988 |
{0, NULL} |
| 1989 |
}; |
| 1990 |
|
| 1991 |
static const _stp_val_array _stp_futex_wake_ops_list[] = { |
| 1992 |
V(FUTEX_OP_SET), |
| 1993 |
V(FUTEX_OP_ADD), |
| 1994 |
V(FUTEX_OP_OR), |
| 1995 |
V(FUTEX_OP_ANDN), |
| 1996 |
V(FUTEX_OP_XOR), |
| 1997 |
{0, NULL} |
| 1998 |
}; |
| 1999 |
static const _stp_val_array _stp_futex_wake_cmps_list[] = { |
| 2000 |
V(FUTEX_OP_CMP_EQ), |
| 2001 |
V(FUTEX_OP_CMP_NE), |
| 2002 |
V(FUTEX_OP_CMP_LT), |
| 2003 |
V(FUTEX_OP_CMP_LE), |
| 2004 |
V(FUTEX_OP_CMP_GT), |
| 2005 |
V(FUTEX_OP_CMP_GE), |
| 2006 |
{0, NULL} |
| 2007 |
}; |
| 2008 |
%} |
| 2009 |
|
| 2010 |
function _futex_op_str:string(op:long) |
| 2011 |
%{ /* pure */ /* unprivileged */ |
| 2012 |
_stp_lookup_str(_stp_futex_op_list, (unsigned int)STAP_ARG_op, |
| 2013 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2014 |
%} |
| 2015 |
|
| 2016 |
function _futex_wake_op_str:string(encoded_op:long) |
| 2017 |
%{ /* pure */ /* unprivileged */ |
| 2018 |
int encoded_op = (int)STAP_ARG_encoded_op; |
| 2019 |
int op = (encoded_op >> 28) & 7; |
| 2020 |
int cmp = (encoded_op >> 24) & 15; |
| 2021 |
int oparg = (encoded_op << 8) >> 20; |
| 2022 |
int cmparg = (encoded_op << 20) >> 20; |
| 2023 |
int slen; |
| 2024 |
|
| 2025 |
strlcpy(STAP_RETVALUE, "{", MAXSTRINGLEN); |
| 2026 |
slen = strlen(STAP_RETVALUE); |
| 2027 |
|
| 2028 |
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) { |
| 2029 |
strlcat(STAP_RETVALUE + slen, "FUTEX_OP_OPARG_SHIFT|", |
| 2030 |
MAXSTRINGLEN - slen); |
| 2031 |
slen = strlen(STAP_RETVALUE); |
| 2032 |
} |
| 2033 |
|
| 2034 |
_stp_lookup_str(_stp_futex_wake_ops_list, op, |
| 2035 |
STAP_RETVALUE + slen, MAXSTRINGLEN - slen); |
| 2036 |
slen = strlen(STAP_RETVALUE); |
| 2037 |
|
| 2038 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, ", %d, ", |
| 2039 |
oparg); |
| 2040 |
slen = strlen(STAP_RETVALUE); |
| 2041 |
|
| 2042 |
_stp_lookup_str(_stp_futex_wake_cmps_list, cmp, |
| 2043 |
STAP_RETVALUE + slen, MAXSTRINGLEN - slen); |
| 2044 |
slen = strlen(STAP_RETVALUE); |
| 2045 |
|
| 2046 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, ", %d}", |
| 2047 |
cmparg); |
| 2048 |
%} |
| 2049 |
|
| 2050 |
%{ |
| 2051 |
#ifdef STAPCONF_UAPI_LINUX_MOUNT_H |
| 2052 |
#include <uapi/linux/mount.h> |
| 2053 |
#endif |
| 2054 |
static const _stp_val_array _stp_mountflags_list[] = { |
| 2055 |
V(MS_RDONLY), |
| 2056 |
V(MS_NOSUID), |
| 2057 |
V(MS_NODEV), |
| 2058 |
V(MS_NOEXEC), |
| 2059 |
V(MS_SYNCHRONOUS), |
| 2060 |
V(MS_REMOUNT), |
| 2061 |
V(MS_MANDLOCK), |
| 2062 |
V(MS_DIRSYNC), |
| 2063 |
V(MS_NOATIME), |
| 2064 |
V(MS_NODIRATIME), |
| 2065 |
V(MS_BIND), |
| 2066 |
V(MS_MOVE), |
| 2067 |
V(MS_REC), |
| 2068 |
/* MS_SILENT replaced MS_VERBOSE */ |
| 2069 |
#ifdef MS_SILENT |
| 2070 |
V(MS_SILENT), |
| 2071 |
#else |
| 2072 |
V(MS_VERBOSE), |
| 2073 |
#endif |
| 2074 |
V(MS_POSIXACL), |
| 2075 |
V(MS_UNBINDABLE), |
| 2076 |
V(MS_PRIVATE), |
| 2077 |
V(MS_SLAVE), |
| 2078 |
V(MS_SHARED), |
| 2079 |
#ifdef MS_RELATIME |
| 2080 |
V(MS_RELATIME), |
| 2081 |
#endif |
| 2082 |
#ifdef MS_KERNMOUNT |
| 2083 |
V(MS_KERNMOUNT), |
| 2084 |
#endif |
| 2085 |
#ifdef MS_I_VERSION |
| 2086 |
V(MS_I_VERSION), |
| 2087 |
#endif |
| 2088 |
#ifdef MS_STRICTATIME |
| 2089 |
V(MS_STRICTATIME), |
| 2090 |
#endif |
| 2091 |
{0, NULL} |
| 2092 |
}; |
| 2093 |
|
| 2094 |
static const _stp_val_array _stp_umountflags_list[] = { |
| 2095 |
V(MNT_FORCE), |
| 2096 |
V(MNT_DETACH), |
| 2097 |
V(MNT_EXPIRE), |
| 2098 |
#ifdef UMOUNT_NOFOLLOW |
| 2099 |
V(UMOUNT_NOFOLLOW), |
| 2100 |
#endif |
| 2101 |
{0, NULL} |
| 2102 |
}; |
| 2103 |
%} |
| 2104 |
|
| 2105 |
function _mountflags_str:string(op:long) |
| 2106 |
%{ /* pure */ /* unprivileged */ |
| 2107 |
_stp_lookup_or_str(_stp_mountflags_list, (unsigned long)STAP_ARG_op, |
| 2108 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2109 |
%} |
| 2110 |
|
| 2111 |
function _umountflags_str:string(op:long) |
| 2112 |
%{ /* pure */ /* unprivileged */ |
| 2113 |
_stp_lookup_or_str(_stp_umountflags_list, (unsigned int)STAP_ARG_op, |
| 2114 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2115 |
%} |
| 2116 |
|
| 2117 |
%(systemtap_v <= "2.7" %? |
| 2118 |
// This function is unused, so deprecate it. |
| 2119 |
function _statfs_f_type_str(f) { |
| 2120 |
if(f==0xadf5) return "ADFS_SUPER_MAGIC" |
| 2121 |
if(f==0xADFF) return "AFFS_SUPER_MAGIC" |
| 2122 |
if(f==0x42465331) return "BEFS_SUPER_MAGIC" |
| 2123 |
if(f==0x1BADFACE) return "BFS_MAGIC" |
| 2124 |
if(f==0xFF534D42) return "CIFS_MAGIC_NUMBER" |
| 2125 |
if(f==0x73757245) return "CODA_SUPER_MAGIC" |
| 2126 |
if(f==0x012FF7B7) return "COH_SUPER_MAGIC" |
| 2127 |
if(f==0x28cd3d45) return "CRAMFS_MAGIC" |
| 2128 |
if(f==0x1373) return "DEVFS_SUPER_MAGIC" |
| 2129 |
if(f==0x00414A53) return "EFS_SUPER_MAGIC" |
| 2130 |
if(f==0x137D) return "EXT_SUPER_MAGIC" |
| 2131 |
if(f==0xEF51) return "EXT2_OLD_SUPER_MAGIC" |
| 2132 |
if(f==0xEF53) return "EXT2_SUPER_MAGIC" |
| 2133 |
if(f==0xEF53) return "EXT3_SUPER_MAGIC" |
| 2134 |
if(f==0x4244) return "HFS_SUPER_MAGIC" |
| 2135 |
if(f==0xF995E849) return "HPFS_SUPER_MAGIC" |
| 2136 |
if(f==0x958458f6) return "HUGETLBFS_MAGIC" |
| 2137 |
if(f==0x9660) return "ISOFS_SUPER_MAGIC" |
| 2138 |
if(f==0x72b6) return "JFFS2_SUPER_MAGIC" |
| 2139 |
if(f==0x3153464a) return "JFS_SUPER_MAGIC" |
| 2140 |
if(f==0x137F) return "MINIX_SUPER_MAGIC" |
| 2141 |
if(f==0x138F) return "MINIX_SUPER_MAGIC2" |
| 2142 |
if(f==0x2468) return "MINIX2_SUPER_MAGIC" |
| 2143 |
if(f==0x2478) return "MINIX2_SUPER_MAGIC2" |
| 2144 |
if(f==0x4d44) return "MSDOS_SUPER_MAGIC" |
| 2145 |
if(f==0x564c) return "NCP_SUPER_MAGIC" |
| 2146 |
if(f==0x6969) return "NFS_SUPER_MAGIC" |
| 2147 |
if(f==0x5346544e) return "NTFS_SB_MAGIC" |
| 2148 |
if(f==0x9fa1) return "OPENPROM_SUPER_MAGIC" |
| 2149 |
if(f==0x9fa0) return "PROC_SUPER_MAGIC" |
| 2150 |
if(f==0x002f) return "QNX4_SUPER_MAGIC" |
| 2151 |
if(f==0x52654973) return "REISERFS_SUPER_MAGIC" |
| 2152 |
if(f==0x7275) return "ROMFS_MAGIC" |
| 2153 |
if(f==0x517B) return "SMB_SUPER_MAGIC" |
| 2154 |
if(f==0x012FF7B6) return "SYSV2_SUPER_MAGIC" |
| 2155 |
if(f==0x012FF7B5) return "SYSV4_SUPER_MAGIC" |
| 2156 |
if(f==0x01021994) return "TMPFS_MAGIC" |
| 2157 |
if(f==0x15013346) return "UDF_SUPER_MAGIC" |
| 2158 |
if(f==0x00011954) return "UFS_MAGIC" |
| 2159 |
if(f==0x9fa2) return "USBDEVICE_SUPER_MAGIC" |
| 2160 |
if(f==0xa501FCF5) return "VXFS_SUPER_MAGIC" |
| 2161 |
if(f==0x012FF7B4) return "XENIX_SUPER_MAGIC" |
| 2162 |
if(f==0x58465342) return "XFS_SUPER_MAGIC" |
| 2163 |
if(f==0x012FD16D) return "_XIAFS_SUPER_MAGIC" |
| 2164 |
return sprintf("UNKNOWN VALUE: %d", f) |
| 2165 |
} |
| 2166 |
%) |
| 2167 |
|
| 2168 |
%{ |
| 2169 |
#include <linux/mman.h> |
| 2170 |
|
| 2171 |
static const _stp_val_array _stp_mremap_flags_list[] = { |
| 2172 |
V(MREMAP_MAYMOVE), |
| 2173 |
V(MREMAP_FIXED), |
| 2174 |
{0, NULL} |
| 2175 |
}; |
| 2176 |
%} |
| 2177 |
|
| 2178 |
function _mremap_flags:string(flags:long) |
| 2179 |
%{ /* pure */ /* unprivileged */ |
| 2180 |
_stp_lookup_or_str(_stp_mremap_flags_list, (uint32_t)STAP_ARG_flags, |
| 2181 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2182 |
%} |
| 2183 |
|
| 2184 |
%{ |
| 2185 |
#include <linux/mman.h> |
| 2186 |
|
| 2187 |
static const _stp_val_array _stp_madvice_advice_list[] = { |
| 2188 |
V(MADV_NORMAL), |
| 2189 |
V(MADV_RANDOM), |
| 2190 |
V(MADV_SEQUENTIAL), |
| 2191 |
V(MADV_WILLNEED), |
| 2192 |
V(MADV_DONTNEED), |
| 2193 |
#ifdef MADV_FREE |
| 2194 |
V(MADV_FREE), |
| 2195 |
#endif |
| 2196 |
V(MADV_REMOVE), |
| 2197 |
V(MADV_DONTFORK), |
| 2198 |
V(MADV_DOFORK), |
| 2199 |
#ifdef MADV_HWPOISON |
| 2200 |
V(MADV_HWPOISON), |
| 2201 |
#endif |
| 2202 |
#ifdef MADV_SOFT_OFFLINE |
| 2203 |
V(MADV_SOFT_OFFLINE), |
| 2204 |
#endif |
| 2205 |
#ifdef MADV_MERGEABLE |
| 2206 |
V(MADV_MERGEABLE), |
| 2207 |
#endif |
| 2208 |
#ifdef MADV_UNMERGEABLE |
| 2209 |
V(MADV_UNMERGEABLE), |
| 2210 |
#endif |
| 2211 |
#ifdef MADV_HUGEPAGE |
| 2212 |
V(MADV_HUGEPAGE), |
| 2213 |
#endif |
| 2214 |
#ifdef MADV_NOHUGEPAGE |
| 2215 |
V(MADV_NOHUGEPAGE), |
| 2216 |
#endif |
| 2217 |
#ifdef MADV_DONTDUMP |
| 2218 |
V(MADV_DONTDUMP), |
| 2219 |
#endif |
| 2220 |
#ifdef MADV_DODUMP |
| 2221 |
V(MADV_DODUMP), |
| 2222 |
#endif |
| 2223 |
{0, NULL} |
| 2224 |
}; |
| 2225 |
%} |
| 2226 |
|
| 2227 |
function _madvice_advice_str:string(behavior:long) |
| 2228 |
%{ /* pure */ /* unprivileged */ |
| 2229 |
_stp_lookup_str(_stp_madvice_advice_list, |
| 2230 |
(unsigned int)STAP_ARG_behavior, STAP_RETVALUE, |
| 2231 |
MAXSTRINGLEN); |
| 2232 |
%} |
| 2233 |
|
| 2234 |
%{ |
| 2235 |
#include <linux/fadvise.h> |
| 2236 |
|
| 2237 |
static const _stp_val_array _stp_fadvice_advice_list[] = { |
| 2238 |
V(POSIX_FADV_NORMAL), |
| 2239 |
V(POSIX_FADV_RANDOM), |
| 2240 |
V(POSIX_FADV_SEQUENTIAL), |
| 2241 |
V(POSIX_FADV_WILLNEED), |
| 2242 |
V(POSIX_FADV_DONTNEED), |
| 2243 |
V(POSIX_FADV_NOREUSE), |
| 2244 |
#if defined(__s390x__) |
| 2245 |
/* On s390x, 64-bit exes and 32-bit exes have different |
| 2246 |
* versions of the following values. */ |
| 2247 |
{4, "POSIX_FADV_DONTNEED"}, |
| 2248 |
{5, "POSIX_FADV_NOREUSE"}, |
| 2249 |
#endif |
| 2250 |
{0, NULL} |
| 2251 |
}; |
| 2252 |
%} |
| 2253 |
|
| 2254 |
function _fadvice_advice_str:string(behavior:long) |
| 2255 |
%{ /* pure */ /* unprivileged */ |
| 2256 |
_stp_lookup_str(_stp_fadvice_advice_list, |
| 2257 |
(unsigned int)STAP_ARG_behavior, STAP_RETVALUE, |
| 2258 |
MAXSTRINGLEN); |
| 2259 |
%} |
| 2260 |
|
| 2261 |
%{ |
| 2262 |
#include <linux/fcntl.h> |
| 2263 |
|
| 2264 |
static const _stp_val_array _stp_fcntl_cmd_list[] = { |
| 2265 |
V(F_DUPFD), |
| 2266 |
V(F_GETFD), |
| 2267 |
V(F_SETFD), |
| 2268 |
V(F_GETFL), |
| 2269 |
V(F_SETFL), |
| 2270 |
V(F_GETLK), |
| 2271 |
V(F_SETLK), |
| 2272 |
V(F_SETLKW), |
| 2273 |
V(F_SETOWN), |
| 2274 |
V(F_GETOWN), |
| 2275 |
V(F_SETSIG), |
| 2276 |
V(F_GETSIG), |
| 2277 |
#ifdef F_GETLK64 |
| 2278 |
V(F_GETLK64), |
| 2279 |
#endif |
| 2280 |
#ifdef F_SETLK64 |
| 2281 |
V(F_SETLK64), |
| 2282 |
#endif |
| 2283 |
#ifdef F_SETLKW64 |
| 2284 |
V(F_SETLKW64), |
| 2285 |
#endif |
| 2286 |
#ifdef F_SETOWN_EX |
| 2287 |
V(F_SETOWN_EX), |
| 2288 |
#endif |
| 2289 |
#ifdef F_GETOWN_EX |
| 2290 |
V(F_GETOWN_EX), |
| 2291 |
#endif |
| 2292 |
#ifdef F_GETOWNER_UIDS |
| 2293 |
V(F_GETOWNER_UIDS), |
| 2294 |
#endif |
| 2295 |
#ifdef F_SETLEASE |
| 2296 |
V(F_SETLEASE), |
| 2297 |
#endif |
| 2298 |
#ifdef F_GETLEASE |
| 2299 |
V(F_GETLEASE), |
| 2300 |
#endif |
| 2301 |
#ifdef F_DUPFD_CLOEXEC |
| 2302 |
V(F_DUPFD_CLOEXEC), |
| 2303 |
#endif |
| 2304 |
#ifdef F_NOTIFY |
| 2305 |
V(F_NOTIFY), |
| 2306 |
#endif |
| 2307 |
#ifdef F_SETPIPE_SZ |
| 2308 |
V(F_SETPIPE_SZ), |
| 2309 |
#endif |
| 2310 |
#ifdef F_GETPIPE_SZ |
| 2311 |
V(F_GETPIPE_SZ), |
| 2312 |
#endif |
| 2313 |
{0, NULL} |
| 2314 |
}; |
| 2315 |
%} |
| 2316 |
|
| 2317 |
function _fcntl_cmd_str:string(cmd:long) |
| 2318 |
%{ /* pure */ /* unprivileged */ |
| 2319 |
_stp_lookup_str(_stp_fcntl_cmd_list, (unsigned int)STAP_ARG_cmd, |
| 2320 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2321 |
%} |
| 2322 |
|
| 2323 |
%{ |
| 2324 |
#include <linux/fs.h> |
| 2325 |
#ifndef SEEK_SET |
| 2326 |
#define SEEK_SET 0 |
| 2327 |
#endif |
| 2328 |
#ifndef SEEK_CUR |
| 2329 |
#define SEEK_CUR 1 |
| 2330 |
#endif |
| 2331 |
#ifndef SEEK_END |
| 2332 |
#define SEEK_END 2 |
| 2333 |
#endif |
| 2334 |
#ifndef SEEK_DATA |
| 2335 |
#define SEEK_DATA 3 |
| 2336 |
#endif |
| 2337 |
#ifndef SEEK_HOLE |
| 2338 |
#define SEEK_HOLE 4 |
| 2339 |
#endif |
| 2340 |
static const _stp_val_array _stp_seek_whence_list[] = { |
| 2341 |
V(SEEK_SET), |
| 2342 |
V(SEEK_CUR), |
| 2343 |
V(SEEK_END), |
| 2344 |
V(SEEK_DATA), |
| 2345 |
V(SEEK_HOLE), |
| 2346 |
{0, NULL} |
| 2347 |
}; |
| 2348 |
|
| 2349 |
%} |
| 2350 |
function _seek_whence_str:string(w:long) |
| 2351 |
%{ /* pure */ /* unprivileged */ |
| 2352 |
_stp_lookup_str(_stp_seek_whence_list, (unsigned int)STAP_ARG_w, |
| 2353 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2354 |
%} |
| 2355 |
|
| 2356 |
%{ |
| 2357 |
#include <linux/quota.h> |
| 2358 |
|
| 2359 |
static const _stp_val_array _stp_quotactl_cmd_list[] = { |
| 2360 |
V(Q_SYNC), |
| 2361 |
V(Q_QUOTAON), |
| 2362 |
V(Q_QUOTAOFF), |
| 2363 |
V(Q_GETFMT), |
| 2364 |
V(Q_GETINFO), |
| 2365 |
V(Q_SETINFO), |
| 2366 |
V(Q_GETQUOTA), |
| 2367 |
V(Q_SETQUOTA), |
| 2368 |
/* XFS Quota Manager (XQM) Codes */ |
| 2369 |
V(Q_XQUOTAON), |
| 2370 |
V(Q_XQUOTAOFF), |
| 2371 |
V(Q_XGETQUOTA), |
| 2372 |
V(Q_XSETQLIM), |
| 2373 |
V(Q_XGETQSTAT), |
| 2374 |
V(Q_XQUOTARM), |
| 2375 |
V(Q_XQUOTASYNC), |
| 2376 |
#ifdef Q_XGETQSTATV |
| 2377 |
V(Q_XGETQSTATV), |
| 2378 |
#endif |
| 2379 |
{0, NULL} |
| 2380 |
}; |
| 2381 |
%} |
| 2382 |
|
| 2383 |
function _quotactl_cmd_str:string(cmd:long) |
| 2384 |
%{ /* pure */ /* unprivileged */ |
| 2385 |
unsigned int cmd = (unsigned int)STAP_ARG_cmd >> SUBCMDSHIFT; |
| 2386 |
unsigned int type = (unsigned int)STAP_ARG_cmd & SUBCMDMASK; |
| 2387 |
|
| 2388 |
_stp_lookup_str(_stp_quotactl_cmd_list, cmd, STAP_RETVALUE, |
| 2389 |
MAXSTRINGLEN); |
| 2390 |
if (type == USRQUOTA) |
| 2391 |
strlcat(STAP_RETVALUE, "|USRQUOTA", MAXSTRINGLEN); |
| 2392 |
else if (type == GRPQUOTA) |
| 2393 |
strlcat(STAP_RETVALUE, "|GRPQUOTA", MAXSTRINGLEN); |
| 2394 |
else { |
| 2395 |
int len = strlen(STAP_RETVALUE); |
| 2396 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 2397 |
"|0x%x", type); |
| 2398 |
} |
| 2399 |
%} |
| 2400 |
|
| 2401 |
function _quotactl_subcmd:long(cmd:long) |
| 2402 |
%{ /* pure */ /* unprivileged */ |
| 2403 |
STAP_RETVALUE = (unsigned int)STAP_ARG_cmd >> SUBCMDSHIFT; |
| 2404 |
%} |
| 2405 |
|
| 2406 |
|
| 2407 |
%{ |
| 2408 |
static const _stp_val_array _stp_quotactl_format_list[] = { |
| 2409 |
V(QFMT_VFS_OLD), |
| 2410 |
#ifdef QFMT_VFS_V0 |
| 2411 |
V(QFMT_VFS_V0), |
| 2412 |
#endif |
| 2413 |
#ifdef QFMT_OCFS2 |
| 2414 |
V(QFMT_OCFS2), |
| 2415 |
#endif |
| 2416 |
#ifdef QFMT_VFS_V1 |
| 2417 |
V(QFMT_VFS_V1), |
| 2418 |
#endif |
| 2419 |
{0, NULL} |
| 2420 |
}; |
| 2421 |
%} |
| 2422 |
|
| 2423 |
function _quotactl_quota_type_str:string(fmt:long) |
| 2424 |
%{ /* pure */ /* unprivileged */ |
| 2425 |
_stp_lookup_str(_stp_quotactl_format_list, |
| 2426 |
(int)STAP_ARG_fmt, STAP_RETVALUE, MAXSTRINGLEN); |
| 2427 |
%} |
| 2428 |
|
| 2429 |
function _struct_dqblk_u:string(uaddr:long) |
| 2430 |
%{ /* pure */ |
| 2431 |
struct if_dqblk dqb; |
| 2432 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 2433 |
if (ptr == NULL) |
| 2434 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 2435 |
else |
| 2436 |
{ |
| 2437 |
if (_stp_copy_from_user((char*)&dqb, ptr, |
| 2438 |
sizeof(struct if_dqblk)) == 0) |
| 2439 |
{ |
| 2440 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 2441 |
"{dqb_bhardlimit=%llu, dqb_bsoftlimit=%llu, dqb_curspace=%llu, dqb_ihardlimit=%llu, dqb_isoftlimit=%llu, ...}", |
| 2442 |
(unsigned long long)dqb.dqb_bhardlimit, (unsigned long long)dqb.dqb_bsoftlimit, (unsigned long long)dqb.dqb_curspace, |
| 2443 |
(unsigned long long)dqb.dqb_ihardlimit, (unsigned long long)dqb.dqb_isoftlimit); |
| 2444 |
} |
| 2445 |
else |
| 2446 |
{ |
| 2447 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 2448 |
(unsigned long)ptr); |
| 2449 |
} |
| 2450 |
} |
| 2451 |
%} |
| 2452 |
|
| 2453 |
function _struct_dqinfo_u:string(uaddr:long) |
| 2454 |
%{ /* pure */ |
| 2455 |
struct if_dqinfo dqi; |
| 2456 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 2457 |
if (ptr == NULL) |
| 2458 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 2459 |
else |
| 2460 |
{ |
| 2461 |
if (_stp_copy_from_user((char*)&dqi, ptr, |
| 2462 |
sizeof(struct if_dqinfo)) == 0) |
| 2463 |
{ |
| 2464 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 2465 |
"{dqi_bgrace=%llu, dqi_igrace=%llu, dqi_flags=%d, dqi_valid=%d}", |
| 2466 |
(unsigned long long)dqi.dqi_bgrace, (unsigned long long)dqi.dqi_igrace, |
| 2467 |
dqi.dqi_flags, dqi.dqi_valid); |
| 2468 |
} |
| 2469 |
else |
| 2470 |
{ |
| 2471 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 2472 |
(unsigned long)ptr); |
| 2473 |
} |
| 2474 |
} |
| 2475 |
%} |
| 2476 |
|
| 2477 |
%{ |
| 2478 |
#include <linux/socket.h> |
| 2479 |
|
| 2480 |
static const _stp_val_array _stp_sockopt_optname_list[] = { |
| 2481 |
V(SO_DEBUG), |
| 2482 |
V(SO_REUSEADDR), |
| 2483 |
V(SO_TYPE), |
| 2484 |
V(SO_ERROR), |
| 2485 |
V(SO_DONTROUTE), |
| 2486 |
V(SO_BROADCAST), |
| 2487 |
V(SO_SNDBUF), |
| 2488 |
V(SO_RCVBUF), |
| 2489 |
V(SO_SNDBUFFORCE), |
| 2490 |
V(SO_RCVBUFFORCE), |
| 2491 |
V(SO_KEEPALIVE), |
| 2492 |
V(SO_OOBINLINE), |
| 2493 |
V(SO_NO_CHECK), |
| 2494 |
V(SO_PRIORITY), |
| 2495 |
V(SO_LINGER), |
| 2496 |
V(SO_BSDCOMPAT), |
| 2497 |
#ifdef SO_REUSEPORT |
| 2498 |
V(SO_REUSEPORT), |
| 2499 |
#endif |
| 2500 |
V(SO_PASSCRED), |
| 2501 |
V(SO_PEERCRED), |
| 2502 |
V(SO_RCVLOWAT), |
| 2503 |
V(SO_SNDLOWAT), |
| 2504 |
#ifdef SO_RCVTIMEO |
| 2505 |
V(SO_RCVTIMEO), |
| 2506 |
#endif |
| 2507 |
#ifdef SO_SNDTIMEO |
| 2508 |
V(SO_SNDTIMEO), |
| 2509 |
#endif |
| 2510 |
V(SO_SECURITY_AUTHENTICATION), |
| 2511 |
V(SO_SECURITY_ENCRYPTION_TRANSPORT), |
| 2512 |
V(SO_SECURITY_ENCRYPTION_NETWORK), |
| 2513 |
V(SO_BINDTODEVICE), |
| 2514 |
V(SO_ATTACH_FILTER), |
| 2515 |
V(SO_DETACH_FILTER), |
| 2516 |
V(SO_PEERNAME), |
| 2517 |
#ifdef SO_TIMESTAMP |
| 2518 |
V(SO_TIMESTAMP), |
| 2519 |
#endif |
| 2520 |
V(SO_ACCEPTCONN), |
| 2521 |
V(SO_PEERSEC), |
| 2522 |
V(SO_PASSSEC), |
| 2523 |
#ifdef SO_TIMESTAMPNS |
| 2524 |
V(SO_TIMESTAMPNS), |
| 2525 |
#endif |
| 2526 |
#ifdef SO_MARK |
| 2527 |
V(SO_MARK), |
| 2528 |
#endif |
| 2529 |
#ifdef SO_TIMESTAMPING |
| 2530 |
V(SO_TIMESTAMPING), |
| 2531 |
#endif |
| 2532 |
#ifdef SO_PROTOCOL |
| 2533 |
V(SO_PROTOCOL), |
| 2534 |
#endif |
| 2535 |
#ifdef SO_DOMAIN |
| 2536 |
V(SO_DOMAIN), |
| 2537 |
#endif |
| 2538 |
#ifdef SO_RXQ_OVFL |
| 2539 |
V(SO_RXQ_OVFL), |
| 2540 |
#endif |
| 2541 |
#ifdef SO_WIFI_STATUS |
| 2542 |
V(SO_WIFI_STATUS), |
| 2543 |
#endif |
| 2544 |
#ifdef SO_PEEK_OFF |
| 2545 |
V(SO_PEEK_OFF), |
| 2546 |
#endif |
| 2547 |
#ifdef SO_NOFCS |
| 2548 |
V(SO_NOFCS), |
| 2549 |
#endif |
| 2550 |
#ifdef SO_LOCK_FILTER |
| 2551 |
V(SO_LOCK_FILTER), |
| 2552 |
#endif |
| 2553 |
#ifdef SO_SELECT_ERR_QUEUE |
| 2554 |
V(SO_SELECT_ERR_QUEUE), |
| 2555 |
#endif |
| 2556 |
#ifdef SO_BUSY_POLL |
| 2557 |
V(SO_BUSY_POLL), |
| 2558 |
#endif |
| 2559 |
#ifdef SO_MAX_PACING_RATE |
| 2560 |
V(SO_MAX_PACING_RATE), |
| 2561 |
#endif |
| 2562 |
#ifdef SO_BPF_EXTENSIONS |
| 2563 |
V(SO_BPF_EXTENSIONS), |
| 2564 |
#endif |
| 2565 |
#ifdef SO_INCOMING_CPU |
| 2566 |
V(SO_INCOMING_CPU), |
| 2567 |
#endif |
| 2568 |
#ifdef SO_ATTACH_BPF |
| 2569 |
V(SO_ATTACH_BPF), |
| 2570 |
#endif |
| 2571 |
#ifdef SO_DETACH_BPF |
| 2572 |
V(SO_DETACH_BPF), |
| 2573 |
#endif |
| 2574 |
#ifdef SO_ATTACH_REUSEPORT_CBPF |
| 2575 |
V(SO_ATTACH_REUSEPORT_CBPF), |
| 2576 |
#endif |
| 2577 |
#ifdef SO_ATTACH_REUSEPORT_EBPF |
| 2578 |
V(SO_ATTACH_REUSEPORT_EBPF), |
| 2579 |
#endif |
| 2580 |
#ifdef SO_CNX_ADVICE |
| 2581 |
V(SO_CNX_ADVICE), |
| 2582 |
#endif |
| 2583 |
#ifdef SCM_TIMESTAMPING_OPT_STATS |
| 2584 |
V(SCM_TIMESTAMPING_OPT_STATS), |
| 2585 |
#endif |
| 2586 |
#ifdef SO_MEMINFO |
| 2587 |
V(SO_MEMINFO), |
| 2588 |
#endif |
| 2589 |
#ifdef SO_INCOMING_NAPI_ID |
| 2590 |
V(SO_INCOMING_NAPI_ID), |
| 2591 |
#endif |
| 2592 |
#ifdef SO_COOKIE |
| 2593 |
V(SO_COOKIE), |
| 2594 |
#endif |
| 2595 |
#ifdef SCM_TIMESTAMPING_PKTINFO |
| 2596 |
V(SCM_TIMESTAMPING_PKTINFO), |
| 2597 |
#endif |
| 2598 |
#ifdef SO_PEERGROUPS |
| 2599 |
V(SO_PEERGROUPS), |
| 2600 |
#endif |
| 2601 |
#ifdef SO_ZEROCOPY |
| 2602 |
V(SO_ZEROCOPY), |
| 2603 |
#endif |
| 2604 |
#ifdef SO_TXTIME |
| 2605 |
V(SO_TXTIME), |
| 2606 |
#endif |
| 2607 |
#ifdef SCM_TXTIME |
| 2608 |
V(SCM_TXTIME), |
| 2609 |
#endif |
| 2610 |
#ifdef SO_BINDTOIFINDEX |
| 2611 |
V(SO_BINDTOIFINDEX), |
| 2612 |
#endif |
| 2613 |
#ifdef SO_TIMESTAMP_OLD |
| 2614 |
V(SO_TIMESTAMP_OLD), |
| 2615 |
#endif |
| 2616 |
#ifdef SO_TIMESTAMPNS_OLD |
| 2617 |
V(SO_TIMESTAMPNS_OLD), |
| 2618 |
#endif |
| 2619 |
#ifdef SO_TIMESTAMPING_OLD |
| 2620 |
V(SO_TIMESTAMPING_OLD), |
| 2621 |
#endif |
| 2622 |
#ifdef SO_TIMESTAMP_NEW |
| 2623 |
V(SO_TIMESTAMP_NEW), |
| 2624 |
#endif |
| 2625 |
#ifdef SO_TIMESTAMPNS_NEW |
| 2626 |
V(SO_TIMESTAMPNS_NEW), |
| 2627 |
#endif |
| 2628 |
#ifdef SO_TIMESTAMPING_NEW |
| 2629 |
V(SO_TIMESTAMPING_NEW), |
| 2630 |
#endif |
| 2631 |
#ifdef SO_RCVTIMEO_NEW |
| 2632 |
V(SO_RCVTIMEO_NEW), |
| 2633 |
#endif |
| 2634 |
#ifdef SO_SNDTIMEO_NEW |
| 2635 |
V(SO_SNDTIMEO_NEW), |
| 2636 |
#endif |
| 2637 |
{0, NULL} |
| 2638 |
}; |
| 2639 |
%} |
| 2640 |
|
| 2641 |
/* see sys/socket.h (for setsockopt) */ |
| 2642 |
function _sockopt_optname_str:string(opt:long) |
| 2643 |
%{ /* pure */ /* unprivileged */ |
| 2644 |
_stp_lookup_str(_stp_sockopt_optname_list, STAP_ARG_opt, STAP_RETVALUE, |
| 2645 |
MAXSTRINGLEN); |
| 2646 |
%} |
| 2647 |
|
| 2648 |
%{ |
| 2649 |
static const _stp_val_array _stp_sockopt_level_list[] = { |
| 2650 |
V(SOL_IP), |
| 2651 |
V(SOL_SOCKET), |
| 2652 |
V(SOL_TCP), |
| 2653 |
V(SOL_UDP), |
| 2654 |
V(SOL_IPV6), |
| 2655 |
V(SOL_ICMPV6), |
| 2656 |
V(SOL_SCTP), |
| 2657 |
#ifdef SOL_UDPLITE |
| 2658 |
V(SOL_UDPLITE), |
| 2659 |
#endif |
| 2660 |
V(SOL_RAW), |
| 2661 |
V(SOL_IPX), |
| 2662 |
V(SOL_AX25), |
| 2663 |
V(SOL_ATALK), |
| 2664 |
V(SOL_NETROM), |
| 2665 |
V(SOL_ROSE), |
| 2666 |
V(SOL_DECNET), |
| 2667 |
#ifdef SOL_X25 |
| 2668 |
V(SOL_X25), |
| 2669 |
#endif |
| 2670 |
V(SOL_PACKET), |
| 2671 |
V(SOL_ATM), |
| 2672 |
V(SOL_AAL), |
| 2673 |
V(SOL_IRDA), |
| 2674 |
V(SOL_NETBEUI), |
| 2675 |
V(SOL_LLC), |
| 2676 |
V(SOL_DCCP), |
| 2677 |
V(SOL_NETLINK), |
| 2678 |
V(SOL_TIPC), |
| 2679 |
#ifdef SOL_RXRPC |
| 2680 |
V(SOL_RXRPC), |
| 2681 |
#endif |
| 2682 |
#ifdef SOL_PPPOL2TP |
| 2683 |
V(SOL_PPPOL2TP), |
| 2684 |
#endif |
| 2685 |
#ifdef SOL_BLUETOOTH |
| 2686 |
V(SOL_BLUETOOTH), |
| 2687 |
#endif |
| 2688 |
#ifdef SOL_PNPIPE |
| 2689 |
V(SOL_PNPIPE), |
| 2690 |
#endif |
| 2691 |
#ifdef SOL_RDS |
| 2692 |
V(SOL_RDS), |
| 2693 |
#endif |
| 2694 |
V(SOL_IUCV), |
| 2695 |
#ifdef SOL_CAIF |
| 2696 |
V(SOL_CAIF), |
| 2697 |
#endif |
| 2698 |
#ifdef SOL_ALG |
| 2699 |
V(SOL_ALG), |
| 2700 |
#endif |
| 2701 |
#ifdef SOL_NFC |
| 2702 |
V(SOL_NFC), |
| 2703 |
#endif |
| 2704 |
{0, NULL} |
| 2705 |
}; |
| 2706 |
%} |
| 2707 |
|
| 2708 |
/* `man 2 setsockopt` for more information */ |
| 2709 |
function _sockopt_level_str:string(level:long) |
| 2710 |
%{ /* pure */ /* unprivileged */ |
| 2711 |
_stp_lookup_str(_stp_sockopt_level_list, STAP_ARG_level, STAP_RETVALUE, |
| 2712 |
MAXSTRINGLEN); |
| 2713 |
%} |
| 2714 |
|
| 2715 |
%{ |
| 2716 |
static const _stp_val_array _stp_sock_family_list[] = { |
| 2717 |
V(PF_UNSPEC), |
| 2718 |
V(PF_LOCAL), /* same thing as PF_UNIX */ |
| 2719 |
V(PF_INET), |
| 2720 |
V(PF_AX25), |
| 2721 |
V(PF_IPX), |
| 2722 |
V(PF_APPLETALK), |
| 2723 |
V(PF_NETROM), |
| 2724 |
V(PF_BRIDGE), |
| 2725 |
V(PF_ATMPVC), |
| 2726 |
V(PF_X25), |
| 2727 |
V(PF_INET6), |
| 2728 |
V(PF_ROSE), |
| 2729 |
V(PF_DECnet), |
| 2730 |
V(PF_NETBEUI), |
| 2731 |
V(PF_SECURITY), |
| 2732 |
V(PF_KEY), |
| 2733 |
V(PF_NETLINK), |
| 2734 |
V(PF_ROUTE), |
| 2735 |
V(PF_PACKET), |
| 2736 |
V(PF_ASH), |
| 2737 |
V(PF_ECONET), |
| 2738 |
V(PF_ATMSVC), |
| 2739 |
#ifdef PF_RDS |
| 2740 |
V(PF_RDS), |
| 2741 |
#endif |
| 2742 |
V(PF_SNA), |
| 2743 |
V(PF_IRDA), |
| 2744 |
V(PF_PPPOX), |
| 2745 |
V(PF_WANPIPE), |
| 2746 |
V(PF_LLC), |
| 2747 |
#ifdef PF_IB |
| 2748 |
V(PF_IB), |
| 2749 |
#endif |
| 2750 |
#ifdef PF_CAN |
| 2751 |
V(PF_CAN), |
| 2752 |
#endif |
| 2753 |
V(PF_TIPC), |
| 2754 |
V(PF_BLUETOOTH), |
| 2755 |
V(PF_IUCV), |
| 2756 |
#ifdef PF_RXRPC |
| 2757 |
V(PF_RXRPC), |
| 2758 |
#endif |
| 2759 |
#ifdef PF_ISDN |
| 2760 |
V(PF_ISDN), |
| 2761 |
#endif |
| 2762 |
#ifdef PF_PHONET |
| 2763 |
V(PF_PHONET), |
| 2764 |
#endif |
| 2765 |
#ifdef PF_IEEE802154 |
| 2766 |
V(PF_IEEE802154), |
| 2767 |
#endif |
| 2768 |
#ifdef PF_CAIF |
| 2769 |
V(PF_CAIF), |
| 2770 |
#endif |
| 2771 |
#ifdef PF_ALG |
| 2772 |
V(PF_ALG), |
| 2773 |
#endif |
| 2774 |
#ifdef PF_NFC |
| 2775 |
V(PF_NFC), |
| 2776 |
#endif |
| 2777 |
#ifdef PF_VSOCK |
| 2778 |
V(PF_VSOCK), |
| 2779 |
#endif |
| 2780 |
{0, NULL} |
| 2781 |
}; |
| 2782 |
%} |
| 2783 |
|
| 2784 |
function _sock_family_str:string(f:long) |
| 2785 |
%{ /* pure */ /* unprivileged */ |
| 2786 |
_stp_lookup_str(_stp_sock_family_list, (unsigned int)STAP_ARG_f, |
| 2787 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2788 |
%} |
| 2789 |
|
| 2790 |
function _sock_type_str:string(type:long) |
| 2791 |
%{ /* pure */ /* unprivileged */ |
| 2792 |
#ifdef SOCK_TYPE_MASK |
| 2793 |
int flags = (int)STAP_ARG_type & ~SOCK_TYPE_MASK; |
| 2794 |
int t = (int)STAP_ARG_type & SOCK_TYPE_MASK; |
| 2795 |
#else |
| 2796 |
int t = (int)STAP_ARG_type; |
| 2797 |
#endif |
| 2798 |
int data_added = 0; |
| 2799 |
|
| 2800 |
/* |
| 2801 |
* This is a bit tricky. We've got 2 types of information |
| 2802 |
* here. A socket type and a possible combination of socket |
| 2803 |
* flags. In addition, we only want one final listing of |
| 2804 |
* any unknown bits set. |
| 2805 |
* |
| 2806 |
* We can't call _stp_lookup_str() here since it would go |
| 2807 |
* ahead and display any unknown type value, and we want to |
| 2808 |
* wait until after any possible flags are displayed. |
| 2809 |
*/ |
| 2810 |
switch (t) { |
| 2811 |
case SOCK_STREAM: |
| 2812 |
strlcpy (STAP_RETVALUE, "SOCK_STREAM", MAXSTRINGLEN); |
| 2813 |
t = 0; |
| 2814 |
data_added = 1; |
| 2815 |
break; |
| 2816 |
case SOCK_DGRAM: |
| 2817 |
strlcpy (STAP_RETVALUE, "SOCK_DGRAM", MAXSTRINGLEN); |
| 2818 |
t = 0; |
| 2819 |
data_added = 1; |
| 2820 |
break; |
| 2821 |
case SOCK_RAW: |
| 2822 |
strlcpy (STAP_RETVALUE, "SOCK_RAW", MAXSTRINGLEN); |
| 2823 |
t = 0; |
| 2824 |
data_added = 1; |
| 2825 |
break; |
| 2826 |
case SOCK_RDM: |
| 2827 |
strlcpy (STAP_RETVALUE, "SOCK_RDM", MAXSTRINGLEN); |
| 2828 |
t = 0; |
| 2829 |
data_added = 1; |
| 2830 |
break; |
| 2831 |
case SOCK_SEQPACKET: |
| 2832 |
strlcpy (STAP_RETVALUE, "SOCK_SEQPACKET", MAXSTRINGLEN); |
| 2833 |
t = 0; |
| 2834 |
data_added = 1; |
| 2835 |
break; |
| 2836 |
#ifdef SOL_DCCP |
| 2837 |
case SOCK_DCCP: |
| 2838 |
strlcpy (STAP_RETVALUE, "SOCK_DCCP", MAXSTRINGLEN); |
| 2839 |
t = 0; |
| 2840 |
data_added = 1; |
| 2841 |
break; |
| 2842 |
#endif |
| 2843 |
case SOCK_PACKET: |
| 2844 |
strlcpy (STAP_RETVALUE, "SOCK_PACKET", MAXSTRINGLEN); |
| 2845 |
t = 0; |
| 2846 |
data_added = 1; |
| 2847 |
break; |
| 2848 |
} |
| 2849 |
|
| 2850 |
#ifdef SOCK_TYPE_MASK |
| 2851 |
/* We can't use _stp_lookup_or_str() here since if none of |
| 2852 |
* these flags are set it would put a "0x0" on the end, which |
| 2853 |
* we don't want to add to the socket type. */ |
| 2854 |
if (flags & SOCK_CLOEXEC) { |
| 2855 |
if (data_added) |
| 2856 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 2857 |
strlcat (STAP_RETVALUE, "SOCK_CLOEXEC", MAXSTRINGLEN); |
| 2858 |
flags &= ~SOCK_CLOEXEC; |
| 2859 |
data_added = 1; |
| 2860 |
} |
| 2861 |
if (flags & SOCK_NONBLOCK) { |
| 2862 |
if (data_added) |
| 2863 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 2864 |
strlcat (STAP_RETVALUE, "SOCK_NONBLOCK", MAXSTRINGLEN); |
| 2865 |
flags &= ~SOCK_NONBLOCK; |
| 2866 |
data_added = 1; |
| 2867 |
} |
| 2868 |
|
| 2869 |
/* If we have any leftover flags bits, add them back to the |
| 2870 |
* type bits to get displayed together. */ |
| 2871 |
t |= flags; |
| 2872 |
#endif |
| 2873 |
|
| 2874 |
/* Display any leftover bits. */ |
| 2875 |
if (t != 0 || !data_added) { |
| 2876 |
int slen; |
| 2877 |
if (data_added) |
| 2878 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 2879 |
slen = strlen(STAP_RETVALUE); |
| 2880 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, |
| 2881 |
"0x%x", t); |
| 2882 |
} |
| 2883 |
%} |
| 2884 |
|
| 2885 |
%{ |
| 2886 |
static const _stp_val_array _stp_sock_flags_list[] = { |
| 2887 |
#ifdef SOCK_TYPE_MASK |
| 2888 |
V(SOCK_CLOEXEC), |
| 2889 |
V(SOCK_NONBLOCK), |
| 2890 |
#endif |
| 2891 |
{0, NULL} |
| 2892 |
}; |
| 2893 |
%} |
| 2894 |
|
| 2895 |
function _sock_flags_str:string(f:long) |
| 2896 |
%{ /* pure */ /* unprivileged */ |
| 2897 |
_stp_lookup_or_str(_stp_sock_flags_list, (unsigned int)STAP_ARG_f, |
| 2898 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2899 |
%} |
| 2900 |
|
| 2901 |
%{ |
| 2902 |
// Be sure we have the IPPROTO_* defines. But, on some older kernels |
| 2903 |
// we don't have all of them defined. Also note that on some older |
| 2904 |
// kernels these values are enum values, not defines. But, the |
| 2905 |
// following code should work anyway. |
| 2906 |
#include <linux/in.h> |
| 2907 |
#ifndef IPPROTO_TP |
| 2908 |
#define IPPROTO_TP 29 |
| 2909 |
#endif |
| 2910 |
#ifndef IPPROTO_MTP |
| 2911 |
#define IPPROTO_MTP 92 |
| 2912 |
#endif |
| 2913 |
#ifndef IPPROTO_ENCAP |
| 2914 |
#define IPPROTO_ENCAP 98 |
| 2915 |
#endif |
| 2916 |
#ifndef IPPROTO_UDPLITE |
| 2917 |
#define IPPROTO_UDPLITE 136 |
| 2918 |
#endif |
| 2919 |
%} |
| 2920 |
|
| 2921 |
function _sock_protocol_str:string(family:long, protocol:long) |
| 2922 |
{ |
| 2923 |
if (family == @const("PF_INET") |
| 2924 |
|| family == @const("PF_INET6")) { |
| 2925 |
if (protocol == @const("IPPROTO_IP")) return "IPPROTO_IP" |
| 2926 |
if (protocol == @const("IPPROTO_ICMP")) return "IPPROTO_ICMP" |
| 2927 |
if (protocol == @const("IPPROTO_IGMP")) return "IPPROTO_IGMP" |
| 2928 |
if (protocol == @const("IPPROTO_IPIP")) return "IPPROTO_IPIP" |
| 2929 |
if (protocol == @const("IPPROTO_TCP")) return "IPPROTO_TCP" |
| 2930 |
if (protocol == @const("IPPROTO_EGP")) return "IPPROTO_EGP" |
| 2931 |
if (protocol == @const("IPPROTO_PUP")) return "IPPROTO_PUP" |
| 2932 |
if (protocol == @const("IPPROTO_UDP")) return "IPPROTO_UDP" |
| 2933 |
if (protocol == @const("IPPROTO_IDP")) return "IPPROTO_IDP" |
| 2934 |
if (protocol == @const("IPPROTO_TP")) return "IPPROTO_TP" |
| 2935 |
if (protocol == @const("IPPROTO_DCCP")) return "IPPROTO_DCCP" |
| 2936 |
if (protocol == @const("IPPROTO_IPV6")) return "IPPROTO_IPV6" |
| 2937 |
if (protocol == @const("IPPROTO_RSVP")) return "IPPROTO_RSVP" |
| 2938 |
if (protocol == @const("IPPROTO_GRE")) return "IPPROTO_GRE" |
| 2939 |
if (protocol == @const("IPPROTO_ESP")) return "IPPROTO_ESP" |
| 2940 |
if (protocol == @const("IPPROTO_AH")) return "IPPROTO_AH" |
| 2941 |
if (protocol == @const("IPPROTO_MTP")) return "IPPROTO_MTP" |
| 2942 |
if (protocol == @const("IPPROTO_ENCAP")) return "IPPROTO_ENCAP" |
| 2943 |
if (protocol == @const("IPPROTO_PIM")) return "IPPROTO_PIM" |
| 2944 |
if (protocol == @const("IPPROTO_COMP")) return "IPPROTO_COMP" |
| 2945 |
if (protocol == @const("IPPROTO_SCTP")) return "IPPROTO_SCTP" |
| 2946 |
if (protocol == @const("IPPROTO_UDPLITE")) return "IPPROTO_UDPLITE" |
| 2947 |
if (protocol == @const("IPPROTO_RAW")) return "IPPROTO_RAW" |
| 2948 |
} |
| 2949 |
return sprintf("%d", protocol) |
| 2950 |
} |
| 2951 |
|
| 2952 |
function _opoll_op_str:string(o:long) |
| 2953 |
%{ /* pure */ /* unprivileged */ |
| 2954 |
static const _stp_val_array opoll_op_list[] = { |
| 2955 |
V(EPOLL_CTL_ADD), |
| 2956 |
V(EPOLL_CTL_MOD), |
| 2957 |
V(EPOLL_CTL_DEL), |
| 2958 |
{0, NULL} |
| 2959 |
}; |
| 2960 |
_stp_lookup_str(opoll_op_list, (unsigned int)STAP_ARG_o, |
| 2961 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 2962 |
%} |
| 2963 |
|
| 2964 |
%(systemtap_v <= "2.7" %? |
| 2965 |
// This function isn't actually used anywhere, so let's deprecate it. |
| 2966 |
function _epoll_events_str(e) { |
| 2967 |
if(e==1) return "EPOLLIN" |
| 2968 |
if(e==4) return "EPOLLOUT" |
| 2969 |
if(e==2) return "EPOLLPRI" |
| 2970 |
if(e==8) return "EPOLLERR" |
| 2971 |
if(e==16) return "EPOLLHUP" |
| 2972 |
if(e==-2147483648) return "EPOLLET" |
| 2973 |
if(e==1073741824) return "EPOLLONESHOT" |
| 2974 |
return sprintf("UNKNOWN VALUE: %d", e) |
| 2975 |
} |
| 2976 |
%) |
| 2977 |
|
| 2978 |
%{ |
| 2979 |
#include <linux/resource.h> |
| 2980 |
|
| 2981 |
static const _stp_val_array _stp_rlimit_resource_list[] = { |
| 2982 |
{ (unsigned int)RLIM_INFINITY, "RLIM_INFINITY"}, |
| 2983 |
V(RLIMIT_CPU), |
| 2984 |
V(RLIMIT_FSIZE), |
| 2985 |
V(RLIMIT_DATA), |
| 2986 |
V(RLIMIT_STACK), |
| 2987 |
V(RLIMIT_CORE), |
| 2988 |
V(RLIMIT_RSS), |
| 2989 |
V(RLIMIT_NPROC), |
| 2990 |
V(RLIMIT_NOFILE), |
| 2991 |
V(RLIMIT_MEMLOCK), |
| 2992 |
V(RLIMIT_AS), |
| 2993 |
V(RLIMIT_LOCKS), |
| 2994 |
V(RLIMIT_SIGPENDING), |
| 2995 |
V(RLIMIT_MSGQUEUE), |
| 2996 |
V(RLIMIT_NICE), |
| 2997 |
V(RLIMIT_RTPRIO), |
| 2998 |
#ifdef RLIMIT_RTTIME |
| 2999 |
V(RLIMIT_RTTIME), |
| 3000 |
#endif |
| 3001 |
V(RLIM_NLIMITS), |
| 3002 |
{0, NULL} |
| 3003 |
}; |
| 3004 |
|
| 3005 |
static const _stp_val_array _stp_rusage_who_list[] = { |
| 3006 |
V(RUSAGE_SELF), |
| 3007 |
{(unsigned int)RUSAGE_CHILDREN, "RUSAGE_CHILDREN"}, |
| 3008 |
{(unsigned int)RUSAGE_BOTH, "RUSAGE_BOTH"}, |
| 3009 |
V(RUSAGE_THREAD), |
| 3010 |
{0, NULL} |
| 3011 |
}; |
| 3012 |
%} |
| 3013 |
|
| 3014 |
function _rlimit_resource_str:string(r:long) |
| 3015 |
%{ /* pure */ /* unprivileged */ |
| 3016 |
_stp_lookup_str(_stp_rlimit_resource_list, (unsigned int)STAP_ARG_r, |
| 3017 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3018 |
%} |
| 3019 |
|
| 3020 |
function _rusage_who_str:string(w:long) |
| 3021 |
%{ /* pure */ /* unprivileged */ |
| 3022 |
_stp_lookup_str(_stp_rusage_who_list, (unsigned int)STAP_ARG_w, |
| 3023 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3024 |
%} |
| 3025 |
|
| 3026 |
/* for accessing 16-bit values encoded in a long */ |
| 3027 |
function __short:long(val:long) |
| 3028 |
%{ /* pure */ /* unprivileged */ |
| 3029 |
STAP_RETVALUE = (short)STAP_ARG_val; |
| 3030 |
%} |
| 3031 |
|
| 3032 |
function __ushort:long(val:long) |
| 3033 |
%{ /* pure */ /* unprivileged */ |
| 3034 |
STAP_RETVALUE = (unsigned short)STAP_ARG_val; |
| 3035 |
%} |
| 3036 |
|
| 3037 |
/* uid_t is unsigned, but calling functions take "-1" as a parameter */ |
| 3038 |
/* so this hack is necessary to correct that mismatch. */ |
| 3039 |
function __int32:long(val:long) |
| 3040 |
%{ /* pure */ /* unprivileged */ |
| 3041 |
STAP_RETVALUE = (int32_t)STAP_ARG_val; |
| 3042 |
%} |
| 3043 |
|
| 3044 |
function __uint32:long(val:long) |
| 3045 |
%{ /* pure */ /* unprivileged */ |
| 3046 |
STAP_RETVALUE = (uint32_t)STAP_ARG_val; |
| 3047 |
%} |
| 3048 |
|
| 3049 |
/* Unsigned values can get get sign-extended and become negative. */ |
| 3050 |
function __ulong:long(val:long) |
| 3051 |
%{ /* pure */ /* unprivileged */ |
| 3052 |
STAP_RETVALUE = (unsigned long)STAP_ARG_val; |
| 3053 |
%} |
| 3054 |
|
| 3055 |
function __long:long(val:long) |
| 3056 |
%{ /* pure */ /* unprivileged */ |
| 3057 |
STAP_RETVALUE = (long)STAP_ARG_val; |
| 3058 |
%} |
| 3059 |
|
| 3060 |
# For utimensat and futimesat, the directory fd can have a special value |
| 3061 |
function _dfd_str:string(d:long) |
| 3062 |
{ |
| 3063 |
if (d == @const("AT_FDCWD")) |
| 3064 |
return "AT_FDCWD" |
| 3065 |
return sprint(d) |
| 3066 |
} |
| 3067 |
|
| 3068 |
%{ |
| 3069 |
static const _stp_val_array _stp_adjtimex_return_str_list[] = { |
| 3070 |
V(TIME_OK), |
| 3071 |
V(TIME_INS), |
| 3072 |
V(TIME_DEL), |
| 3073 |
V(TIME_OOP), |
| 3074 |
V(TIME_WAIT), |
| 3075 |
V(TIME_ERROR), |
| 3076 |
V(TIME_BAD), |
| 3077 |
{0, NULL} |
| 3078 |
}; |
| 3079 |
%} |
| 3080 |
|
| 3081 |
function _adjtimex_return_str:string(ret:long) |
| 3082 |
%{ /* pure */ /* unprivileged */ |
| 3083 |
int len; |
| 3084 |
snprintf (STAP_RETVALUE, MAXSTRINGLEN, "%d (", (int)STAP_ARG_ret); |
| 3085 |
len = strlen(STAP_RETVALUE); |
| 3086 |
_stp_lookup_str2(_stp_adjtimex_return_str_list, (int)STAP_ARG_ret, |
| 3087 |
STAP_RETVALUE + len, MAXSTRINGLEN - len, 10); |
| 3088 |
strlcat (STAP_RETVALUE, ")", MAXSTRINGLEN); |
| 3089 |
%} |
| 3090 |
|
| 3091 |
%{ |
| 3092 |
static const _stp_val_array _stp_signal_list[] = { |
| 3093 |
{0, "SIG_0"}, |
| 3094 |
V(SIGHUP), |
| 3095 |
V(SIGINT), |
| 3096 |
V(SIGQUIT), |
| 3097 |
V(SIGILL), |
| 3098 |
V(SIGTRAP), |
| 3099 |
V(SIGABRT), |
| 3100 |
V(SIGBUS), |
| 3101 |
V(SIGFPE), |
| 3102 |
V(SIGKILL), |
| 3103 |
V(SIGUSR1), |
| 3104 |
V(SIGSEGV), |
| 3105 |
V(SIGPIPE), |
| 3106 |
V(SIGUSR2), |
| 3107 |
V(SIGALRM), |
| 3108 |
V(SIGTERM), |
| 3109 |
V(SIGCHLD), |
| 3110 |
V(SIGCONT), |
| 3111 |
V(SIGSTOP), |
| 3112 |
V(SIGTSTP), |
| 3113 |
V(SIGTTIN), |
| 3114 |
V(SIGTTOU), |
| 3115 |
V(SIGURG), |
| 3116 |
#ifdef SIGXCPU |
| 3117 |
V(SIGXCPU), |
| 3118 |
#endif |
| 3119 |
#ifdef SIGXFSZ |
| 3120 |
V(SIGXFSZ), |
| 3121 |
#endif |
| 3122 |
V(SIGVTALRM), |
| 3123 |
V(SIGPROF), |
| 3124 |
V(SIGWINCH), |
| 3125 |
{SIGIO,"SIGIO/SIGPOLL"}, |
| 3126 |
V(SIGPWR), |
| 3127 |
#ifdef SIGSYS |
| 3128 |
V(SIGSYS), |
| 3129 |
#endif |
| 3130 |
{SIGTRAP|0x80,"TRACESYSGOOD"}, |
| 3131 |
{0, NULL} |
| 3132 |
}; |
| 3133 |
|
| 3134 |
static void _stp_sigset_str(sigset_t *mask, char *ptr, int len) |
| 3135 |
{ |
| 3136 |
const _stp_val_array * const array = _stp_signal_list; |
| 3137 |
int i = 0, flag = 0; |
| 3138 |
while (array[i].name) { |
| 3139 |
if (array[i].val > 0 && array[i].val <= _NSIG |
| 3140 |
&& sigismember(mask, array[i].val)) { |
| 3141 |
if (flag) |
| 3142 |
strlcat(ptr, "|", len); |
| 3143 |
else |
| 3144 |
strlcat(ptr, "[", len); |
| 3145 |
strlcat(ptr, array[i].name, len); |
| 3146 |
flag = 1; |
| 3147 |
} |
| 3148 |
i++; |
| 3149 |
} |
| 3150 |
if (flag == 0) |
| 3151 |
strlcat(ptr, "[EMPTY]", len); |
| 3152 |
else |
| 3153 |
strlcat(ptr, "]", len); |
| 3154 |
} |
| 3155 |
%} |
| 3156 |
|
| 3157 |
function _signal_name:string(sig:long) |
| 3158 |
%{ /* pure */ /* unprivileged */ |
| 3159 |
_stp_lookup_str(_stp_signal_list, (unsigned int)STAP_ARG_sig, |
| 3160 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3161 |
%} |
| 3162 |
|
| 3163 |
%{ |
| 3164 |
static const _stp_val_array _stp_semctl_list[] = { |
| 3165 |
V(IPC_INFO), |
| 3166 |
V(SEM_INFO), |
| 3167 |
V(SEM_STAT), |
| 3168 |
V(GETALL), |
| 3169 |
V(GETVAL), |
| 3170 |
V(GETPID), |
| 3171 |
V(GETNCNT), |
| 3172 |
V(GETZCNT), |
| 3173 |
V(IPC_STAT), |
| 3174 |
V(SETVAL), |
| 3175 |
V(SETALL), |
| 3176 |
V(IPC_RMID), |
| 3177 |
V(IPC_SET), |
| 3178 |
{0, NULL} |
| 3179 |
}; |
| 3180 |
%} |
| 3181 |
|
| 3182 |
function _semctl_cmd:string(cmd:long) |
| 3183 |
%{ /* pure */ /* unprivileged */ |
| 3184 |
unsigned int cmd = STAP_ARG_cmd; |
| 3185 |
int len; |
| 3186 |
|
| 3187 |
#ifdef IPC_64 |
| 3188 |
if (cmd & IPC_64) { |
| 3189 |
strlcpy(STAP_RETVALUE, "IPC_64|", MAXSTRINGLEN); |
| 3190 |
cmd &= ~IPC_64; |
| 3191 |
} |
| 3192 |
#endif |
| 3193 |
len = strlen(STAP_RETVALUE); |
| 3194 |
_stp_lookup_str(_stp_semctl_list, cmd, STAP_RETVALUE + len, |
| 3195 |
MAXSTRINGLEN - len); |
| 3196 |
%} |
| 3197 |
|
| 3198 |
function _stp_sigset_u:string(setptr:long) |
| 3199 |
%{ /* pure */ |
| 3200 |
char *ptr = (char *)(uintptr_t)STAP_ARG_setptr; |
| 3201 |
sigset_t set; |
| 3202 |
|
| 3203 |
if (ptr == NULL) |
| 3204 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3205 |
else { |
| 3206 |
if (_stp_copy_from_user((char*)&set,ptr,sizeof(sigset_t)) == 0) |
| 3207 |
_stp_sigset_str(&set, STAP_RETVALUE, MAXSTRINGLEN); |
| 3208 |
else |
| 3209 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 3210 |
(unsigned long)ptr); |
| 3211 |
} |
| 3212 |
%} |
| 3213 |
|
| 3214 |
function _stp_compat_sigset_u:string(setptr:long) |
| 3215 |
%{ /* pure */ |
| 3216 |
#ifdef CONFIG_COMPAT |
| 3217 |
char *ptr = (char *)(uintptr_t)STAP_ARG_setptr; |
| 3218 |
|
| 3219 |
if (ptr == NULL) |
| 3220 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3221 |
else { |
| 3222 |
compat_sigset_t set; |
| 3223 |
|
| 3224 |
if (_stp_copy_from_user((char*)&set, ptr, |
| 3225 |
sizeof(compat_sigset_t)) == 0) { |
| 3226 |
sigset_t new_set; |
| 3227 |
sigset_from_compat(&new_set, &set); |
| 3228 |
_stp_sigset_str(&new_set, STAP_RETVALUE, MAXSTRINGLEN); |
| 3229 |
} |
| 3230 |
else |
| 3231 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 3232 |
(unsigned long)ptr); |
| 3233 |
} |
| 3234 |
#endif |
| 3235 |
%} |
| 3236 |
|
| 3237 |
%{ |
| 3238 |
static const _stp_val_array _stp_fork_list[] = { |
| 3239 |
V(CLONE_VM), |
| 3240 |
V(CLONE_FS), |
| 3241 |
V(CLONE_FILES), |
| 3242 |
V(CLONE_SIGHAND), |
| 3243 |
V(CLONE_PTRACE), |
| 3244 |
V(CLONE_VFORK), |
| 3245 |
V(CLONE_PARENT), |
| 3246 |
V(CLONE_THREAD), |
| 3247 |
V(CLONE_NEWNS), |
| 3248 |
V(CLONE_SYSVSEM), |
| 3249 |
V(CLONE_SETTLS), |
| 3250 |
V(CLONE_PARENT_SETTID), |
| 3251 |
V(CLONE_CHILD_CLEARTID), |
| 3252 |
V(CLONE_DETACHED), |
| 3253 |
V(CLONE_UNTRACED), |
| 3254 |
V(CLONE_CHILD_SETTID), |
| 3255 |
#ifdef CLONE_STOPPED |
| 3256 |
V(CLONE_STOPPED), |
| 3257 |
#endif |
| 3258 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) |
| 3259 |
V(CLONE_NEWUTS), |
| 3260 |
V(CLONE_NEWIPC), |
| 3261 |
#endif |
| 3262 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) |
| 3263 |
V(CLONE_NEWUSER), |
| 3264 |
#endif |
| 3265 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) |
| 3266 |
V(CLONE_NEWPID), |
| 3267 |
V(CLONE_NEWNET), |
| 3268 |
#endif |
| 3269 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) |
| 3270 |
V(CLONE_IO), |
| 3271 |
#endif |
| 3272 |
{0, NULL} |
| 3273 |
}; |
| 3274 |
%} |
| 3275 |
|
| 3276 |
function __fork_flags:string(flags:long) |
| 3277 |
%{ /* pure */ /* unprivileged */ |
| 3278 |
_stp_lookup_or_str(_stp_fork_list, STAP_ARG_flags & ~0xff, STAP_RETVALUE, MAXSTRINGLEN); |
| 3279 |
if ( STAP_ARG_flags & 0xff ) { |
| 3280 |
/* flags contains the termination signal */ |
| 3281 |
if (*STAP_RETVALUE) |
| 3282 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 3283 |
_stp_lookup_str(_stp_signal_list, STAP_ARG_flags & 0xff, |
| 3284 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3285 |
} |
| 3286 |
%} |
| 3287 |
|
| 3288 |
%{ |
| 3289 |
static const _stp_val_array _stp_atflag_list[] = { |
| 3290 |
#ifdef AT_SYMLINK_NOFOLLOW |
| 3291 |
V(AT_SYMLINK_NOFOLLOW), |
| 3292 |
#endif |
| 3293 |
#ifdef AT_REMOVEDIR |
| 3294 |
V(AT_REMOVEDIR), |
| 3295 |
#endif |
| 3296 |
#ifdef AT_SYMLINK_FOLLOW |
| 3297 |
V(AT_SYMLINK_FOLLOW), |
| 3298 |
#endif |
| 3299 |
#ifdef AT_NO_AUTOMOUNT |
| 3300 |
V(AT_NO_AUTOMOUNT), |
| 3301 |
#endif |
| 3302 |
#ifdef AT_EMPTY_PATH |
| 3303 |
V(AT_EMPTY_PATH), |
| 3304 |
#endif |
| 3305 |
{0, NULL} |
| 3306 |
}; |
| 3307 |
%} |
| 3308 |
|
| 3309 |
function _at_flag_str:string(f:long) |
| 3310 |
%{ /* pure */ /* unprivileged */ |
| 3311 |
_stp_lookup_or_str(_stp_atflag_list, STAP_ARG_f, STAP_RETVALUE, |
| 3312 |
MAXSTRINGLEN); |
| 3313 |
%} |
| 3314 |
|
| 3315 |
%{ |
| 3316 |
#include <linux/eventpoll.h> |
| 3317 |
%} |
| 3318 |
function _epoll_create1_flag_str:string(f:long) |
| 3319 |
%{ /* pure */ /* unprivileged */ |
| 3320 |
static const _stp_val_array epoll_create1_flags_list[] = { |
| 3321 |
#ifdef EPOLL_CLOEXEC |
| 3322 |
V(EPOLL_CLOEXEC), |
| 3323 |
#endif |
| 3324 |
{0, NULL} |
| 3325 |
}; |
| 3326 |
_stp_lookup_or_str(epoll_create1_flags_list, (unsigned int)STAP_ARG_f, |
| 3327 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3328 |
%} |
| 3329 |
|
| 3330 |
%{ |
| 3331 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) |
| 3332 |
#include <linux/eventfd.h> |
| 3333 |
#endif |
| 3334 |
|
| 3335 |
static const _stp_val_array _stp_eventfd2_flag_list[] = { |
| 3336 |
#ifdef EFD_NONBLOCK |
| 3337 |
V(EFD_NONBLOCK), |
| 3338 |
#endif |
| 3339 |
#ifdef EFD_CLOEXEC |
| 3340 |
V(EFD_CLOEXEC), |
| 3341 |
#endif |
| 3342 |
#ifdef EFD_SEMAPHORE |
| 3343 |
V(EFD_SEMAPHORE), |
| 3344 |
#endif |
| 3345 |
{0, NULL} |
| 3346 |
}; |
| 3347 |
%} |
| 3348 |
function _eventfd2_flag_str:string(flags:long) |
| 3349 |
%{ /* pure */ /* unprivileged */ |
| 3350 |
uint32_t flags = (uint32_t)STAP_ARG_flags; |
| 3351 |
_stp_lookup_or_str(_stp_eventfd2_flag_list, flags, STAP_RETVALUE, |
| 3352 |
MAXSTRINGLEN); |
| 3353 |
%} |
| 3354 |
|
| 3355 |
%{ |
| 3356 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) |
| 3357 |
#include <linux/signalfd.h> |
| 3358 |
#endif |
| 3359 |
|
| 3360 |
static const _stp_val_array _stp_signalfd4_flags_list[] = { |
| 3361 |
#ifdef SFD_NONBLOCK |
| 3362 |
V(SFD_NONBLOCK), |
| 3363 |
#endif |
| 3364 |
#ifdef SFD_CLOEXEC |
| 3365 |
V(SFD_CLOEXEC), |
| 3366 |
#endif |
| 3367 |
{0, NULL} |
| 3368 |
}; |
| 3369 |
%} |
| 3370 |
function _signalfd4_flags_str:string(f:long) |
| 3371 |
%{ /* pure */ /* unprivileged */ |
| 3372 |
uint32_t flags = (uint32_t)STAP_ARG_f; |
| 3373 |
_stp_lookup_or_str(_stp_signalfd4_flags_list, flags, STAP_RETVALUE, |
| 3374 |
MAXSTRINGLEN); |
| 3375 |
%} |
| 3376 |
|
| 3377 |
%{ |
| 3378 |
#if (defined(CONFIG_INOTIFY) || defined(CONFIG_INOTIFY_USER)) |
| 3379 |
#include <linux/inotify.h> |
| 3380 |
#endif |
| 3381 |
|
| 3382 |
static const _stp_val_array _stp_inotify_init1_flag_list[] = { |
| 3383 |
#if defined(IN_NONBLOCK) |
| 3384 |
V(IN_NONBLOCK), |
| 3385 |
#endif |
| 3386 |
#if defined(IN_CLOEXEC) |
| 3387 |
V(IN_CLOEXEC), |
| 3388 |
#endif |
| 3389 |
{0, NULL} |
| 3390 |
}; |
| 3391 |
%} |
| 3392 |
|
| 3393 |
function _inotify_init1_flag_str:string(f:long) |
| 3394 |
%{ /* pure */ /* unprivileged */ |
| 3395 |
unsigned int flags = (unsigned int)STAP_ARG_f; |
| 3396 |
_stp_lookup_or_str(_stp_inotify_init1_flag_list, flags, STAP_RETVALUE, |
| 3397 |
MAXSTRINGLEN); |
| 3398 |
%} |
| 3399 |
|
| 3400 |
function _dup3_flag_str:string(f:long) |
| 3401 |
%{ /* pure */ /* unprivileged */ |
| 3402 |
unsigned int flags = (unsigned int)STAP_ARG_f; |
| 3403 |
_stp_lookup_or_str(_stp_open_mode_flags_list, flags, STAP_RETVALUE, |
| 3404 |
MAXSTRINGLEN); |
| 3405 |
%} |
| 3406 |
|
| 3407 |
%{ |
| 3408 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0) |
| 3409 |
#include <linux/shm.h> |
| 3410 |
#else |
| 3411 |
#include <uapi/linux/shm.h> |
| 3412 |
#endif |
| 3413 |
static const _stp_val_array _stp_shmat_list[] = { |
| 3414 |
V(SHM_RDONLY), |
| 3415 |
V(SHM_RND), |
| 3416 |
V(SHM_REMAP), |
| 3417 |
V(SHM_EXEC), |
| 3418 |
{0, NULL} |
| 3419 |
}; |
| 3420 |
%} |
| 3421 |
|
| 3422 |
function _shmat_flags_str:string(f:long) |
| 3423 |
%{ /* pure */ /* unprivileged */ |
| 3424 |
_stp_lookup_or_str(_stp_shmat_list, STAP_ARG_f, STAP_RETVALUE, MAXSTRINGLEN); |
| 3425 |
%} |
| 3426 |
|
| 3427 |
|
| 3428 |
%{ |
| 3429 |
#include <linux/mman.h> |
| 3430 |
static const _stp_val_array _stp_mprotect_list[] = { |
| 3431 |
{0, "PROT_NONE"}, |
| 3432 |
V(PROT_READ), |
| 3433 |
V(PROT_WRITE), |
| 3434 |
V(PROT_EXEC), |
| 3435 |
V(PROT_SEM), |
| 3436 |
V(PROT_GROWSDOWN), |
| 3437 |
V(PROT_GROWSUP), |
| 3438 |
#ifdef PROT_SAO // powerpc only |
| 3439 |
V(PROT_SAO), |
| 3440 |
#endif |
| 3441 |
{0, NULL} |
| 3442 |
}; |
| 3443 |
%} |
| 3444 |
|
| 3445 |
function _mprotect_prot_str:string(prot:long) |
| 3446 |
%{ /* pure */ /* unprivileged */ |
| 3447 |
_stp_lookup_or_str(_stp_mprotect_list, STAP_ARG_prot, STAP_RETVALUE, MAXSTRINGLEN); |
| 3448 |
%} |
| 3449 |
|
| 3450 |
%{ |
| 3451 |
#include <linux/mman.h> |
| 3452 |
static const _stp_val_array _stp_mmap_list[] = { |
| 3453 |
V(MAP_SHARED), |
| 3454 |
V(MAP_PRIVATE), |
| 3455 |
V(MAP_FIXED), |
| 3456 |
V(MAP_ANONYMOUS), |
| 3457 |
V(MAP_GROWSDOWN), |
| 3458 |
V(MAP_DENYWRITE), |
| 3459 |
V(MAP_EXECUTABLE), |
| 3460 |
V(MAP_LOCKED), |
| 3461 |
V(MAP_NORESERVE), |
| 3462 |
V(MAP_POPULATE), |
| 3463 |
V(MAP_NONBLOCK), |
| 3464 |
#ifdef MAP_STACK |
| 3465 |
V(MAP_STACK), |
| 3466 |
#endif |
| 3467 |
#ifdef MAP_HUGETLB |
| 3468 |
V(MAP_HUGETLB), |
| 3469 |
#endif |
| 3470 |
#ifdef MAP_UNINITIALIZED |
| 3471 |
V(MAP_UNINITIALIZED), |
| 3472 |
#endif |
| 3473 |
#ifdef MAP_32BIT // x86 only |
| 3474 |
V(MAP_32BIT), |
| 3475 |
#endif |
| 3476 |
{0, NULL} |
| 3477 |
}; |
| 3478 |
%} |
| 3479 |
|
| 3480 |
function _mmap_flags:string(flags:long) |
| 3481 |
%{ /* pure */ /* unprivileged */ |
| 3482 |
#ifdef MAP_HUGE_SHIFT |
| 3483 |
// Extract the huge page size for special treatment. |
| 3484 |
u8 huge = (STAP_ARG_flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK; |
| 3485 |
STAP_ARG_flags &= ~((long)MAP_HUGE_MASK << MAP_HUGE_SHIFT); |
| 3486 |
|
| 3487 |
if (huge) { |
| 3488 |
// MAP_HUGE_2MB and MAP_HUGE_1GB are predefined on x86, but |
| 3489 |
// the log2 value can be used to represent any power of two. |
| 3490 |
const char* suffix = ""; |
| 3491 |
if (huge >= 60) { huge -= 60; suffix = "EB"; } |
| 3492 |
else if (huge >= 50) { huge -= 50; suffix = "PB"; } |
| 3493 |
else if (huge >= 40) { huge -= 40; suffix = "TB"; } |
| 3494 |
else if (huge >= 30) { huge -= 30; suffix = "GB"; } |
| 3495 |
else if (huge >= 20) { huge -= 20; suffix = "MB"; } |
| 3496 |
else if (huge >= 10) { huge -= 10; suffix = "KB"; } |
| 3497 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "MAP_HUGE_%ld%s|", 1L << huge, suffix); |
| 3498 |
} |
| 3499 |
#endif |
| 3500 |
|
| 3501 |
_stp_lookup_or_str(_stp_mmap_list, STAP_ARG_flags, STAP_RETVALUE, MAXSTRINGLEN); |
| 3502 |
%} |
| 3503 |
|
| 3504 |
%( systemtap_v <= "3.0" %? |
| 3505 |
# old mmap functions passed in a struct like this. |
| 3506 |
# |
| 3507 |
function get_mmap_args:string (args:long) |
| 3508 |
%{ /* pure */ |
| 3509 |
#if defined (__x86_64__) || defined (__ia64__) |
| 3510 |
struct mmap_arg_struct { |
| 3511 |
unsigned int addr; |
| 3512 |
unsigned int len; |
| 3513 |
unsigned int prot; |
| 3514 |
unsigned int flags; |
| 3515 |
int fd; |
| 3516 |
unsigned int offset; |
| 3517 |
} a; |
| 3518 |
#else |
| 3519 |
struct mmap_arg_struct { |
| 3520 |
unsigned long addr; |
| 3521 |
unsigned long len; |
| 3522 |
unsigned long prot; |
| 3523 |
unsigned long flags; |
| 3524 |
long fd; |
| 3525 |
unsigned long offset; |
| 3526 |
} a; |
| 3527 |
#endif |
| 3528 |
|
| 3529 |
if(_stp_copy_from_user((char *)&a,(char *)(uintptr_t)STAP_ARG_args, sizeof(a))== 0) { |
| 3530 |
int len; |
| 3531 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx, %lu, ", |
| 3532 |
(unsigned long)a.addr, (unsigned long)a.len); |
| 3533 |
_stp_lookup_or_str(_stp_mprotect_list, a.prot, STAP_RETVALUE, MAXSTRINGLEN); |
| 3534 |
strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 3535 |
_stp_lookup_or_str(_stp_mmap_list, a.flags, STAP_RETVALUE, MAXSTRINGLEN); |
| 3536 |
strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 3537 |
len = strlen(STAP_RETVALUE); |
| 3538 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, "%ld, %ld", (long)a.fd, (long)a.offset); |
| 3539 |
} else |
| 3540 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 3541 |
(unsigned long)STAP_ARG_args); |
| 3542 |
%} |
| 3543 |
%) |
| 3544 |
|
| 3545 |
|
| 3546 |
function _sighandler_str:string(uaddr:long) |
| 3547 |
%{ /* pure */ /* unprivileged */ |
| 3548 |
static const _stp_val_array _stp_sa_handler_list[] = { |
| 3549 |
{0, "SIG_DFL"}, |
| 3550 |
{1, "SIG_IGN"}, |
| 3551 |
{0, NULL} |
| 3552 |
}; |
| 3553 |
_stp_lookup_str(_stp_sa_handler_list, (long)STAP_ARG_uaddr, STAP_RETVALUE, MAXSTRINGLEN); |
| 3554 |
%} |
| 3555 |
|
| 3556 |
%{ |
| 3557 |
static void _stp_sigaction_str(struct sigaction *act, char *ptr, int len) |
| 3558 |
{ |
| 3559 |
static const _stp_val_array _stp_sa_handler_list[] = { |
| 3560 |
{0, "SIG_DFL"}, |
| 3561 |
{1, "SIG_IGN"}, |
| 3562 |
{0, NULL} |
| 3563 |
}; |
| 3564 |
|
| 3565 |
static const _stp_val_array _stp_sa_flags_list[] = { |
| 3566 |
V(SA_NOCLDSTOP), |
| 3567 |
V(SA_NOCLDWAIT), |
| 3568 |
V(SA_RESETHAND), |
| 3569 |
V(SA_ONSTACK), |
| 3570 |
V(SA_RESTART), |
| 3571 |
V(SA_NODEFER), |
| 3572 |
V(SA_SIGINFO), |
| 3573 |
#ifdef SA_RESTORER |
| 3574 |
V(SA_RESTORER), |
| 3575 |
#endif |
| 3576 |
{0, NULL} |
| 3577 |
}; |
| 3578 |
|
| 3579 |
int slen; |
| 3580 |
_stp_lookup_str(_stp_sa_handler_list, (long)act->sa_handler, |
| 3581 |
ptr, len); |
| 3582 |
if (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL) |
| 3583 |
{ |
| 3584 |
strlcat (ptr, ", ", len); |
| 3585 |
_stp_lookup_or_str(_stp_sa_flags_list, act->sa_flags, ptr, len); |
| 3586 |
strlcat (ptr, ", ", len); |
| 3587 |
#if !defined (__ia64__) && !defined (__mips__) && !defined(__riscv) |
| 3588 |
slen = strlen(ptr); |
| 3589 |
_stp_snprintf(ptr + slen, len - slen, |
| 3590 |
"0x%lx, ", (long)act->sa_restorer); |
| 3591 |
#endif |
| 3592 |
_stp_sigset_str(&act->sa_mask, ptr, len); |
| 3593 |
} |
| 3594 |
} |
| 3595 |
%} |
| 3596 |
|
| 3597 |
function _stp_sigmask_str:string(sigmask:long) |
| 3598 |
%{ /* pure */ |
| 3599 |
unsigned long mask = (unsigned long)STAP_ARG_sigmask; |
| 3600 |
sigset_t set; |
| 3601 |
|
| 3602 |
siginitset(&set, mask); |
| 3603 |
_stp_sigset_str(&set, STAP_RETVALUE, MAXSTRINGLEN); |
| 3604 |
%} |
| 3605 |
|
| 3606 |
function _struct_sigaction_u:string(uaddr:long) |
| 3607 |
%{ /* pure */ |
| 3608 |
struct sigaction act; |
| 3609 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 3610 |
|
| 3611 |
if (ptr == NULL) |
| 3612 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3613 |
else |
| 3614 |
{ |
| 3615 |
if(_stp_copy_from_user((char*)&act, ptr, |
| 3616 |
sizeof(struct sigaction)) == 0) |
| 3617 |
_stp_sigaction_str(&act, STAP_RETVALUE, MAXSTRINGLEN); |
| 3618 |
else |
| 3619 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", (unsigned long)ptr); |
| 3620 |
} |
| 3621 |
%} |
| 3622 |
|
| 3623 |
function _struct_sigaction32_u:string(uaddr:long) |
| 3624 |
%{ /* pure */ |
| 3625 |
#ifdef CONFIG_COMPAT |
| 3626 |
#include <linux/compat.h> |
| 3627 |
|
| 3628 |
#ifdef AUTOCONF_COMPAT_SIGACTION |
| 3629 |
struct compat_sigaction act32; |
| 3630 |
#else |
| 3631 |
// There seems to be no public cross arch header that defines this. |
| 3632 |
// For x86, you can find it in asm/ia32.h. For s390x, it is defined |
| 3633 |
// in a private header. |
| 3634 |
struct sigaction32 { |
| 3635 |
compat_uptr_t sa_handler; |
| 3636 |
unsigned int sa_flags; |
| 3637 |
unsigned int sa_restorer; /* Another 32 bit pointer */ |
| 3638 |
compat_sigset_t sa_mask; /* A 32 bit mask */ |
| 3639 |
}; |
| 3640 |
|
| 3641 |
struct sigaction32 act32; |
| 3642 |
#endif |
| 3643 |
|
| 3644 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 3645 |
|
| 3646 |
if (ptr == NULL) |
| 3647 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3648 |
else |
| 3649 |
{ |
| 3650 |
if(_stp_copy_from_user((char*)&act32, ptr, |
| 3651 |
sizeof(act32)) == 0) |
| 3652 |
{ |
| 3653 |
struct sigaction act; |
| 3654 |
|
| 3655 |
act.sa_handler = (void *)compat_ptr(act32.sa_handler); |
| 3656 |
act.sa_flags = (unsigned long)act32.sa_flags; |
| 3657 |
#ifdef SA_RESTORER |
| 3658 |
act.sa_restorer = (void *)compat_ptr(act32.sa_restorer); |
| 3659 |
#endif |
| 3660 |
/* swap words around to get right endian order. */ |
| 3661 |
switch (_NSIG_WORDS) |
| 3662 |
{ |
| 3663 |
case 4: act.sa_mask.sig[3] = act32.sa_mask.sig[6] |
| 3664 |
| (((long)act32.sa_mask.sig[7]) << 32); |
| 3665 |
fallthrough; |
| 3666 |
case 3: act.sa_mask.sig[2] = act32.sa_mask.sig[4] |
| 3667 |
| (((long)act32.sa_mask.sig[5]) << 32); |
| 3668 |
fallthrough; |
| 3669 |
case 2: act.sa_mask.sig[1] = act32.sa_mask.sig[2] |
| 3670 |
| (((long)act32.sa_mask.sig[3]) << 32); |
| 3671 |
fallthrough; |
| 3672 |
case 1: act.sa_mask.sig[0] = act32.sa_mask.sig[0] |
| 3673 |
| (((long)act32.sa_mask.sig[1]) << 32); |
| 3674 |
} |
| 3675 |
|
| 3676 |
_stp_sigaction_str(&act, STAP_RETVALUE, MAXSTRINGLEN); |
| 3677 |
} |
| 3678 |
else |
| 3679 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", (unsigned long)ptr); |
| 3680 |
} |
| 3681 |
#endif |
| 3682 |
%} |
| 3683 |
|
| 3684 |
function _struct_old_sigaction32_u:string(uaddr:long) |
| 3685 |
%{ /* pure */ |
| 3686 |
#ifdef CONFIG_COMPAT |
| 3687 |
#include <linux/compat.h> |
| 3688 |
|
| 3689 |
#ifdef CONFIG_COMPAT_OLD_SIGACTION |
| 3690 |
struct compat_old_sigaction act32; |
| 3691 |
#else |
| 3692 |
// There seems to be no public cross arch header that defines this. |
| 3693 |
// For x86, you can find it in asm/ia32.h. For s390x, it is defined |
| 3694 |
// in a private header. |
| 3695 |
struct old_sigaction32 { |
| 3696 |
compat_uptr_t sa_handler; |
| 3697 |
compat_old_sigset_t sa_mask; /* A 32 bit mask */ |
| 3698 |
unsigned int sa_flags; |
| 3699 |
unsigned int sa_restorer; /* Another 32 bit pointer */ |
| 3700 |
}; |
| 3701 |
|
| 3702 |
struct old_sigaction32 act32; |
| 3703 |
#endif |
| 3704 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 3705 |
|
| 3706 |
if (ptr == NULL) |
| 3707 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3708 |
else |
| 3709 |
{ |
| 3710 |
if(_stp_copy_from_user((char*)&act32, ptr, sizeof(act32)) == 0) |
| 3711 |
{ |
| 3712 |
struct sigaction act; |
| 3713 |
|
| 3714 |
act.sa_handler = (void *)compat_ptr(act32.sa_handler); |
| 3715 |
#ifdef SA_RESTORER |
| 3716 |
act.sa_restorer = (void *)compat_ptr(act32.sa_restorer); |
| 3717 |
#endif |
| 3718 |
act.sa_flags = (unsigned long)act32.sa_flags; |
| 3719 |
siginitset(&act.sa_mask, act32.sa_mask); |
| 3720 |
_stp_sigaction_str(&act, STAP_RETVALUE, MAXSTRINGLEN); |
| 3721 |
} |
| 3722 |
else |
| 3723 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", (unsigned long)ptr); |
| 3724 |
} |
| 3725 |
#endif |
| 3726 |
%} |
| 3727 |
|
| 3728 |
/* |
| 3729 |
* Function irqflags_str : |
| 3730 |
* Returns the symbolic string representation of the IRQ flags. |
| 3731 |
* |
| 3732 |
*/ |
| 3733 |
|
| 3734 |
%{ |
| 3735 |
#include <linux/interrupt.h> |
| 3736 |
#ifndef IRQF_ONESHOT |
| 3737 |
#define IRQF_ONESHOT 0x00002000 |
| 3738 |
#endif |
| 3739 |
static const _stp_val_array _stp_irq_list[] = { |
| 3740 |
#ifdef IRQF_DISABLED |
| 3741 |
V(IRQF_DISABLED), |
| 3742 |
#endif |
| 3743 |
#ifdef IRQF_SAMPLE_RANDOM |
| 3744 |
V(IRQF_SAMPLE_RANDOM), |
| 3745 |
#endif |
| 3746 |
#ifdef IRQF_SHARED |
| 3747 |
V(IRQF_SHARED), |
| 3748 |
#endif |
| 3749 |
#ifdef IRQF_PROBE_SHARED |
| 3750 |
V(IRQF_PROBE_SHARED), |
| 3751 |
#endif |
| 3752 |
#ifdef IRQF_TIMER |
| 3753 |
V(IRQF_TIMER), |
| 3754 |
#endif |
| 3755 |
#ifdef IRQF_PERCPU |
| 3756 |
V(IRQF_PERCPU), |
| 3757 |
#endif |
| 3758 |
#ifdef IRQF_NOBALANCING |
| 3759 |
V(IRQF_NOBALANCING), |
| 3760 |
#endif |
| 3761 |
#ifdef IRQF_IRQPOLL |
| 3762 |
V(IRQF_IRQPOLL), |
| 3763 |
#endif |
| 3764 |
V(IRQF_ONESHOT), |
| 3765 |
{0, NULL} |
| 3766 |
}; |
| 3767 |
%} |
| 3768 |
|
| 3769 |
function irqflags_str:string(f:long) |
| 3770 |
%{ /* pure */ /* unprivileged */ |
| 3771 |
_stp_lookup_or_str(_stp_irq_list, STAP_ARG_f, STAP_RETVALUE, MAXSTRINGLEN); |
| 3772 |
%} |
| 3773 |
|
| 3774 |
@__private30 function _stp_struct_iovec_u:string(iov_uaddr:long) |
| 3775 |
%{ /* pure */ |
| 3776 |
char *iov_uaddr = (void *)(uintptr_t)STAP_ARG_iov_uaddr; |
| 3777 |
struct iovec iov = { 0 }; |
| 3778 |
if (iov_uaddr == NULL) |
| 3779 |
strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3780 |
else { |
| 3781 |
if (_stp_copy_from_user((char*)&iov, iov_uaddr, |
| 3782 |
sizeof(struct iovec)) == 0) { |
| 3783 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 3784 |
"[{%#lx, %lu}]", iov.iov_base, |
| 3785 |
iov.iov_len); |
| 3786 |
} |
| 3787 |
else |
| 3788 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 3789 |
(unsigned long)iov_uaddr); |
| 3790 |
} |
| 3791 |
%} |
| 3792 |
|
| 3793 |
@__private30 function _stp_struct_compat_iovec_u:string(iov_uaddr:long) |
| 3794 |
%{ /* pure */ |
| 3795 |
#ifdef CONFIG_COMPAT |
| 3796 |
char *iov_uaddr = (void *)(uintptr_t)STAP_ARG_iov_uaddr; |
| 3797 |
struct compat_iovec iov = { 0 }; |
| 3798 |
if (iov_uaddr == NULL) |
| 3799 |
strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 3800 |
else { |
| 3801 |
if (_stp_copy_from_user((char*)&iov, iov_uaddr, |
| 3802 |
sizeof(struct compat_iovec)) == 0) { |
| 3803 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 3804 |
"[{%#lx, %lu}]", iov.iov_base, |
| 3805 |
iov.iov_len); |
| 3806 |
} |
| 3807 |
else |
| 3808 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 3809 |
(unsigned long)iov_uaddr); |
| 3810 |
} |
| 3811 |
#endif |
| 3812 |
%} |
| 3813 |
|
| 3814 |
%{ |
| 3815 |
#include <linux/ptrace.h> |
| 3816 |
static const _stp_val_array _stp_ptrace_options_list[] = { |
| 3817 |
#ifdef PTRACE_O_EXITKILL |
| 3818 |
V(PTRACE_O_EXITKILL), |
| 3819 |
#endif |
| 3820 |
V(PTRACE_O_TRACECLONE), |
| 3821 |
V(PTRACE_O_TRACEEXEC), |
| 3822 |
V(PTRACE_O_TRACEEXIT), |
| 3823 |
V(PTRACE_O_TRACEFORK), |
| 3824 |
V(PTRACE_O_TRACESYSGOOD), |
| 3825 |
V(PTRACE_O_TRACEVFORK), |
| 3826 |
V(PTRACE_O_TRACEVFORKDONE), |
| 3827 |
#ifdef PTRACE_O_TRACESECCOMP |
| 3828 |
V(PTRACE_O_TRACESECCOMP), |
| 3829 |
#endif |
| 3830 |
{0, NULL} |
| 3831 |
}; |
| 3832 |
%} |
| 3833 |
|
| 3834 |
/* PTRACE_SETOPTIONS parser of the DATA parameter. */ |
| 3835 |
function _ptrace_options_str:string(f:long) |
| 3836 |
%{ /* pure */ /* unprivileged */ |
| 3837 |
unsigned long f = (unsigned long)STAP_ARG_f; |
| 3838 |
_stp_lookup_or_str(_stp_ptrace_options_list, f, STAP_RETVALUE, |
| 3839 |
MAXSTRINGLEN); |
| 3840 |
%} |
| 3841 |
|
| 3842 |
/* ptrace syscall provisioning of argstr. */ |
| 3843 |
%{ |
| 3844 |
#include <linux/elf.h> |
| 3845 |
static const _stp_val_array _stp_elf_notes_list[] = { |
| 3846 |
V(NT_PRSTATUS), |
| 3847 |
V(NT_PRFPREG), |
| 3848 |
V(NT_PRPSINFO), |
| 3849 |
V(NT_TASKSTRUCT), |
| 3850 |
V(NT_AUXV), |
| 3851 |
#ifdef NT_SIGINFO |
| 3852 |
V(NT_SIGINFO), |
| 3853 |
#endif |
| 3854 |
#ifdef NT_FILE |
| 3855 |
V(NT_FILE), |
| 3856 |
#endif |
| 3857 |
V(NT_PRXFPREG), |
| 3858 |
#ifdef NT_PPC_VMX |
| 3859 |
V(NT_PPC_VMX), |
| 3860 |
#endif |
| 3861 |
#ifdef NT_PPC_SPE |
| 3862 |
V(NT_PPC_SPE), |
| 3863 |
#endif |
| 3864 |
#ifdef NT_PPC_VSX |
| 3865 |
V(NT_PPC_VSX), |
| 3866 |
#endif |
| 3867 |
#ifdef NT_386_TLS |
| 3868 |
V(NT_386_TLS), |
| 3869 |
#endif |
| 3870 |
#ifdef NT_386_IOPERM |
| 3871 |
V(NT_386_IOPERM), |
| 3872 |
#endif |
| 3873 |
#ifdef NT_X86_XSTATE |
| 3874 |
V(NT_X86_XSTATE), |
| 3875 |
#endif |
| 3876 |
#ifdef NT_S390_HIGH_GPRS |
| 3877 |
V(NT_S390_HIGH_GPRS), |
| 3878 |
#endif |
| 3879 |
#ifdef NT_S390_TIMER |
| 3880 |
V(NT_S390_TIMER), |
| 3881 |
#endif |
| 3882 |
#ifdef NT_S390_TODCMP |
| 3883 |
V(NT_S390_TODCMP), |
| 3884 |
#endif |
| 3885 |
#ifdef NT_S390_TODPREG |
| 3886 |
V(NT_S390_TODPREG), |
| 3887 |
#endif |
| 3888 |
#ifdef NT_S390_CTRS |
| 3889 |
V(NT_S390_CTRS), |
| 3890 |
#endif |
| 3891 |
#ifdef NT_S390_PREFIX |
| 3892 |
V(NT_S390_PREFIX), |
| 3893 |
#endif |
| 3894 |
#ifdef NT_S390_LAST_BREAK |
| 3895 |
V(NT_S390_LAST_BREAK), |
| 3896 |
#endif |
| 3897 |
#ifdef NT_S390_SYSTEM_CALL |
| 3898 |
V(NT_S390_SYSTEM_CALL), |
| 3899 |
#endif |
| 3900 |
#ifdef NT_S390_TDB |
| 3901 |
V(NT_S390_TDB), |
| 3902 |
#endif |
| 3903 |
#ifdef NT_S390_VXRS_LOW |
| 3904 |
V(NT_S390_VXRS_LOW), |
| 3905 |
#endif |
| 3906 |
#ifdef NT_S390_VXRS_HIGH |
| 3907 |
V(NT_S390_VXRS_HIGH), |
| 3908 |
#endif |
| 3909 |
#ifdef NT_ARM_VFP |
| 3910 |
V(NT_ARM_VFP), |
| 3911 |
#endif |
| 3912 |
#ifdef NT_ARM_TLS |
| 3913 |
V(NT_ARM_TLS), |
| 3914 |
#endif |
| 3915 |
#ifdef NT_ARM_HW_BREAK |
| 3916 |
V(NT_ARM_HW_BREAK), |
| 3917 |
#endif |
| 3918 |
#ifdef NT_ARM_HW_WATCH |
| 3919 |
V(NT_ARM_HW_WATCH), |
| 3920 |
#endif |
| 3921 |
#ifdef NT_ARM_SYSTEM_CALL |
| 3922 |
V(NT_ARM_SYSTEM_CALL), |
| 3923 |
#endif |
| 3924 |
#ifdef NT_METAG_CBUF |
| 3925 |
V(NT_METAG_CBUF), |
| 3926 |
#endif |
| 3927 |
#ifdef NT_METAG_RPIPE |
| 3928 |
V(NT_METAG_RPIPE), |
| 3929 |
#endif |
| 3930 |
#ifdef NT_METAG_TLS |
| 3931 |
V(NT_METAG_TLS), |
| 3932 |
#endif |
| 3933 |
{0, NULL} |
| 3934 |
}; |
| 3935 |
%} |
| 3936 |
|
| 3937 |
@__private30 function _stp_elf_notes_str:string(value:long) |
| 3938 |
%{ /* pure */ /* unprivileged */ |
| 3939 |
_stp_lookup_str(_stp_elf_notes_list, (unsigned long)STAP_ARG_value, |
| 3940 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 3941 |
%} |
| 3942 |
|
| 3943 |
%{ |
| 3944 |
#ifndef PTRACE_GETREGSET |
| 3945 |
# define PTRACE_GETREGSET 0x4204 |
| 3946 |
#endif |
| 3947 |
#ifndef PTRACE_SETREGSET |
| 3948 |
# define PTRACE_SETREGSET 0x4205 |
| 3949 |
#endif |
| 3950 |
#ifndef PTRACE_SEIZE |
| 3951 |
# define PTRACE_SEIZE 0x4206 |
| 3952 |
#endif |
| 3953 |
#ifndef PTRACE_INTERRUPT |
| 3954 |
# define PTRACE_INTERRUPT 0x4207 |
| 3955 |
#endif |
| 3956 |
#ifndef PTRACE_LISTEN |
| 3957 |
# define PTRACE_LISTEN 0x4208 |
| 3958 |
#endif |
| 3959 |
#ifndef PTRACE_PEEKSIGINFO |
| 3960 |
# define PTRACE_PEEKSIGINFO 0x4209 |
| 3961 |
#endif |
| 3962 |
#ifndef PTRACE_GETSIGMASK |
| 3963 |
# define PTRACE_GETSIGMASK 0x420a |
| 3964 |
#endif |
| 3965 |
#ifndef PTRACE_SETSIGMASK |
| 3966 |
# define PTRACE_SETSIGMASK 0x420b |
| 3967 |
#endif |
| 3968 |
|
| 3969 |
/* These are the architecture-independent ptrace requests (although |
| 3970 |
* some return architecture-dependent register buffers). */ |
| 3971 |
|
| 3972 |
static const _stp_val_array _stp_ptrace_request_list[] = { |
| 3973 |
V(PTRACE_TRACEME), |
| 3974 |
V(PTRACE_PEEKTEXT), |
| 3975 |
V(PTRACE_PEEKDATA), |
| 3976 |
V(PTRACE_PEEKUSR), |
| 3977 |
V(PTRACE_POKETEXT), |
| 3978 |
V(PTRACE_POKEDATA), |
| 3979 |
V(PTRACE_POKEUSR), |
| 3980 |
V(PTRACE_CONT), |
| 3981 |
V(PTRACE_KILL), |
| 3982 |
V(PTRACE_SINGLESTEP), |
| 3983 |
V(PTRACE_ATTACH), |
| 3984 |
V(PTRACE_DETACH), |
| 3985 |
V(PTRACE_SYSCALL), |
| 3986 |
V(PTRACE_SETOPTIONS), |
| 3987 |
V(PTRACE_GETEVENTMSG), |
| 3988 |
V(PTRACE_GETSIGINFO), |
| 3989 |
V(PTRACE_SETSIGINFO), |
| 3990 |
V(PTRACE_GETREGSET), |
| 3991 |
V(PTRACE_SETREGSET), |
| 3992 |
V(PTRACE_SEIZE), |
| 3993 |
V(PTRACE_INTERRUPT), |
| 3994 |
V(PTRACE_LISTEN), |
| 3995 |
V(PTRACE_PEEKSIGINFO), |
| 3996 |
V(PTRACE_GETSIGMASK), |
| 3997 |
V(PTRACE_SETSIGMASK), |
| 3998 |
{0, NULL} |
| 3999 |
}; |
| 4000 |
%} |
| 4001 |
|
| 4002 |
@__private30 function __ptrace_request_str:string(request:long) |
| 4003 |
%{ /* pure */ /* unprivileged */ |
| 4004 |
_stp_lookup_str(_stp_ptrace_request_list, |
| 4005 |
(unsigned long)STAP_ARG_request, STAP_RETVALUE, |
| 4006 |
MAXSTRINGLEN); |
| 4007 |
%} |
| 4008 |
|
| 4009 |
function _ptrace_argstr(request, pid, addr, data) |
| 4010 |
{ |
| 4011 |
// Handle arch-specific ptrace requests first. |
| 4012 |
retval=_arch_ptrace_argstr(request, pid, addr, data) |
| 4013 |
if (retval != "") |
| 4014 |
return retval |
| 4015 |
|
| 4016 |
// Handle generic ptrace requests. |
| 4017 |
if (request == @const("PTRACE_PEEKTEXT") |
| 4018 |
|| request == @const("PTRACE_PEEKDATA") |
| 4019 |
|| request == @const("PTRACE_PEEKUSR")) |
| 4020 |
/* For PTRACE_PEEK{TEXT,DATA,USR}, 'data' is ignored |
| 4021 |
* from the user's point of view, but glibc stores the |
| 4022 |
* result at the 'data' address. */ |
| 4023 |
return sprintf("%s, %d, %p, [%p]", |
| 4024 |
__ptrace_request_str(request), pid, addr, data) |
| 4025 |
if (request == @const("PTRACE_POKETEXT") |
| 4026 |
|| request == @const("PTRACE_POKEDATA") |
| 4027 |
|| request == @const("PTRACE_POKEUSR") |
| 4028 |
|| request == @const("PTRACE_PEEKSIGINFO")) |
| 4029 |
return sprintf("%s, %d, %p, %p", |
| 4030 |
__ptrace_request_str(request), pid, addr, data) |
| 4031 |
if (request == @const("PTRACE_CONT") |
| 4032 |
|| request == @const("PTRACE_SYSCALL") |
| 4033 |
|| request == @const("PTRACE_SINGLESTEP") |
| 4034 |
|| request == @const("PTRACE_DETACH")) |
| 4035 |
return sprintf("%s, %d, %#x, %s", |
| 4036 |
__ptrace_request_str(request), pid, addr, |
| 4037 |
_signal_name (data)) |
| 4038 |
if (request == @const("PTRACE_GETSIGINFO") |
| 4039 |
|| request == @const("PTRACE_SETSIGINFO") |
| 4040 |
|| request == @const("PTRACE_GETEVENTMSG") |
| 4041 |
|| request == @const("PTRACE_GETSIGMASK") |
| 4042 |
|| request == @const("PTRACE_SETSIGMASK")) |
| 4043 |
return sprintf("%s, %d, %#x, %p", |
| 4044 |
__ptrace_request_str(request), pid, addr, data) |
| 4045 |
if (request == @const("PTRACE_GETREGSET") |
| 4046 |
|| request == @const("PTRACE_SETREGSET")) |
| 4047 |
return sprintf("%s, %d, %s, %s", |
| 4048 |
__ptrace_request_str(request), pid, |
| 4049 |
_stp_elf_notes_str(addr), |
| 4050 |
(@__compat_task |
| 4051 |
? _stp_struct_compat_iovec_u(data) |
| 4052 |
: _stp_struct_iovec_u(data))) |
| 4053 |
if (request == @const("PTRACE_TRACEME") |
| 4054 |
|| request == @const("PTRACE_KILL") |
| 4055 |
|| request == @const("PTRACE_ATTACH") |
| 4056 |
|| request == @const("PTRACE_SEIZE") |
| 4057 |
|| request == @const("PTRACE_INTERRUPT") |
| 4058 |
|| request == @const("PTRACE_LISTEN")) |
| 4059 |
return sprintf("%s, %d, %#x, %#x", |
| 4060 |
__ptrace_request_str(request), pid, addr, data) |
| 4061 |
if (request == @const("PTRACE_SETOPTIONS")) |
| 4062 |
return sprintf("PTRACE_SETOPTIONS, %d, %#x, %s", pid, |
| 4063 |
addr, _ptrace_options_str(data)) |
| 4064 |
|
| 4065 |
return sprintf("%s, %d, %p, %p", __ptrace_request_str(request), |
| 4066 |
pid, addr, data) |
| 4067 |
} |
| 4068 |
|
| 4069 |
/* ptrace.return syscall decoder for PTRACE_GETEVENTMSG. */ |
| 4070 |
function _ptrace_return_geteventmsg_data(request,data) |
| 4071 |
{ |
| 4072 |
if (request == @const("PTRACE_GETEVENTMSG")) |
| 4073 |
return user_long(data) |
| 4074 |
} |
| 4075 |
|
| 4076 |
%{ |
| 4077 |
#include <linux/swap.h> |
| 4078 |
|
| 4079 |
static const _stp_val_array _stp_swapon_flags_list[] = { |
| 4080 |
V(SWAP_FLAG_PREFER), |
| 4081 |
#ifdef SWAP_FLAG_DISCARD |
| 4082 |
V(SWAP_FLAG_DISCARD), |
| 4083 |
#endif |
| 4084 |
#ifdef SWAP_FLAG_DISCARD_ONCE |
| 4085 |
V(SWAP_FLAG_DISCARD_ONCE), |
| 4086 |
#endif |
| 4087 |
#ifdef SWAP_FLAG_DISCARD_PAGES |
| 4088 |
V(SWAP_FLAG_DISCARD_PAGES), |
| 4089 |
#endif |
| 4090 |
{0, NULL} |
| 4091 |
}; |
| 4092 |
%} |
| 4093 |
|
| 4094 |
function _swapon_flags_str:string(flags:long) |
| 4095 |
%{ /* pure */ /* unprivileged */ |
| 4096 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 4097 |
_stp_lookup_or_str(_stp_swapon_flags_list, |
| 4098 |
(flags & ~SWAP_FLAG_PRIO_MASK), STAP_RETVALUE, |
| 4099 |
MAXSTRINGLEN); |
| 4100 |
if (STAP_ARG_flags & SWAP_FLAG_PREFER) { |
| 4101 |
int slen; |
| 4102 |
slen = strlen(STAP_RETVALUE); |
| 4103 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, |
| 4104 |
"|%d", flags & SWAP_FLAG_PRIO_MASK); |
| 4105 |
} |
| 4106 |
%} |
| 4107 |
|
| 4108 |
/* do_fork helper function to determine fork type. */ |
| 4109 |
@__private30 function __is_user_regs:long (regs:long) |
| 4110 |
%{ /* pure */ |
| 4111 |
struct pt_regs * regs = (void *)((uintptr_t)STAP_ARG_regs); |
| 4112 |
/* copied from asm/ptrace.h */ |
| 4113 |
#if defined(__i386__) |
| 4114 |
#ifdef STAPCONF_X86_UNIREGS |
| 4115 |
int cs = kread(®s->cs); |
| 4116 |
#else |
| 4117 |
int cs = kread(®s->xcs); |
| 4118 |
#endif |
| 4119 |
STAP_RETVALUE = (!!((cs & 3))); |
| 4120 |
#elif defined(__x86_64__) |
| 4121 |
unsigned long cs = kread(®s->cs); |
| 4122 |
STAP_RETVALUE = (!!((cs & 3))); |
| 4123 |
#elif defined(__ia64__) |
| 4124 |
unsigned long psr = kread(®s->cr_ipsr); |
| 4125 |
STAP_RETVALUE = (((struct ia64_psr *) &psr)->cpl != 0); |
| 4126 |
#elif defined(__powerpc64__) |
| 4127 |
unsigned long msr = kread(®s->msr); |
| 4128 |
STAP_RETVALUE = ((msr >> MSR_PR_LG) & 0x1); |
| 4129 |
#elif defined(__powerpc__) |
| 4130 |
unsigned long msr = kread(®s->msr); |
| 4131 |
STAP_RETVALUE = ((msr >> MSR_PR) != 0); |
| 4132 |
#elif defined(__arm__) |
| 4133 |
long cpsr = kread(®s->ARM_cpsr); |
| 4134 |
STAP_RETVALUE = ((cpsr & 0xf) == 0); |
| 4135 |
#elif defined(__mips__) |
| 4136 |
unsigned long cp0 = kread(®s->cp0_status); |
| 4137 |
#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) |
| 4138 |
STAP_RETVALUE = ((cp0 & 0x08) == 8); |
| 4139 |
#else |
| 4140 |
STAP_RETVALUE = ((cp0 & 0x18) == 0x10); |
| 4141 |
#endif |
| 4142 |
#elif defined(__s390__) || defined(__s390x__) |
| 4143 |
unsigned long mask = kread(®s->psw.mask); |
| 4144 |
STAP_RETVALUE = ((mask & PSW_MASK_PSTATE) != 0); |
| 4145 |
#elif defined(__aarch64__) |
| 4146 |
long pstate = kread(®s->pstate); |
| 4147 |
STAP_RETVALUE = ((pstate & PSR_MODE_MASK) == PSR_MODE_EL0t); |
| 4148 |
#else |
| 4149 |
#error "Unimplemented architecture" |
| 4150 |
#endif |
| 4151 |
CATCH_DEREF_FAULT(); |
| 4152 |
%} |
| 4153 |
|
| 4154 |
%{ |
| 4155 |
#include <linux/ipc.h> |
| 4156 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0) |
| 4157 |
#include <linux/shm.h> |
| 4158 |
#else |
| 4159 |
#include <uapi/linux/shm.h> |
| 4160 |
#endif |
| 4161 |
static const _stp_val_array _stp_shmget_flags_list[] = { |
| 4162 |
V(IPC_CREAT), |
| 4163 |
V(IPC_EXCL), |
| 4164 |
V(SHM_HUGETLB), |
| 4165 |
V(SHM_NORESERVE), |
| 4166 |
{0, NULL} |
| 4167 |
}; |
| 4168 |
%} |
| 4169 |
|
| 4170 |
function _stp_shmget_flags_str:string(shmflg:long) |
| 4171 |
%{ /* pure */ /* unprivileged */ |
| 4172 |
unsigned int shmflg = (unsigned int)STAP_ARG_shmflg; |
| 4173 |
unsigned int modebits; |
| 4174 |
|
| 4175 |
/* Lowest 9 bits are mode bits. */ |
| 4176 |
modebits = shmflg & 0777; |
| 4177 |
shmflg &= ~0777; |
| 4178 |
_stp_lookup_or_str(_stp_shmget_flags_list, shmflg, STAP_RETVALUE, |
| 4179 |
MAXSTRINGLEN); |
| 4180 |
if (modebits) { |
| 4181 |
int slen; |
| 4182 |
slen = strlen(STAP_RETVALUE); |
| 4183 |
if (slen) |
| 4184 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, |
| 4185 |
"|%#o", modebits); |
| 4186 |
else |
| 4187 |
_stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "%#o", |
| 4188 |
modebits); |
| 4189 |
} |
| 4190 |
%} |
| 4191 |
|
| 4192 |
function _stp_msgget_key_str:string(key:long) |
| 4193 |
{ |
| 4194 |
if (key == @const("IPC_PRIVATE")) |
| 4195 |
return "IPC_PRIVATE" |
| 4196 |
return sprintf("%d", key) |
| 4197 |
} |
| 4198 |
|
| 4199 |
%{ |
| 4200 |
#include <linux/msg.h> |
| 4201 |
|
| 4202 |
static const _stp_val_array _stp_msgctl_list[] = { |
| 4203 |
V(IPC_INFO), |
| 4204 |
V(IPC_STAT), |
| 4205 |
V(IPC_RMID), |
| 4206 |
V(IPC_SET), |
| 4207 |
V(MSG_INFO), |
| 4208 |
V(MSG_STAT), |
| 4209 |
{0, NULL} |
| 4210 |
}; |
| 4211 |
%} |
| 4212 |
|
| 4213 |
function _stp_msgctl_cmd_str:string(cmd:long) |
| 4214 |
%{ /* pure */ /* unprivileged */ |
| 4215 |
unsigned int cmd = STAP_ARG_cmd; |
| 4216 |
|
| 4217 |
if (cmd & IPC_64) { |
| 4218 |
strlcpy (STAP_RETVALUE, "IPC_64|", MAXSTRINGLEN); |
| 4219 |
cmd &= ~IPC_64; |
| 4220 |
} |
| 4221 |
_stp_lookup_str(_stp_msgctl_list, cmd, STAP_RETVALUE, MAXSTRINGLEN); |
| 4222 |
%} |
| 4223 |
|
| 4224 |
%{ |
| 4225 |
static const _stp_val_array _stp_msgflg_list[] = { |
| 4226 |
V(MSG_NOERROR), |
| 4227 |
V(MSG_EXCEPT), |
| 4228 |
V(IPC_NOWAIT), |
| 4229 |
{0, NULL} |
| 4230 |
}; |
| 4231 |
%} |
| 4232 |
|
| 4233 |
function _stp_msgflg_str:string(msgflg:long) |
| 4234 |
%{ /* pure */ /* unprivileged */ |
| 4235 |
unsigned int msgflg = STAP_ARG_msgflg; |
| 4236 |
|
| 4237 |
_stp_lookup_or_str(_stp_msgflg_list, msgflg, STAP_RETVALUE, |
| 4238 |
MAXSTRINGLEN); |
| 4239 |
%} |
| 4240 |
|
| 4241 |
%{ |
| 4242 |
// Copied from ipc/compat.c. |
| 4243 |
|
| 4244 |
#ifdef CONFIG_COMPAT |
| 4245 |
struct compat_ipc_kludge { |
| 4246 |
compat_uptr_t msgp; |
| 4247 |
compat_long_t msgtyp; |
| 4248 |
}; |
| 4249 |
#endif |
| 4250 |
%} |
| 4251 |
|
| 4252 |
function _stp_compat_msgrcv_msgbuf:long(uaddr:long, version:long) |
| 4253 |
%{ /* pure */ |
| 4254 |
#ifdef CONFIG_COMPAT |
| 4255 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 4256 |
int version = (int)(unsigned long)STAP_ARG_version; |
| 4257 |
void *msgbuf = ptr; |
| 4258 |
|
| 4259 |
if (!version) { |
| 4260 |
struct compat_ipc_kludge ipck; |
| 4261 |
|
| 4262 |
msgbuf = NULL; |
| 4263 |
if (ptr != NULL |
| 4264 |
&& _stp_copy_from_user((char*)&ipck, ptr, |
| 4265 |
sizeof(ipck)) == 0) { |
| 4266 |
msgbuf = compat_ptr(ipck.msgp); |
| 4267 |
} |
| 4268 |
} |
| 4269 |
STAP_RETVALUE = (unsigned long)msgbuf; |
| 4270 |
#endif |
| 4271 |
%} |
| 4272 |
|
| 4273 |
function _stp_compat_msgrcv_msgtyp:long(uaddr:long, version:long, msgtyp:long) |
| 4274 |
%{ /* pure */ |
| 4275 |
#ifdef CONFIG_COMPAT |
| 4276 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 4277 |
int version = (int)(unsigned long)STAP_ARG_version; |
| 4278 |
long msgtyp = (long)STAP_ARG_msgtyp; |
| 4279 |
|
| 4280 |
if (!version) { |
| 4281 |
struct compat_ipc_kludge ipck; |
| 4282 |
|
| 4283 |
if (ptr != NULL |
| 4284 |
&& _stp_copy_from_user((char*)&ipck, ptr, |
| 4285 |
sizeof(ipck)) == 0) { |
| 4286 |
msgtyp = ipck.msgtyp; |
| 4287 |
} |
| 4288 |
} |
| 4289 |
STAP_RETVALUE = msgtyp; |
| 4290 |
#endif |
| 4291 |
%} |
| 4292 |
|
| 4293 |
%{ |
| 4294 |
#include <linux/xattr.h> |
| 4295 |
|
| 4296 |
static const _stp_val_array _stp_xattr_flags_list[] = { |
| 4297 |
V(XATTR_CREATE), |
| 4298 |
V(XATTR_REPLACE), |
| 4299 |
{0, NULL} |
| 4300 |
}; |
| 4301 |
%} |
| 4302 |
|
| 4303 |
function _stp_xattr_flags_str:string(flags:long) |
| 4304 |
%{ /* pure */ /* unprivileged */ |
| 4305 |
unsigned int flags = STAP_ARG_flags; |
| 4306 |
|
| 4307 |
_stp_lookup_or_str(_stp_xattr_flags_list, flags, STAP_RETVALUE, |
| 4308 |
MAXSTRINGLEN); |
| 4309 |
%} |
| 4310 |
|
| 4311 |
function _stp_xattr_val_str:string(uaddr:long, size:long) |
| 4312 |
%{ /* pure */ |
| 4313 |
void *uaddr = (void *)(uintptr_t)STAP_ARG_uaddr; |
| 4314 |
unsigned long size = STAP_ARG_size; |
| 4315 |
unsigned char buffer[50]; |
| 4316 |
size_t copy_size = clamp_t(size_t, size, 0, sizeof(buffer)); |
| 4317 |
|
| 4318 |
if (uaddr != NULL && copy_size > 0 |
| 4319 |
&& _stp_copy_from_user(buffer, uaddr, copy_size) == 0) { |
| 4320 |
size_t i; |
| 4321 |
unsigned char *out = STAP_RETVALUE; |
| 4322 |
// Save 3 chars: 2 for the leading and trailing |
| 4323 |
// double-quote chars, one for the trailing NUL. |
| 4324 |
size_t out_size = MAXSTRINGLEN - 3; |
| 4325 |
|
| 4326 |
*out++ = '"'; |
| 4327 |
for (i = 0; i < copy_size; ++i) { |
| 4328 |
#define _stp_is_printable_ascii(c) ((c) >= ' ' && (c) <= 0x7e) |
| 4329 |
#define _stp_tohex(n) "0123456789abcdef"[n] |
| 4330 |
|
| 4331 |
if (_stp_is_printable_ascii(buffer[i])) { |
| 4332 |
if (--out_size >= 0) |
| 4333 |
*out++ = buffer[i]; |
| 4334 |
} |
| 4335 |
else { |
| 4336 |
if (out_size < 4) |
| 4337 |
break; |
| 4338 |
out_size -= 4; |
| 4339 |
if (out_size >= 0) { |
| 4340 |
*out++ = '\\'; |
| 4341 |
*out++ = 'x'; |
| 4342 |
*out++ = _stp_tohex(buffer[i] / 16); |
| 4343 |
*out++ = _stp_tohex(buffer[i] % 16); |
| 4344 |
} |
| 4345 |
} |
| 4346 |
if (out_size == 0) |
| 4347 |
break; |
| 4348 |
} |
| 4349 |
// Don't print terminating NUL from the input data if |
| 4350 |
// there is one. |
| 4351 |
if (i > 1 && buffer[i - 1] == '\0' |
| 4352 |
&& _stp_is_printable_ascii(buffer[i - 2])) |
| 4353 |
out -= 4; |
| 4354 |
*out++ = '"'; |
| 4355 |
*out = '\0'; |
| 4356 |
} |
| 4357 |
else |
| 4358 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 4359 |
(unsigned long)uaddr); |
| 4360 |
%} |
| 4361 |
|
| 4362 |
%{ |
| 4363 |
#include <linux/ioprio.h> |
| 4364 |
|
| 4365 |
static const _stp_val_array _stp_ioprio_who_list[] = { |
| 4366 |
V(IOPRIO_WHO_PROCESS), |
| 4367 |
V(IOPRIO_WHO_PGRP), |
| 4368 |
V(IOPRIO_WHO_USER), |
| 4369 |
{0, NULL} |
| 4370 |
}; |
| 4371 |
static const _stp_val_array _stp_ioprio_class_list[] = { |
| 4372 |
V(IOPRIO_CLASS_NONE), |
| 4373 |
V(IOPRIO_CLASS_RT), |
| 4374 |
V(IOPRIO_CLASS_BE), |
| 4375 |
V(IOPRIO_CLASS_IDLE), |
| 4376 |
{0, NULL} |
| 4377 |
}; |
| 4378 |
%} |
| 4379 |
|
| 4380 |
function _stp_ioprio_which_str:string(who:long) |
| 4381 |
%{ /* pure */ /* unprivileged */ |
| 4382 |
_stp_lookup_str2(_stp_ioprio_who_list, (int)STAP_ARG_who, |
| 4383 |
STAP_RETVALUE, MAXSTRINGLEN, 10); |
| 4384 |
%} |
| 4385 |
|
| 4386 |
function _stp_ioprio_value_str:string(value:long) |
| 4387 |
%{ /* pure */ /* unprivileged */ |
| 4388 |
unsigned int class = IOPRIO_PRIO_CLASS(((unsigned int)STAP_ARG_value)); |
| 4389 |
int slen; |
| 4390 |
|
| 4391 |
_stp_lookup_str(_stp_ioprio_class_list, class, STAP_RETVALUE, |
| 4392 |
MAXSTRINGLEN); |
| 4393 |
slen = strlen(STAP_RETVALUE); |
| 4394 |
_stp_snprintf(STAP_RETVALUE + slen, MAXSTRINGLEN - slen, "|%d", |
| 4395 |
IOPRIO_PRIO_DATA(((int)STAP_ARG_value))); |
| 4396 |
%} |
| 4397 |
|
| 4398 |
%{ |
| 4399 |
#include <linux/mempolicy.h> |
| 4400 |
static const _stp_val_array _stp_mempolicy_flags_list[] = { |
| 4401 |
V(MPOL_F_NODE), |
| 4402 |
V(MPOL_F_ADDR), |
| 4403 |
#ifdef MPOL_F_MEMS_ALLOWED |
| 4404 |
V(MPOL_F_MEMS_ALLOWED), |
| 4405 |
#endif |
| 4406 |
{0, NULL} |
| 4407 |
}; |
| 4408 |
|
| 4409 |
#ifndef MPOL_MODE_FLAGS |
| 4410 |
#define MPOL_MODE_FLAGS 0 |
| 4411 |
#endif |
| 4412 |
|
| 4413 |
static const _stp_val_array _stp_mempolicy_mode_flags_list[] = { |
| 4414 |
#ifdef MPOL_F_STATIC_NODES |
| 4415 |
V(MPOL_F_STATIC_NODES), |
| 4416 |
#endif |
| 4417 |
#ifdef MPOL_F_RELATIVE_NODES |
| 4418 |
V(MPOL_F_RELATIVE_NODES), |
| 4419 |
#endif |
| 4420 |
{0, NULL} |
| 4421 |
}; |
| 4422 |
|
| 4423 |
static const _stp_val_array _stp_mempolicy_mode_list[] = { |
| 4424 |
V(MPOL_DEFAULT), |
| 4425 |
V(MPOL_PREFERRED), |
| 4426 |
V(MPOL_BIND), |
| 4427 |
V(MPOL_INTERLEAVE), |
| 4428 |
#ifdef MPOL_LOCAL |
| 4429 |
V(MPOL_LOCAL), |
| 4430 |
#endif |
| 4431 |
{0, NULL} |
| 4432 |
}; |
| 4433 |
%} |
| 4434 |
|
| 4435 |
function _mempolicy_flags_str:string(flags:long) |
| 4436 |
%{ /* pure */ /* unprivileged */ |
| 4437 |
_stp_lookup_or_str(_stp_mempolicy_flags_list, |
| 4438 |
(unsigned long)STAP_ARG_flags, STAP_RETVALUE, |
| 4439 |
MAXSTRINGLEN); |
| 4440 |
%} |
| 4441 |
|
| 4442 |
function _mempolicy_mode_str:string(mode:long) |
| 4443 |
%{ /* pure */ /* unprivileged */ |
| 4444 |
unsigned int mode = (unsigned int)STAP_ARG_mode; |
| 4445 |
int len = 0; |
| 4446 |
|
| 4447 |
if (mode != 0xffffffff && mode & MPOL_MODE_FLAGS) { |
| 4448 |
_stp_lookup_str(_stp_mempolicy_mode_flags_list, |
| 4449 |
mode & MPOL_MODE_FLAGS, STAP_RETVALUE, |
| 4450 |
MAXSTRINGLEN); |
| 4451 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 4452 |
len = strlen(STAP_RETVALUE); |
| 4453 |
mode &= ~MPOL_MODE_FLAGS; |
| 4454 |
} |
| 4455 |
_stp_lookup_str(_stp_mempolicy_mode_list, mode, STAP_RETVALUE + len, |
| 4456 |
MAXSTRINGLEN - len); |
| 4457 |
%} |
| 4458 |
|
| 4459 |
%{ |
| 4460 |
#include <linux/keyctl.h> |
| 4461 |
|
| 4462 |
static const _stp_val_array _stp_keyctl_cmd_list[] = { |
| 4463 |
V(KEYCTL_GET_KEYRING_ID), |
| 4464 |
V(KEYCTL_JOIN_SESSION_KEYRING), |
| 4465 |
V(KEYCTL_UPDATE), |
| 4466 |
V(KEYCTL_REVOKE), |
| 4467 |
V(KEYCTL_CHOWN), |
| 4468 |
V(KEYCTL_SETPERM), |
| 4469 |
V(KEYCTL_DESCRIBE), |
| 4470 |
V(KEYCTL_CLEAR), |
| 4471 |
V(KEYCTL_LINK), |
| 4472 |
V(KEYCTL_UNLINK), |
| 4473 |
V(KEYCTL_SEARCH), |
| 4474 |
V(KEYCTL_READ), |
| 4475 |
V(KEYCTL_INSTANTIATE), |
| 4476 |
V(KEYCTL_NEGATE), |
| 4477 |
V(KEYCTL_SET_REQKEY_KEYRING), |
| 4478 |
V(KEYCTL_SET_TIMEOUT), |
| 4479 |
V(KEYCTL_ASSUME_AUTHORITY), |
| 4480 |
#ifdef KEYCTL_GET_SECURITY |
| 4481 |
V(KEYCTL_GET_SECURITY), |
| 4482 |
#endif |
| 4483 |
#ifdef KEYCTL_SESSION_TO_PARENT |
| 4484 |
V(KEYCTL_SESSION_TO_PARENT), |
| 4485 |
#endif |
| 4486 |
#ifdef KEYCTL_REJECT |
| 4487 |
V(KEYCTL_REJECT), |
| 4488 |
#endif |
| 4489 |
#ifdef KEYCTL_INSTANTIATE_IOV |
| 4490 |
V(KEYCTL_INSTANTIATE_IOV), |
| 4491 |
#endif |
| 4492 |
#ifdef KEYCTL_INVALIDATE |
| 4493 |
V(KEYCTL_INVALIDATE), |
| 4494 |
#endif |
| 4495 |
#ifdef KEYCTL_GET_PERSISTENT |
| 4496 |
V(KEYCTL_GET_PERSISTENT), |
| 4497 |
#endif |
| 4498 |
{0, NULL} |
| 4499 |
}; |
| 4500 |
|
| 4501 |
// For older kernels, we need to define new constants for the |
| 4502 |
// @__keyctl_argstr() macro |
| 4503 |
#ifndef KEYCTL_GET_SECURITY |
| 4504 |
#define KEYCTL_GET_SECURITY 17 |
| 4505 |
#endif |
| 4506 |
#ifndef KEYCTL_SESSION_TO_PARENT |
| 4507 |
#define KEYCTL_SESSION_TO_PARENT 18 |
| 4508 |
#endif |
| 4509 |
#ifndef KEYCTL_REJECT |
| 4510 |
#define KEYCTL_REJECT 19 |
| 4511 |
#endif |
| 4512 |
#ifndef KEYCTL_INSTANTIATE_IOV |
| 4513 |
#define KEYCTL_INSTANTIATE_IOV 20 |
| 4514 |
#endif |
| 4515 |
#ifndef KEYCTL_INVALIDATE |
| 4516 |
#define KEYCTL_INVALIDATE 21 |
| 4517 |
#endif |
| 4518 |
#ifndef KEYCTL_GET_PERSISTENT |
| 4519 |
#define KEYCTL_GET_PERSISTENT 22 |
| 4520 |
#endif |
| 4521 |
%} |
| 4522 |
|
| 4523 |
function _stp_keyctl_cmd_str:string(cmd:long) |
| 4524 |
%{ /* pure */ /* unprivileged */ |
| 4525 |
_stp_lookup_str2(_stp_keyctl_cmd_list, (int)STAP_ARG_cmd, |
| 4526 |
STAP_RETVALUE, MAXSTRINGLEN, 10); |
| 4527 |
%} |
| 4528 |
|
| 4529 |
%{ |
| 4530 |
static const _stp_val_array _stp_keyctl_keyring_shortcut_list[] = { |
| 4531 |
V(KEY_SPEC_THREAD_KEYRING), |
| 4532 |
V(KEY_SPEC_PROCESS_KEYRING), |
| 4533 |
V(KEY_SPEC_SESSION_KEYRING), |
| 4534 |
V(KEY_SPEC_USER_KEYRING), |
| 4535 |
V(KEY_SPEC_USER_SESSION_KEYRING), |
| 4536 |
V(KEY_SPEC_GROUP_KEYRING), |
| 4537 |
V(KEY_SPEC_REQKEY_AUTH_KEY), |
| 4538 |
#ifdef KEY_SPEC_REQUESTOR_KEYRING |
| 4539 |
V(KEY_SPEC_REQUESTOR_KEYRING), |
| 4540 |
#endif |
| 4541 |
{0, NULL} |
| 4542 |
}; |
| 4543 |
%} |
| 4544 |
|
| 4545 |
function _stp_keyctl_keyring_shortcut_str:string(id:long) |
| 4546 |
%{ /* pure */ /* unprivileged */ |
| 4547 |
_stp_lookup_str2(_stp_keyctl_keyring_shortcut_list, (int)STAP_ARG_id, |
| 4548 |
STAP_RETVALUE, MAXSTRINGLEN, 10); |
| 4549 |
%} |
| 4550 |
|
| 4551 |
%{ |
| 4552 |
static const _stp_val_array _stp_keyctl_default_keyrings_list[] = { |
| 4553 |
V(KEY_REQKEY_DEFL_NO_CHANGE), |
| 4554 |
V(KEY_REQKEY_DEFL_DEFAULT), |
| 4555 |
V(KEY_REQKEY_DEFL_THREAD_KEYRING), |
| 4556 |
V(KEY_REQKEY_DEFL_PROCESS_KEYRING), |
| 4557 |
V(KEY_REQKEY_DEFL_SESSION_KEYRING), |
| 4558 |
V(KEY_REQKEY_DEFL_USER_KEYRING), |
| 4559 |
V(KEY_REQKEY_DEFL_USER_SESSION_KEYRING), |
| 4560 |
V(KEY_REQKEY_DEFL_GROUP_KEYRING), |
| 4561 |
{0, NULL} |
| 4562 |
}; |
| 4563 |
%} |
| 4564 |
|
| 4565 |
function _stp_keyctl_default_keyrings_str:string(id:long) |
| 4566 |
%{ /* pure */ /* unprivileged */ |
| 4567 |
_stp_lookup_str2(_stp_keyctl_default_keyrings_list, (int)STAP_ARG_id, |
| 4568 |
STAP_RETVALUE, MAXSTRINGLEN, 10); |
| 4569 |
%} |
| 4570 |
|
| 4571 |
|
| 4572 |
|
| 4573 |
%{ |
| 4574 |
#include <linux/key.h> |
| 4575 |
|
| 4576 |
static const _stp_val_array _stp_keyctl_perm_list[] = { |
| 4577 |
#if defined(CONFIG_KEYS) |
| 4578 |
V(KEY_POS_VIEW), |
| 4579 |
V(KEY_POS_READ), |
| 4580 |
V(KEY_POS_WRITE), |
| 4581 |
V(KEY_POS_SEARCH), |
| 4582 |
V(KEY_POS_LINK), |
| 4583 |
V(KEY_POS_SETATTR), |
| 4584 |
V(KEY_POS_ALL), |
| 4585 |
V(KEY_USR_VIEW), |
| 4586 |
V(KEY_USR_READ), |
| 4587 |
V(KEY_USR_WRITE), |
| 4588 |
V(KEY_USR_SEARCH), |
| 4589 |
V(KEY_USR_LINK), |
| 4590 |
V(KEY_USR_SETATTR), |
| 4591 |
V(KEY_USR_ALL), |
| 4592 |
V(KEY_GRP_VIEW), |
| 4593 |
V(KEY_GRP_READ), |
| 4594 |
V(KEY_GRP_WRITE), |
| 4595 |
V(KEY_GRP_SEARCH), |
| 4596 |
V(KEY_GRP_LINK), |
| 4597 |
V(KEY_GRP_SETATTR), |
| 4598 |
V(KEY_GRP_ALL), |
| 4599 |
V(KEY_OTH_VIEW), |
| 4600 |
V(KEY_OTH_READ), |
| 4601 |
V(KEY_OTH_WRITE), |
| 4602 |
V(KEY_OTH_SEARCH), |
| 4603 |
V(KEY_OTH_LINK), |
| 4604 |
V(KEY_OTH_SETATTR), |
| 4605 |
V(KEY_OTH_ALL), |
| 4606 |
#endif /* CONFIG_KEYS */ |
| 4607 |
{0, NULL} |
| 4608 |
}; |
| 4609 |
%} |
| 4610 |
|
| 4611 |
function _stp_keyctl_perm_str:string(mask:long) |
| 4612 |
%{ /* pure */ /* unprivileged */ |
| 4613 |
uint32_t mask = (uint32_t)STAP_ARG_mask; |
| 4614 |
_stp_lookup_or_str2(_stp_keyctl_perm_list, mask, STAP_RETVALUE, |
| 4615 |
MAXSTRINGLEN, 10); |
| 4616 |
%} |
| 4617 |
|
| 4618 |
%{ |
| 4619 |
#include <linux/module.h> |
| 4620 |
|
| 4621 |
#ifndef MODULE_INIT_IGNORE_MODVERSIONS |
| 4622 |
#define MODULE_INIT_IGNORE_MODVERSIONS 1 |
| 4623 |
#endif |
| 4624 |
#ifndef MODULE_INIT_IGNORE_VERMAGIC |
| 4625 |
#define MODULE_INIT_IGNORE_VERMAGIC 2 |
| 4626 |
#endif |
| 4627 |
|
| 4628 |
static const _stp_val_array _stp_finit_module_flags_list[] = { |
| 4629 |
V(MODULE_INIT_IGNORE_MODVERSIONS), |
| 4630 |
V(MODULE_INIT_IGNORE_VERMAGIC), |
| 4631 |
{0, NULL} |
| 4632 |
}; |
| 4633 |
%} |
| 4634 |
|
| 4635 |
function _finit_module_flags_str:string(flags:long) |
| 4636 |
%{ /* pure */ /* unprivileged */ |
| 4637 |
_stp_lookup_or_str(_stp_finit_module_flags_list, |
| 4638 |
(unsigned int)STAP_ARG_flags, STAP_RETVALUE, |
| 4639 |
MAXSTRINGLEN); |
| 4640 |
%} |
| 4641 |
|
| 4642 |
%{ |
| 4643 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) |
| 4644 |
#include <linux/prctl.h> |
| 4645 |
#else |
| 4646 |
#include <uapi/linux/prctl.h> |
| 4647 |
#endif |
| 4648 |
|
| 4649 |
static const _stp_val_array _stp_prctl_option_list[] = { |
| 4650 |
V(PR_SET_PDEATHSIG), |
| 4651 |
V(PR_GET_PDEATHSIG), |
| 4652 |
V(PR_GET_DUMPABLE), |
| 4653 |
V(PR_SET_DUMPABLE), |
| 4654 |
V(PR_GET_UNALIGN), |
| 4655 |
V(PR_SET_UNALIGN), |
| 4656 |
V(PR_GET_KEEPCAPS), |
| 4657 |
V(PR_SET_KEEPCAPS), |
| 4658 |
V(PR_GET_FPEMU), |
| 4659 |
V(PR_SET_FPEMU), |
| 4660 |
V(PR_GET_FPEXC), |
| 4661 |
V(PR_SET_FPEXC), |
| 4662 |
V(PR_GET_TIMING), |
| 4663 |
V(PR_SET_TIMING), |
| 4664 |
V(PR_SET_NAME), |
| 4665 |
V(PR_GET_NAME), |
| 4666 |
V(PR_GET_ENDIAN), |
| 4667 |
V(PR_SET_ENDIAN), |
| 4668 |
#ifdef PR_GET_SECCOMP |
| 4669 |
V(PR_GET_SECCOMP), |
| 4670 |
#endif |
| 4671 |
#ifdef PR_SET_SECCOMP |
| 4672 |
V(PR_SET_SECCOMP), |
| 4673 |
#endif |
| 4674 |
#ifdef PR_CAPBSET_READ |
| 4675 |
V(PR_CAPBSET_READ), |
| 4676 |
#endif |
| 4677 |
#ifdef PR_CAPBSET_DROP |
| 4678 |
V(PR_CAPBSET_DROP), |
| 4679 |
#endif |
| 4680 |
#ifdef PR_GET_TSC |
| 4681 |
V(PR_GET_TSC), |
| 4682 |
#endif |
| 4683 |
#ifdef PR_SET_TSC |
| 4684 |
V(PR_SET_TSC), |
| 4685 |
#endif |
| 4686 |
#ifdef PR_GET_SECUREBITS |
| 4687 |
V(PR_GET_SECUREBITS), |
| 4688 |
#endif |
| 4689 |
#ifdef PR_SET_SECUREBITS |
| 4690 |
V(PR_SET_SECUREBITS), |
| 4691 |
#endif |
| 4692 |
#ifdef PR_SET_TIMERSLACK |
| 4693 |
V(PR_SET_TIMERSLACK), |
| 4694 |
#endif |
| 4695 |
#ifdef PR_GET_TIMERSLACK |
| 4696 |
V(PR_GET_TIMERSLACK), |
| 4697 |
#endif |
| 4698 |
#ifdef PR_TASK_PERF_EVENTS_DISABLE |
| 4699 |
V(PR_TASK_PERF_EVENTS_DISABLE), |
| 4700 |
#endif |
| 4701 |
#ifdef PR_TASK_PERF_EVENTS_ENABLE |
| 4702 |
V(PR_TASK_PERF_EVENTS_ENABLE), |
| 4703 |
#endif |
| 4704 |
#ifdef PR_MCE_KILL |
| 4705 |
V(PR_MCE_KILL), |
| 4706 |
#endif |
| 4707 |
#ifdef PR_MCE_KILL_GET |
| 4708 |
V(PR_MCE_KILL_GET), |
| 4709 |
#endif |
| 4710 |
#ifdef PR_SET_MM |
| 4711 |
V(PR_SET_MM), |
| 4712 |
#endif |
| 4713 |
#ifdef PR_SET_PTRACER |
| 4714 |
V(PR_SET_PTRACER), |
| 4715 |
#endif |
| 4716 |
#ifdef PR_SET_CHILD_SUBREAPER |
| 4717 |
V(PR_SET_CHILD_SUBREAPER), |
| 4718 |
#endif |
| 4719 |
#ifdef PR_GET_CHILD_SUBREAPER |
| 4720 |
V(PR_GET_CHILD_SUBREAPER), |
| 4721 |
#endif |
| 4722 |
#ifdef PR_SET_NO_NEW_PRIVS |
| 4723 |
V(PR_SET_NO_NEW_PRIVS), |
| 4724 |
#endif |
| 4725 |
#ifdef PR_GET_NO_NEW_PRIVS |
| 4726 |
V(PR_GET_NO_NEW_PRIVS), |
| 4727 |
#endif |
| 4728 |
#ifdef PR_GET_TID_ADDRESS |
| 4729 |
V(PR_GET_TID_ADDRESS), |
| 4730 |
#endif |
| 4731 |
#ifdef PR_SET_THP_DISABLE |
| 4732 |
V(PR_SET_THP_DISABLE), |
| 4733 |
#endif |
| 4734 |
#ifdef PR_GET_THP_DISABLE |
| 4735 |
V(PR_GET_THP_DISABLE), |
| 4736 |
#endif |
| 4737 |
#ifdef PR_MPX_ENABLE_MANAGEMENT |
| 4738 |
V(PR_MPX_ENABLE_MANAGEMENT), |
| 4739 |
#endif |
| 4740 |
#ifdef PR_MPX_DISABLE_MANAGEMENT |
| 4741 |
V(PR_MPX_DISABLE_MANAGEMENT), |
| 4742 |
#endif |
| 4743 |
{0, NULL} |
| 4744 |
}; |
| 4745 |
|
| 4746 |
// Options that get passed to PR_SET_UNALIGN and returned by PR_GET_UNALIGN. |
| 4747 |
static const _stp_val_array _stp_prctl_unalign_option_list[] = { |
| 4748 |
V(PR_UNALIGN_NOPRINT), |
| 4749 |
V(PR_UNALIGN_SIGBUS), |
| 4750 |
{0, NULL} |
| 4751 |
}; |
| 4752 |
|
| 4753 |
// Options that get passed to PR_SET_FPEMU and returned by PR_GET_FPEMU. |
| 4754 |
static const _stp_val_array _stp_prctl_fpemu_option_list[] = { |
| 4755 |
V(PR_FPEMU_NOPRINT), |
| 4756 |
V(PR_FPEMU_SIGFPE), |
| 4757 |
{0, NULL} |
| 4758 |
}; |
| 4759 |
|
| 4760 |
// Options that get passed to PR_SET_FPEXC and returned by PR_GET_FPEXC. |
| 4761 |
static const _stp_val_array _stp_prctl_fpexc_option_list[] = { |
| 4762 |
V(PR_FP_EXC_SW_ENABLE), |
| 4763 |
V(PR_FP_EXC_DIV), |
| 4764 |
V(PR_FP_EXC_OVF), |
| 4765 |
V(PR_FP_EXC_UND), |
| 4766 |
V(PR_FP_EXC_RES), |
| 4767 |
V(PR_FP_EXC_INV), |
| 4768 |
V(PR_FP_EXC_DISABLED), |
| 4769 |
V(PR_FP_EXC_NONRECOV), |
| 4770 |
V(PR_FP_EXC_ASYNC), |
| 4771 |
V(PR_FP_EXC_PRECISE), |
| 4772 |
{0, NULL} |
| 4773 |
}; |
| 4774 |
|
| 4775 |
// Options that get passed to PR_SET_TIMING and returned by PR_GET_TIMING. |
| 4776 |
static const _stp_val_array _stp_prctl_timing_option_list[] = { |
| 4777 |
V(PR_TIMING_STATISTICAL), |
| 4778 |
V(PR_TIMING_TIMESTAMP), |
| 4779 |
{0, NULL} |
| 4780 |
}; |
| 4781 |
|
| 4782 |
// Options that get passed to PR_SET_ENDIAN and returned by PR_GET_ENDIAN. |
| 4783 |
static const _stp_val_array _stp_prctl_endian_option_list[] = { |
| 4784 |
V(PR_ENDIAN_BIG), |
| 4785 |
V(PR_ENDIAN_LITTLE), |
| 4786 |
V(PR_ENDIAN_PPC_LITTLE), |
| 4787 |
{0, NULL} |
| 4788 |
}; |
| 4789 |
|
| 4790 |
#ifdef PR_SET_TSC |
| 4791 |
// Options that get passed to PR_SET_TSC and returned by PR_GET_TSC. |
| 4792 |
static const _stp_val_array _stp_prctl_tsc_option_list[] = { |
| 4793 |
V(PR_TSC_ENABLE), |
| 4794 |
V(PR_TSC_SIGSEGV), |
| 4795 |
{0, NULL} |
| 4796 |
}; |
| 4797 |
#endif |
| 4798 |
|
| 4799 |
#ifdef PR_MCE_KILL |
| 4800 |
// Options that get passed to PR_MCE_KILL and returned by PR_MCE_KILL_GET. |
| 4801 |
static const _stp_val_array _stp_prctl_mce_kill_option_list[] = { |
| 4802 |
V(PR_MCE_KILL_CLEAR), |
| 4803 |
V(PR_MCE_KILL_SET), |
| 4804 |
{0, NULL} |
| 4805 |
}; |
| 4806 |
// Options for PR_MCE_KILL with PR_MCE_KILL_SET. |
| 4807 |
static const _stp_val_array _stp_prctl_mce_kill_option2_list[] = { |
| 4808 |
V(PR_MCE_KILL_LATE), |
| 4809 |
V(PR_MCE_KILL_EARLY), |
| 4810 |
V(PR_MCE_KILL_DEFAULT), |
| 4811 |
{0, NULL} |
| 4812 |
}; |
| 4813 |
#endif |
| 4814 |
|
| 4815 |
#ifdef PR_SET_MM |
| 4816 |
// Options that get passed to PR_SET_MM. |
| 4817 |
static const _stp_val_array _stp_prctl_mm_option_list[] = { |
| 4818 |
V(PR_SET_MM_START_CODE), |
| 4819 |
V(PR_SET_MM_END_CODE), |
| 4820 |
V(PR_SET_MM_START_DATA), |
| 4821 |
V(PR_SET_MM_END_DATA), |
| 4822 |
V(PR_SET_MM_START_STACK), |
| 4823 |
V(PR_SET_MM_START_BRK), |
| 4824 |
V(PR_SET_MM_BRK), |
| 4825 |
#ifdef PR_SET_MM_ARG_START |
| 4826 |
V(PR_SET_MM_ARG_START), |
| 4827 |
#endif |
| 4828 |
#ifdef PR_SET_MM_ARG_END |
| 4829 |
V(PR_SET_MM_ARG_END), |
| 4830 |
#endif |
| 4831 |
#ifdef PR_SET_MM_ENV_START |
| 4832 |
V(PR_SET_MM_ENV_START), |
| 4833 |
#endif |
| 4834 |
#ifdef PR_SET_MM_ENV_END |
| 4835 |
V(PR_SET_MM_ENV_END), |
| 4836 |
#endif |
| 4837 |
#ifdef PR_SET_MM_AUXV |
| 4838 |
V(PR_SET_MM_AUXV), |
| 4839 |
#endif |
| 4840 |
#ifdef PR_SET_MM_EXE_FILE |
| 4841 |
V(PR_SET_MM_EXE_FILE), |
| 4842 |
#endif |
| 4843 |
#ifdef PR_SET_MM_MAP |
| 4844 |
V(PR_SET_MM_MAP), |
| 4845 |
#endif |
| 4846 |
#ifdef PR_SET_MM_MAP_SIZE |
| 4847 |
V(PR_SET_MM_MAP_SIZE), |
| 4848 |
#endif |
| 4849 |
{0, NULL} |
| 4850 |
}; |
| 4851 |
#endif |
| 4852 |
|
| 4853 |
#ifdef PR_SET_PTRACER |
| 4854 |
// Options that get passed to PR_SET_PTRACER. |
| 4855 |
static const _stp_val_array _stp_prctl_ptracer_option_list[] = { |
| 4856 |
V(PR_SET_PTRACER_ANY), |
| 4857 |
{0, NULL} |
| 4858 |
}; |
| 4859 |
#endif |
| 4860 |
|
| 4861 |
#include <linux/capability.h> |
| 4862 |
|
| 4863 |
static const _stp_val_array _stp_linux_capability_list[] = { |
| 4864 |
V(CAP_CHOWN), |
| 4865 |
V(CAP_DAC_OVERRIDE), |
| 4866 |
V(CAP_DAC_READ_SEARCH), |
| 4867 |
V(CAP_FOWNER), |
| 4868 |
V(CAP_FSETID), |
| 4869 |
V(CAP_KILL), |
| 4870 |
V(CAP_SETGID), |
| 4871 |
V(CAP_SETUID), |
| 4872 |
V(CAP_SETPCAP), |
| 4873 |
V(CAP_LINUX_IMMUTABLE), |
| 4874 |
V(CAP_NET_BIND_SERVICE), |
| 4875 |
V(CAP_NET_BROADCAST), |
| 4876 |
V(CAP_NET_ADMIN), |
| 4877 |
V(CAP_NET_RAW), |
| 4878 |
V(CAP_IPC_LOCK), |
| 4879 |
V(CAP_IPC_OWNER), |
| 4880 |
V(CAP_SYS_MODULE), |
| 4881 |
V(CAP_SYS_RAWIO), |
| 4882 |
V(CAP_SYS_CHROOT), |
| 4883 |
V(CAP_SYS_PTRACE), |
| 4884 |
V(CAP_SYS_PACCT), |
| 4885 |
V(CAP_SYS_ADMIN), |
| 4886 |
V(CAP_SYS_BOOT), |
| 4887 |
V(CAP_SYS_NICE), |
| 4888 |
V(CAP_SYS_RESOURCE), |
| 4889 |
V(CAP_SYS_TIME), |
| 4890 |
V(CAP_SYS_TTY_CONFIG), |
| 4891 |
V(CAP_MKNOD), |
| 4892 |
V(CAP_LEASE), |
| 4893 |
V(CAP_AUDIT_WRITE), |
| 4894 |
V(CAP_AUDIT_CONTROL), |
| 4895 |
#ifdef CAP_SETFCAP |
| 4896 |
V(CAP_SETFCAP), |
| 4897 |
#endif |
| 4898 |
#ifdef CAP_MAC_OVERRIDE |
| 4899 |
V(CAP_MAC_OVERRIDE), |
| 4900 |
#endif |
| 4901 |
#ifdef CAP_MAC_ADMIN |
| 4902 |
V(CAP_MAC_ADMIN), |
| 4903 |
#endif |
| 4904 |
#ifdef CAP_SYSLOG |
| 4905 |
V(CAP_SYSLOG), |
| 4906 |
#endif |
| 4907 |
#ifdef CAP_WAKE_ALARM |
| 4908 |
V(CAP_WAKE_ALARM), |
| 4909 |
#endif |
| 4910 |
#ifdef CAP_BLOCK_SUSPEND |
| 4911 |
V(CAP_BLOCK_SUSPEND), |
| 4912 |
#endif |
| 4913 |
#ifdef CAP_AUDIT_READ |
| 4914 |
V(CAP_AUDIT_READ), |
| 4915 |
#endif |
| 4916 |
{0, NULL} |
| 4917 |
}; |
| 4918 |
|
| 4919 |
#ifdef PR_SET_SECUREBITS |
| 4920 |
#include <linux/securebits.h> |
| 4921 |
|
| 4922 |
#ifndef SECBIT_NOROOT |
| 4923 |
#define SECBIT_NOROOT (issecure_mask(SECURE_NOROOT)) |
| 4924 |
#endif |
| 4925 |
#ifndef SECBIT_NOROOT_LOCKED |
| 4926 |
#define SECBIT_NOROOT_LOCKED (issecure_mask(SECURE_NOROOT_LOCKED)) |
| 4927 |
#endif |
| 4928 |
#ifndef SECBIT_NO_SETUID_FIXUP |
| 4929 |
#define SECBIT_NO_SETUID_FIXUP (issecure_mask(SECURE_NO_SETUID_FIXUP)) |
| 4930 |
#endif |
| 4931 |
#ifndef SECBIT_NO_SETUID_FIXUP_LOCKED |
| 4932 |
#define SECBIT_NO_SETUID_FIXUP_LOCKED \ |
| 4933 |
(issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED)) |
| 4934 |
#endif |
| 4935 |
#ifndef SECBIT_KEEP_CAPS |
| 4936 |
#define SECBIT_KEEP_CAPS (issecure_mask(SECURE_KEEP_CAPS)) |
| 4937 |
#endif |
| 4938 |
#ifndef SECBIT_KEEP_CAPS_LOCKED |
| 4939 |
#define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED)) |
| 4940 |
#endif |
| 4941 |
|
| 4942 |
static const _stp_val_array _stp_linux_securebits_list[] = { |
| 4943 |
V(SECBIT_NOROOT), |
| 4944 |
V(SECBIT_NOROOT_LOCKED), |
| 4945 |
V(SECBIT_NO_SETUID_FIXUP), |
| 4946 |
V(SECBIT_NO_SETUID_FIXUP_LOCKED), |
| 4947 |
V(SECBIT_KEEP_CAPS), |
| 4948 |
V(SECBIT_KEEP_CAPS_LOCKED), |
| 4949 |
{0, NULL} |
| 4950 |
}; |
| 4951 |
#endif |
| 4952 |
%} |
| 4953 |
|
| 4954 |
function _prctl_argstr:string(option:long, arg2:long, arg3:long, arg4:long, |
| 4955 |
arg5:long) |
| 4956 |
%{ /* pure */ /* unprivileged */ |
| 4957 |
int len; |
| 4958 |
|
| 4959 |
_stp_lookup_str(_stp_prctl_option_list, (unsigned int)STAP_ARG_option, |
| 4960 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 4961 |
switch ((unsigned int)STAP_ARG_option) { |
| 4962 |
// Options that take no arguments: |
| 4963 |
case PR_GET_DUMPABLE: |
| 4964 |
case PR_GET_TIMING: |
| 4965 |
case PR_GET_KEEPCAPS: |
| 4966 |
#ifdef PR_GET_SECCOMP |
| 4967 |
case PR_GET_SECCOMP: |
| 4968 |
#endif |
| 4969 |
#ifdef PR_TASK_PERF_EVENTS_DISABLE |
| 4970 |
case PR_TASK_PERF_EVENTS_DISABLE: |
| 4971 |
#endif |
| 4972 |
#ifdef PR_TASK_PERF_EVENTS_ENABLE |
| 4973 |
case PR_TASK_PERF_EVENTS_ENABLE: |
| 4974 |
#endif |
| 4975 |
#ifdef PR_GET_TIMERSLACK |
| 4976 |
case PR_GET_TIMERSLACK: |
| 4977 |
#endif |
| 4978 |
#ifdef PR_MCE_KILL_GET |
| 4979 |
case PR_MCE_KILL_GET: |
| 4980 |
#endif |
| 4981 |
#ifdef PR_GET_NO_NEW_PRIVS |
| 4982 |
case PR_GET_NO_NEW_PRIVS: |
| 4983 |
#endif |
| 4984 |
#ifdef PR_GET_THP_DISABLE |
| 4985 |
case PR_GET_THP_DISABLE: |
| 4986 |
#endif |
| 4987 |
#ifdef PR_MPX_ENABLE_MANAGEMENT |
| 4988 |
case PR_MPX_ENABLE_MANAGEMENT: |
| 4989 |
#endif |
| 4990 |
#ifdef PR_MPX_DISABLE_MANAGEMENT |
| 4991 |
case PR_MPX_DISABLE_MANAGEMENT: |
| 4992 |
#endif |
| 4993 |
#ifdef PR_GET_SECUREBITS |
| 4994 |
case PR_GET_SECUREBITS: |
| 4995 |
#endif |
| 4996 |
// We're done. |
| 4997 |
break; |
| 4998 |
|
| 4999 |
// Options that use arg2: |
| 5000 |
case PR_SET_UNALIGN: |
| 5001 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5002 |
len = strlen(STAP_RETVALUE); |
| 5003 |
_stp_lookup_str(_stp_prctl_unalign_option_list, |
| 5004 |
(unsigned long)STAP_ARG_arg2, |
| 5005 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5006 |
break; |
| 5007 |
case PR_SET_FPEMU: |
| 5008 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5009 |
len = strlen(STAP_RETVALUE); |
| 5010 |
_stp_lookup_str(_stp_prctl_fpemu_option_list, |
| 5011 |
(unsigned long)STAP_ARG_arg2, |
| 5012 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5013 |
break; |
| 5014 |
case PR_SET_FPEXC: |
| 5015 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5016 |
len = strlen(STAP_RETVALUE); |
| 5017 |
_stp_lookup_str(_stp_prctl_fpexc_option_list, |
| 5018 |
(unsigned long)STAP_ARG_arg2, |
| 5019 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5020 |
break; |
| 5021 |
case PR_SET_TIMING: |
| 5022 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5023 |
len = strlen(STAP_RETVALUE); |
| 5024 |
_stp_lookup_str(_stp_prctl_timing_option_list, |
| 5025 |
(unsigned long)STAP_ARG_arg2, |
| 5026 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5027 |
break; |
| 5028 |
case PR_SET_ENDIAN: |
| 5029 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5030 |
len = strlen(STAP_RETVALUE); |
| 5031 |
_stp_lookup_str(_stp_prctl_endian_option_list, |
| 5032 |
(unsigned long)STAP_ARG_arg2, |
| 5033 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5034 |
break; |
| 5035 |
#ifdef PR_SET_TSC |
| 5036 |
case PR_SET_TSC: |
| 5037 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5038 |
len = strlen(STAP_RETVALUE); |
| 5039 |
_stp_lookup_str(_stp_prctl_tsc_option_list, |
| 5040 |
(unsigned long)STAP_ARG_arg2, |
| 5041 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5042 |
break; |
| 5043 |
#endif |
| 5044 |
#ifdef PR_SET_PTRACER |
| 5045 |
case PR_SET_PTRACER: |
| 5046 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5047 |
len = strlen(STAP_RETVALUE); |
| 5048 |
// Notice we passing arg2 as a signed long |
| 5049 |
// here. PR_SET_PTRACER_ANY is -1. |
| 5050 |
_stp_lookup_str2(_stp_prctl_ptracer_option_list, |
| 5051 |
(_stp_is_compat_task() |
| 5052 |
? (long)(int)STAP_ARG_arg2 |
| 5053 |
: (long)STAP_ARG_arg2), |
| 5054 |
STAP_RETVALUE + len, |
| 5055 |
MAXSTRINGLEN - len, 10); |
| 5056 |
break; |
| 5057 |
#endif |
| 5058 |
#if defined(PR_CAPBSET_READ) && defined(PR_CAPBSET_DROP) |
| 5059 |
case PR_CAPBSET_READ: |
| 5060 |
case PR_CAPBSET_DROP: |
| 5061 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5062 |
len = strlen(STAP_RETVALUE); |
| 5063 |
_stp_lookup_str(_stp_linux_capability_list, |
| 5064 |
(unsigned long)STAP_ARG_arg2, |
| 5065 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5066 |
break; |
| 5067 |
#endif |
| 5068 |
#ifdef PR_SET_SECUREBITS |
| 5069 |
case PR_SET_SECUREBITS: |
| 5070 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5071 |
len = strlen(STAP_RETVALUE); |
| 5072 |
_stp_lookup_or_str(_stp_linux_securebits_list, |
| 5073 |
(unsigned long)STAP_ARG_arg2, |
| 5074 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5075 |
break; |
| 5076 |
#endif |
| 5077 |
case PR_SET_PDEATHSIG: |
| 5078 |
case PR_GET_PDEATHSIG: |
| 5079 |
case PR_GET_UNALIGN: |
| 5080 |
case PR_GET_FPEMU: |
| 5081 |
case PR_GET_FPEXC: |
| 5082 |
case PR_SET_NAME: |
| 5083 |
case PR_GET_NAME: |
| 5084 |
case PR_GET_ENDIAN: |
| 5085 |
#ifdef PR_GET_TSC |
| 5086 |
case PR_GET_TSC: |
| 5087 |
#endif |
| 5088 |
#ifdef PR_GET_TID_ADDRESS |
| 5089 |
case PR_GET_TID_ADDRESS: |
| 5090 |
#endif |
| 5091 |
#ifdef PR_GET_CHILD_SUBREAPER |
| 5092 |
case PR_GET_CHILD_SUBREAPER: |
| 5093 |
#endif |
| 5094 |
#ifdef PR_SET_THP_DISABLE |
| 5095 |
case PR_SET_THP_DISABLE: |
| 5096 |
#endif |
| 5097 |
len = strlen(STAP_RETVALUE); |
| 5098 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5099 |
", 0x%lx", (unsigned long)STAP_ARG_arg2); |
| 5100 |
break; |
| 5101 |
case PR_SET_DUMPABLE: |
| 5102 |
case PR_SET_KEEPCAPS: |
| 5103 |
#ifdef PR_SET_CHILD_SUBREAPER |
| 5104 |
case PR_SET_CHILD_SUBREAPER: |
| 5105 |
#endif |
| 5106 |
#ifdef PR_SET_NO_NEW_PRIVS |
| 5107 |
case PR_SET_NO_NEW_PRIVS: |
| 5108 |
#endif |
| 5109 |
#ifdef PR_SET_TIMERSLACK |
| 5110 |
case PR_SET_TIMERSLACK: |
| 5111 |
#endif |
| 5112 |
len = strlen(STAP_RETVALUE); |
| 5113 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5114 |
", %lu", (unsigned long)STAP_ARG_arg2); |
| 5115 |
break; |
| 5116 |
|
| 5117 |
// Options that use arg[23]: |
| 5118 |
#ifdef PR_MCE_KILL |
| 5119 |
case PR_MCE_KILL: |
| 5120 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5121 |
len = strlen(STAP_RETVALUE); |
| 5122 |
_stp_lookup_str(_stp_prctl_mce_kill_option_list, |
| 5123 |
(unsigned long)STAP_ARG_arg2, |
| 5124 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5125 |
switch ((unsigned long)STAP_ARG_arg2) { |
| 5126 |
case PR_MCE_KILL_SET: |
| 5127 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5128 |
len = strlen(STAP_RETVALUE); |
| 5129 |
_stp_lookup_str(_stp_prctl_mce_kill_option2_list, |
| 5130 |
(unsigned long)STAP_ARG_arg3, |
| 5131 |
STAP_RETVALUE + len, |
| 5132 |
MAXSTRINGLEN - len); |
| 5133 |
break; |
| 5134 |
case PR_MCE_KILL_CLEAR: |
| 5135 |
break; |
| 5136 |
default: |
| 5137 |
len = strlen(STAP_RETVALUE); |
| 5138 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5139 |
", 0x%lx", (unsigned long)STAP_ARG_arg3); |
| 5140 |
break; |
| 5141 |
} |
| 5142 |
break; |
| 5143 |
#endif |
| 5144 |
#ifdef PR_SET_SECCOMP |
| 5145 |
case PR_SET_SECCOMP: |
| 5146 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5147 |
len = strlen(STAP_RETVALUE); |
| 5148 |
_stp_lookup_str(_stp_seccomp_mode_list, |
| 5149 |
(unsigned long)STAP_ARG_arg2, |
| 5150 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5151 |
len = strlen(STAP_RETVALUE); |
| 5152 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5153 |
", 0x%lx", (unsigned long)STAP_ARG_arg3); |
| 5154 |
break; |
| 5155 |
#endif |
| 5156 |
#ifdef PR_SET_MM |
| 5157 |
case PR_SET_MM: |
| 5158 |
strlcat(STAP_RETVALUE, ", ", MAXSTRINGLEN); |
| 5159 |
len = strlen(STAP_RETVALUE); |
| 5160 |
_stp_lookup_str(_stp_prctl_mm_option_list, |
| 5161 |
(unsigned long)STAP_ARG_arg2, |
| 5162 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5163 |
len = strlen(STAP_RETVALUE); |
| 5164 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5165 |
", 0x%lx", (unsigned long)STAP_ARG_arg3); |
| 5166 |
break; |
| 5167 |
#endif |
| 5168 |
|
| 5169 |
// Options that use arg[2-5] |
| 5170 |
default: |
| 5171 |
len = strlen(STAP_RETVALUE); |
| 5172 |
_stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5173 |
", 0x%lx, 0x%lx, 0x%lx, 0x%lx", |
| 5174 |
(unsigned long)STAP_ARG_arg2, |
| 5175 |
(unsigned long)STAP_ARG_arg3, |
| 5176 |
(unsigned long)STAP_ARG_arg4, |
| 5177 |
(unsigned long)STAP_ARG_arg5); |
| 5178 |
break; |
| 5179 |
} |
| 5180 |
%} |
| 5181 |
|
| 5182 |
%{ |
| 5183 |
// RHEL5 x86_64 (2.6.18-398.el5) has __NR_timerfd_create but no |
| 5184 |
// timerfd.h. |
| 5185 |
#ifdef STAPCONF_TIMERFD_H |
| 5186 |
#include <linux/timerfd.h> |
| 5187 |
#endif |
| 5188 |
|
| 5189 |
static const _stp_val_array _stp_timerfd_flags_list[] = { |
| 5190 |
#ifdef TFD_TIMER_ABSTIME |
| 5191 |
V(TFD_TIMER_ABSTIME), |
| 5192 |
#endif |
| 5193 |
#ifdef TFD_TIMER_CANCEL_ON_SET |
| 5194 |
V(TFD_TIMER_CANCEL_ON_SET), |
| 5195 |
#endif |
| 5196 |
#ifdef TFD_CLOEXEC |
| 5197 |
V(TFD_CLOEXEC), |
| 5198 |
#endif |
| 5199 |
#ifdef TFD_NONBLOCK |
| 5200 |
V(TFD_NONBLOCK), |
| 5201 |
#endif |
| 5202 |
{0, NULL} |
| 5203 |
}; |
| 5204 |
%} |
| 5205 |
|
| 5206 |
function _stp_timerfd_flags_str:string(flags:long) |
| 5207 |
%{ /* pure */ /* unprivileged */ |
| 5208 |
_stp_lookup_or_str(_stp_timerfd_flags_list, |
| 5209 |
(unsigned int)STAP_ARG_flags, STAP_RETVALUE, |
| 5210 |
MAXSTRINGLEN); |
| 5211 |
%} |
| 5212 |
|
| 5213 |
%{ |
| 5214 |
// RHEL5 linux/pipe_fs_i.h has SPLICE* defs. RHEL6+ has it in |
| 5215 |
// separate linux/splice.h, which does not exist on RHEL5. |
| 5216 |
#include <linux/pipe_fs_i.h> |
| 5217 |
#ifndef SPLICE_F_MOVE |
| 5218 |
#include <linux/splice.h> |
| 5219 |
#endif |
| 5220 |
|
| 5221 |
static const _stp_val_array _stp_splice_flags_list[] = { |
| 5222 |
#ifdef SPLICE_F_MOVE |
| 5223 |
V(SPLICE_F_MOVE), |
| 5224 |
#endif |
| 5225 |
#ifdef SPLICE_F_NONBLOCK |
| 5226 |
V(SPLICE_F_NONBLOCK), |
| 5227 |
#endif |
| 5228 |
#ifdef SPLICE_F_MORE |
| 5229 |
V(SPLICE_F_MORE), |
| 5230 |
#endif |
| 5231 |
#ifdef SPLICE_F_GIFT |
| 5232 |
V(SPLICE_F_GIFT), |
| 5233 |
#endif |
| 5234 |
{0, NULL} |
| 5235 |
}; |
| 5236 |
%} |
| 5237 |
|
| 5238 |
function _stp_splice_flags_str:string(flags:long) |
| 5239 |
%{ /* pure */ /* unprivileged */ |
| 5240 |
_stp_lookup_or_str(_stp_splice_flags_list, |
| 5241 |
(unsigned int)STAP_ARG_flags, STAP_RETVALUE, |
| 5242 |
MAXSTRINGLEN); |
| 5243 |
%} |
| 5244 |
|
| 5245 |
%{ |
| 5246 |
#include <linux/falloc.h> |
| 5247 |
|
| 5248 |
static const _stp_val_array _stp_fallocate_mode_list[] = { |
| 5249 |
V(FALLOC_FL_KEEP_SIZE), |
| 5250 |
#ifdef FALLOC_FL_PUNCH_HOLE |
| 5251 |
V(FALLOC_FL_PUNCH_HOLE), |
| 5252 |
#endif |
| 5253 |
#ifdef FALLOC_FL_NO_HIDE_STALE |
| 5254 |
V(FALLOC_FL_NO_HIDE_STALE), |
| 5255 |
#endif |
| 5256 |
#ifdef FALLOC_FL_COLLAPSE_RANGE |
| 5257 |
V(FALLOC_FL_COLLAPSE_RANGE), |
| 5258 |
#endif |
| 5259 |
#ifdef FALLOC_FL_ZERO_RANGE |
| 5260 |
V(FALLOC_FL_ZERO_RANGE), |
| 5261 |
#endif |
| 5262 |
{0, NULL} |
| 5263 |
}; |
| 5264 |
%} |
| 5265 |
|
| 5266 |
function _stp_fallocate_mode_str:string(mode:long) |
| 5267 |
%{ /* pure */ /* unprivileged */ |
| 5268 |
_stp_lookup_or_str(_stp_fallocate_mode_list, |
| 5269 |
(unsigned int)STAP_ARG_mode, STAP_RETVALUE, |
| 5270 |
MAXSTRINGLEN); |
| 5271 |
%} |
| 5272 |
|
| 5273 |
%{ |
| 5274 |
#ifdef __NR_arch_prctl |
| 5275 |
#include <asm/prctl.h> |
| 5276 |
#endif |
| 5277 |
static const _stp_val_array _stp_arch_prctl_func_list[] = { |
| 5278 |
#ifdef ARCH_SET_FS |
| 5279 |
V(ARCH_SET_FS), |
| 5280 |
#endif |
| 5281 |
#ifdef ARCH_GET_FS |
| 5282 |
V(ARCH_GET_FS), |
| 5283 |
#endif |
| 5284 |
#ifdef ARCH_SET_GS |
| 5285 |
V(ARCH_SET_GS), |
| 5286 |
#endif |
| 5287 |
#ifdef ARCH_GET_GS |
| 5288 |
V(ARCH_GET_GS), |
| 5289 |
#endif |
| 5290 |
{0, NULL} |
| 5291 |
}; |
| 5292 |
%} |
| 5293 |
|
| 5294 |
function _stp_arch_prctl_func_str:string(func:long) |
| 5295 |
%{ /* pure */ /* unprivileged */ |
| 5296 |
_stp_lookup_str2(_stp_arch_prctl_func_list, |
| 5297 |
(int)STAP_ARG_func, STAP_RETVALUE, |
| 5298 |
MAXSTRINGLEN, 10); |
| 5299 |
%} |
| 5300 |
|
| 5301 |
|
| 5302 |
%{ |
| 5303 |
static const _stp_val_array _stp_adjtimex_modes_list[] = { |
| 5304 |
V(ADJ_OFFSET), |
| 5305 |
V(ADJ_FREQUENCY), |
| 5306 |
V(ADJ_MAXERROR), |
| 5307 |
V(ADJ_ESTERROR), |
| 5308 |
V(ADJ_STATUS), |
| 5309 |
V(ADJ_TIMECONST), |
| 5310 |
V(ADJ_TICK), |
| 5311 |
V(ADJ_OFFSET_SINGLESHOT), |
| 5312 |
{0, NULL} |
| 5313 |
}; |
| 5314 |
%} |
| 5315 |
|
| 5316 |
function _struct_timex_u:string(uaddr:long) |
| 5317 |
%{ /* pure */ |
| 5318 |
struct timex ts; |
| 5319 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5320 |
int len; |
| 5321 |
if (ptr == NULL) |
| 5322 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5323 |
else |
| 5324 |
{ |
| 5325 |
if (_stp_copy_from_user((char*)&ts, ptr, |
| 5326 |
sizeof(struct timex)) == 0) |
| 5327 |
{ |
| 5328 |
memset(STAP_RETVALUE, 0, MAXSTRINGLEN); |
| 5329 |
STAP_RETVALUE[0] = '{'; |
| 5330 |
_stp_lookup_or_str(_stp_adjtimex_modes_list, |
| 5331 |
(unsigned int)ts.modes, STAP_RETVALUE + 1, |
| 5332 |
MAXSTRINGLEN - 1); |
| 5333 |
len = strlen(STAP_RETVALUE); |
| 5334 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5335 |
", constant=%lu, esterror=%lu, freq=%lu, maxerror=%lu, offset=%lu, precision=%lu, status=%d, tick=%lu, tolerance=%lu}", |
| 5336 |
(long)ts.constant, (long)ts.esterror, (long)ts.freq, (long)ts.maxerror, (long)ts.offset, (long)ts.precision, ts.status, (long)ts.tick, (long)ts.tolerance); |
| 5337 |
|
| 5338 |
} |
| 5339 |
else |
| 5340 |
{ |
| 5341 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5342 |
(unsigned long)ptr); |
| 5343 |
} |
| 5344 |
} |
| 5345 |
%} |
| 5346 |
|
| 5347 |
function _struct_compat_timex_u:string(uaddr:long) |
| 5348 |
%{ /* pure */ |
| 5349 |
#if defined(CONFIG_COMPAT) |
| 5350 |
#if defined(CONFIG_COMPAT_32BIT_TIME) && (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) |
| 5351 |
#define compat_timex old_timex32 |
| 5352 |
#endif |
| 5353 |
struct compat_timex ts; |
| 5354 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5355 |
int len; |
| 5356 |
if (ptr == NULL) |
| 5357 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5358 |
else |
| 5359 |
{ |
| 5360 |
if (_stp_copy_from_user((char*)&ts, ptr, |
| 5361 |
sizeof(struct compat_timex)) == 0) |
| 5362 |
{ |
| 5363 |
memset(STAP_RETVALUE, 0, MAXSTRINGLEN); |
| 5364 |
STAP_RETVALUE[0] = '{'; |
| 5365 |
_stp_lookup_or_str(_stp_adjtimex_modes_list, |
| 5366 |
(unsigned int)ts.modes, STAP_RETVALUE + 1, |
| 5367 |
MAXSTRINGLEN - 1); |
| 5368 |
len = strlen(STAP_RETVALUE); |
| 5369 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5370 |
", constant=%u, esterror=%u, freq=%u, maxerror=%u, offset=%u, precision=%u, status=%d, tick=%u, tolerance=%u}", |
| 5371 |
ts.constant, ts.esterror, ts.freq, ts.maxerror, ts.offset, ts.precision, ts.status, ts.tick, ts.tolerance); |
| 5372 |
|
| 5373 |
} |
| 5374 |
else |
| 5375 |
{ |
| 5376 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5377 |
(unsigned long)ptr); |
| 5378 |
} |
| 5379 |
} |
| 5380 |
#if defined(CONFIG_COMPAT_32BIT_TIME) && (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) |
| 5381 |
#undef compat_timex |
| 5382 |
#endif |
| 5383 |
#endif |
| 5384 |
%} |
| 5385 |
|
| 5386 |
%{ |
| 5387 |
#include <linux/fs.h> |
| 5388 |
static const _stp_val_array _stp_sync_file_range_list[] = { |
| 5389 |
#ifdef SYNC_FILE_RANGE_WAIT_BEFORE |
| 5390 |
V(SYNC_FILE_RANGE_WAIT_BEFORE), |
| 5391 |
#endif |
| 5392 |
#ifdef SYNC_FILE_RANGE_WRITE |
| 5393 |
V(SYNC_FILE_RANGE_WRITE), |
| 5394 |
#endif |
| 5395 |
#ifdef SYNC_FILE_RANGE_WAIT_AFTER |
| 5396 |
V(SYNC_FILE_RANGE_WAIT_AFTER), |
| 5397 |
#endif |
| 5398 |
{0, NULL} |
| 5399 |
}; |
| 5400 |
%} |
| 5401 |
|
| 5402 |
function _sync_file_range_flags_str:string(flags:long) |
| 5403 |
%{ /* pure */ /* unprivileged */ |
| 5404 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 5405 |
_stp_lookup_or_str(_stp_sync_file_range_list, flags, |
| 5406 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 5407 |
%} |
| 5408 |
|
| 5409 |
%{ |
| 5410 |
#include <asm/siginfo.h> |
| 5411 |
static const _stp_val_array _stp_siginfo_si_code_list[] = { |
| 5412 |
V(SI_USER), |
| 5413 |
V(SI_KERNEL), |
| 5414 |
V(SI_QUEUE), |
| 5415 |
V(SI_TIMER), |
| 5416 |
V(SI_MESGQ), |
| 5417 |
V(SI_ASYNCIO), |
| 5418 |
V(SI_SIGIO), |
| 5419 |
V(SI_TKILL), |
| 5420 |
V(SI_DETHREAD), |
| 5421 |
{0, NULL} |
| 5422 |
}; |
| 5423 |
|
| 5424 |
/* SIGILL si_codes */ |
| 5425 |
static const _stp_val_array _stp_sigill_si_code_list[] = { |
| 5426 |
V(ILL_ILLOPC), |
| 5427 |
V(ILL_ILLOPN), |
| 5428 |
V(ILL_ILLADR), |
| 5429 |
V(ILL_ILLTRP), |
| 5430 |
V(ILL_PRVOPC), |
| 5431 |
V(ILL_PRVREG), |
| 5432 |
V(ILL_COPROC), |
| 5433 |
V(ILL_BADSTK), |
| 5434 |
{0, NULL} |
| 5435 |
}; |
| 5436 |
|
| 5437 |
/* SIGFPE si_codes */ |
| 5438 |
static const _stp_val_array _stp_sigfpe_si_code_list[] = { |
| 5439 |
V(FPE_INTDIV), |
| 5440 |
V(FPE_INTOVF), |
| 5441 |
V(FPE_FLTDIV), |
| 5442 |
V(FPE_FLTOVF), |
| 5443 |
V(FPE_FLTUND), |
| 5444 |
V(FPE_FLTRES), |
| 5445 |
V(FPE_FLTINV), |
| 5446 |
V(FPE_FLTSUB), |
| 5447 |
{0, NULL} |
| 5448 |
}; |
| 5449 |
|
| 5450 |
/* SIGSEGV si_codes */ |
| 5451 |
static const _stp_val_array _stp_sigsegv_si_code_list[] = { |
| 5452 |
V(SEGV_MAPERR), |
| 5453 |
V(SEGV_ACCERR), |
| 5454 |
#ifdef SEGV_BNDERR |
| 5455 |
V(SEGV_BNDERR), |
| 5456 |
#endif |
| 5457 |
{0, NULL} |
| 5458 |
}; |
| 5459 |
|
| 5460 |
/* SIGBUS si_codes */ |
| 5461 |
static const _stp_val_array _stp_sigbus_si_code_list[] = { |
| 5462 |
V(BUS_ADRALN), |
| 5463 |
V(BUS_ADRERR), |
| 5464 |
V(BUS_OBJERR), |
| 5465 |
#ifdef BUS_MCEERR_AR |
| 5466 |
V(BUS_MCEERR_AR), |
| 5467 |
#endif |
| 5468 |
#ifdef BUS_MCEERR_AO |
| 5469 |
V(BUS_MCEERR_AO), |
| 5470 |
#endif |
| 5471 |
{0, NULL} |
| 5472 |
}; |
| 5473 |
|
| 5474 |
/* SIGTRAP si_codes */ |
| 5475 |
static const _stp_val_array _stp_sigtrap_si_code_list[] = { |
| 5476 |
V(TRAP_BRKPT), |
| 5477 |
V(TRAP_TRACE), |
| 5478 |
#ifdef TRAP_BRANCH |
| 5479 |
V(TRAP_BRANCH), |
| 5480 |
#endif |
| 5481 |
#ifdef TRAP_HWBKPT |
| 5482 |
V(TRAP_HWBKPT), |
| 5483 |
#endif |
| 5484 |
{0, NULL} |
| 5485 |
}; |
| 5486 |
|
| 5487 |
/* SIGCHLD si_codes */ |
| 5488 |
static const _stp_val_array _stp_sigchld_si_code_list[] = { |
| 5489 |
V(CLD_EXITED), |
| 5490 |
V(CLD_KILLED), |
| 5491 |
V(CLD_DUMPED), |
| 5492 |
V(CLD_TRAPPED), |
| 5493 |
V(CLD_STOPPED), |
| 5494 |
V(CLD_CONTINUED), |
| 5495 |
{0, NULL} |
| 5496 |
}; |
| 5497 |
|
| 5498 |
/* SIGPOLL si_codes */ |
| 5499 |
static const _stp_val_array _stp_sigpoll_si_code_list[] = { |
| 5500 |
V(POLL_IN), |
| 5501 |
V(POLL_OUT), |
| 5502 |
V(POLL_MSG), |
| 5503 |
V(POLL_ERR), |
| 5504 |
V(POLL_PRI), |
| 5505 |
V(POLL_HUP), |
| 5506 |
{0, NULL} |
| 5507 |
}; |
| 5508 |
|
| 5509 |
/* SIGSYS si_codes */ |
| 5510 |
static const _stp_val_array _stp_sigsys_si_code_list[] = { |
| 5511 |
#ifdef SYS_SECCOMP |
| 5512 |
V(SYS_SECCOMP), |
| 5513 |
#endif |
| 5514 |
{0, NULL} |
| 5515 |
}; |
| 5516 |
%} |
| 5517 |
|
| 5518 |
function _stp_siginfo_u:string(uaddr:long) |
| 5519 |
%{ /* pure */ |
| 5520 |
siginfo_t sinfo; |
| 5521 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5522 |
int len; |
| 5523 |
|
| 5524 |
if (ptr == NULL) { |
| 5525 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5526 |
return; |
| 5527 |
} |
| 5528 |
if (_stp_copy_from_user((void *)&sinfo, ptr, |
| 5529 |
sizeof(sinfo)) != 0) { |
| 5530 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5531 |
(unsigned long)ptr); |
| 5532 |
return; |
| 5533 |
} |
| 5534 |
|
| 5535 |
strlcpy(STAP_RETVALUE, "{si_signo=", MAXSTRINGLEN); |
| 5536 |
len = strlen(STAP_RETVALUE); |
| 5537 |
_stp_lookup_str(_stp_signal_list, sinfo.si_signo, |
| 5538 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5539 |
len = strlen(STAP_RETVALUE); |
| 5540 |
strlcpy(STAP_RETVALUE + len, ", si_code=", MAXSTRINGLEN - len); |
| 5541 |
len = strlen(STAP_RETVALUE); |
| 5542 |
_stp_lookup_str(_stp_siginfo_si_code_list, sinfo.si_code, |
| 5543 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5544 |
|
| 5545 |
// OK, this is odd. If si_code didn't match anything in |
| 5546 |
// _stp_siginfo_si_code_list, we need to decode si_code based |
| 5547 |
// on the si_signo value. |
| 5548 |
if (*(STAP_RETVALUE + len) == '0') { |
| 5549 |
const _stp_val_array *array = NULL; |
| 5550 |
switch (sinfo.si_signo) { |
| 5551 |
case SIGILL: |
| 5552 |
array = _stp_sigill_si_code_list; |
| 5553 |
break; |
| 5554 |
case SIGFPE: |
| 5555 |
array = _stp_sigfpe_si_code_list; |
| 5556 |
break; |
| 5557 |
case SIGSEGV: |
| 5558 |
array = _stp_sigsegv_si_code_list; |
| 5559 |
break; |
| 5560 |
case SIGBUS: |
| 5561 |
array = _stp_sigbus_si_code_list; |
| 5562 |
break; |
| 5563 |
case SIGTRAP: |
| 5564 |
array = _stp_sigtrap_si_code_list; |
| 5565 |
break; |
| 5566 |
case SIGCHLD: |
| 5567 |
array = _stp_sigchld_si_code_list; |
| 5568 |
break; |
| 5569 |
case SIGPOLL: |
| 5570 |
array = _stp_sigpoll_si_code_list; |
| 5571 |
break; |
| 5572 |
case SIGSYS: |
| 5573 |
array = _stp_sigsys_si_code_list; |
| 5574 |
break; |
| 5575 |
default: |
| 5576 |
// Do nothing. The original si_code lookup |
| 5577 |
// added a hex version. |
| 5578 |
break; |
| 5579 |
} |
| 5580 |
if (array) |
| 5581 |
_stp_lookup_str(array, sinfo.si_code, |
| 5582 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5583 |
} |
| 5584 |
len = strlen(STAP_RETVALUE); |
| 5585 |
#ifdef SI_FROMUSER |
| 5586 |
if (SI_FROMUSER(&sinfo)) { |
| 5587 |
switch (sinfo.si_code) { |
| 5588 |
case SI_TIMER: |
| 5589 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5590 |
", si_tid=%#x, si_overrun=%d", |
| 5591 |
sinfo.si_tid, sinfo.si_overrun); |
| 5592 |
break; |
| 5593 |
default: |
| 5594 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5595 |
", si_pid=%lu, si_uid=%lu", |
| 5596 |
(unsigned long)sinfo.si_pid, |
| 5597 |
(unsigned long)sinfo.si_uid); |
| 5598 |
break; |
| 5599 |
} |
| 5600 |
} |
| 5601 |
else |
| 5602 |
#endif /* SI_FROMUSER */ |
| 5603 |
{ |
| 5604 |
switch (sinfo.si_signo) { |
| 5605 |
case SIGCHLD: |
| 5606 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5607 |
", si_pid=%lu, si_uid=%lu, si_status=", |
| 5608 |
(unsigned long)sinfo.si_pid, |
| 5609 |
(unsigned long)sinfo.si_uid); |
| 5610 |
len = strlen(STAP_RETVALUE); |
| 5611 |
if (sinfo.si_code == CLD_EXITED) |
| 5612 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5613 |
"%d", sinfo.si_status); |
| 5614 |
else |
| 5615 |
_stp_lookup_str(_stp_signal_list, |
| 5616 |
sinfo.si_status, |
| 5617 |
STAP_RETVALUE + len, |
| 5618 |
MAXSTRINGLEN - len); |
| 5619 |
break; |
| 5620 |
case SIGILL: |
| 5621 |
case SIGFPE: |
| 5622 |
case SIGSEGV: |
| 5623 |
case SIGBUS: |
| 5624 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5625 |
", si_addr=%#lx", (unsigned long)sinfo.si_addr); |
| 5626 |
break; |
| 5627 |
case SIGPOLL: |
| 5628 |
if (sinfo.si_code == POLL_IN |
| 5629 |
|| sinfo.si_code == POLL_OUT |
| 5630 |
|| sinfo.si_code == POLL_MSG) |
| 5631 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5632 |
", si_band=%ld", (long)sinfo.si_band); |
| 5633 |
break; |
| 5634 |
#if defined(SIGSYS) && defined(__ARCH_SIGSYS) |
| 5635 |
case SIGSYS: |
| 5636 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5637 |
", si_call_addr=%#lx, si_syscall=%d, si_arch=%u", |
| 5638 |
(unsigned long)(sinfo.si_call_addr), |
| 5639 |
sinfo.si_syscall, sinfo.si_arch); |
| 5640 |
break; |
| 5641 |
#endif |
| 5642 |
default: |
| 5643 |
if (sinfo.si_pid || sinfo.si_uid) |
| 5644 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5645 |
", si_pid=%lu, si_uid=%lu", |
| 5646 |
(unsigned long)sinfo.si_pid, |
| 5647 |
(unsigned long)sinfo.si_uid); |
| 5648 |
break; |
| 5649 |
} |
| 5650 |
} |
| 5651 |
len = strlen(STAP_RETVALUE); |
| 5652 |
strlcat(STAP_RETVALUE, "}", MAXSTRINGLEN); |
| 5653 |
%} |
| 5654 |
|
| 5655 |
%{ |
| 5656 |
#ifdef CONFIG_COMPAT |
| 5657 |
#include <linux/compat.h> |
| 5658 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) |
| 5659 |
#include "linux/compat_structs.h" |
| 5660 |
#endif |
| 5661 |
#endif |
| 5662 |
%} |
| 5663 |
|
| 5664 |
function _stp_compat_siginfo_u:string(uaddr:long) |
| 5665 |
%{ /* pure */ |
| 5666 |
#ifdef CONFIG_COMPAT |
| 5667 |
compat_siginfo_t sinfo; |
| 5668 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5669 |
int len; |
| 5670 |
|
| 5671 |
if (ptr == NULL) { |
| 5672 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5673 |
return; |
| 5674 |
} |
| 5675 |
if (_stp_copy_from_user((void *)&sinfo, ptr, |
| 5676 |
sizeof(sinfo)) != 0) { |
| 5677 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5678 |
(unsigned long)ptr); |
| 5679 |
return; |
| 5680 |
} |
| 5681 |
|
| 5682 |
strlcpy(STAP_RETVALUE, "{si_signo=", MAXSTRINGLEN); |
| 5683 |
len = strlen(STAP_RETVALUE); |
| 5684 |
_stp_lookup_str(_stp_signal_list, sinfo.si_signo, |
| 5685 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5686 |
len = strlen(STAP_RETVALUE); |
| 5687 |
strlcpy(STAP_RETVALUE + len, ", si_code=", MAXSTRINGLEN - len); |
| 5688 |
len = strlen(STAP_RETVALUE); |
| 5689 |
_stp_lookup_str(_stp_siginfo_si_code_list, sinfo.si_code, |
| 5690 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5691 |
|
| 5692 |
// OK, this is odd. If si_code didn't match anything in |
| 5693 |
// _stp_siginfo_si_code_list, we need to decode si_code based |
| 5694 |
// on the si_signo value. |
| 5695 |
if (*(STAP_RETVALUE + len) == '0') { |
| 5696 |
const _stp_val_array *array = NULL; |
| 5697 |
switch (sinfo.si_signo) { |
| 5698 |
case SIGILL: |
| 5699 |
array = _stp_sigill_si_code_list; |
| 5700 |
break; |
| 5701 |
case SIGFPE: |
| 5702 |
array = _stp_sigfpe_si_code_list; |
| 5703 |
break; |
| 5704 |
case SIGSEGV: |
| 5705 |
array = _stp_sigsegv_si_code_list; |
| 5706 |
break; |
| 5707 |
case SIGBUS: |
| 5708 |
array = _stp_sigbus_si_code_list; |
| 5709 |
break; |
| 5710 |
case SIGTRAP: |
| 5711 |
array = _stp_sigtrap_si_code_list; |
| 5712 |
break; |
| 5713 |
case SIGCHLD: |
| 5714 |
array = _stp_sigchld_si_code_list; |
| 5715 |
break; |
| 5716 |
case SIGPOLL: |
| 5717 |
array = _stp_sigpoll_si_code_list; |
| 5718 |
break; |
| 5719 |
case SIGSYS: |
| 5720 |
array = _stp_sigsys_si_code_list; |
| 5721 |
break; |
| 5722 |
default: |
| 5723 |
// Do nothing. The original si_code lookup |
| 5724 |
// added a hex version. |
| 5725 |
break; |
| 5726 |
} |
| 5727 |
if (array) |
| 5728 |
_stp_lookup_str(array, sinfo.si_code, |
| 5729 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5730 |
} |
| 5731 |
len = strlen(STAP_RETVALUE); |
| 5732 |
#ifdef SI_FROMUSER |
| 5733 |
if (SI_FROMUSER(&sinfo)) { |
| 5734 |
switch (sinfo.si_code) { |
| 5735 |
case SI_TIMER: |
| 5736 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5737 |
", si_tid=%#x, si_overrun=%d", |
| 5738 |
sinfo.si_tid, sinfo.si_overrun); |
| 5739 |
break; |
| 5740 |
default: |
| 5741 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5742 |
", si_pid=%lu, si_uid=%lu", |
| 5743 |
(unsigned long)sinfo.si_pid, |
| 5744 |
(unsigned long)sinfo.si_uid); |
| 5745 |
break; |
| 5746 |
} |
| 5747 |
} |
| 5748 |
else |
| 5749 |
#endif /* SI_FROMUSER */ |
| 5750 |
{ |
| 5751 |
switch (sinfo.si_signo) { |
| 5752 |
case SIGCHLD: |
| 5753 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5754 |
", si_pid=%lu, si_uid=%lu, si_status=", |
| 5755 |
(unsigned long)sinfo.si_pid, |
| 5756 |
(unsigned long)sinfo.si_uid); |
| 5757 |
len = strlen(STAP_RETVALUE); |
| 5758 |
if (sinfo.si_code == CLD_EXITED) |
| 5759 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5760 |
"%d", sinfo.si_status); |
| 5761 |
else |
| 5762 |
_stp_lookup_str(_stp_signal_list, |
| 5763 |
sinfo.si_status, |
| 5764 |
STAP_RETVALUE + len, |
| 5765 |
MAXSTRINGLEN - len); |
| 5766 |
break; |
| 5767 |
case SIGILL: |
| 5768 |
case SIGFPE: |
| 5769 |
case SIGSEGV: |
| 5770 |
case SIGBUS: |
| 5771 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5772 |
", si_addr=%#lx", (unsigned long)sinfo.si_addr); |
| 5773 |
break; |
| 5774 |
case SIGPOLL: |
| 5775 |
if (sinfo.si_code == POLL_IN |
| 5776 |
|| sinfo.si_code == POLL_OUT |
| 5777 |
|| sinfo.si_code == POLL_MSG) |
| 5778 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5779 |
", si_band=%ld", (long)sinfo.si_band); |
| 5780 |
break; |
| 5781 |
// Checking for SIGSYS/__ARCH_SIGSYS is fine for the "real" siginfo_t, |
| 5782 |
// but the compat version can be without the SIGSYS fields, so we'll |
| 5783 |
// have to add an arch test. |
| 5784 |
#if defined(SIGSYS) && defined(__ARCH_SIGSYS) \ |
| 5785 |
&& !defined(__s390x__) && !defined(__powerpc64__) |
| 5786 |
case SIGSYS: |
| 5787 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5788 |
", si_call_addr=%#lx, si_syscall=%d, si_arch=%u", |
| 5789 |
(unsigned long)sinfo.si_call_addr, |
| 5790 |
sinfo.si_syscall, sinfo.si_arch); |
| 5791 |
break; |
| 5792 |
#endif |
| 5793 |
default: |
| 5794 |
if (sinfo.si_pid || sinfo.si_uid) |
| 5795 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, |
| 5796 |
", si_pid=%lu, si_uid=%lu", |
| 5797 |
(unsigned long)sinfo.si_pid, |
| 5798 |
(unsigned long)sinfo.si_uid); |
| 5799 |
break; |
| 5800 |
} |
| 5801 |
} |
| 5802 |
len = strlen(STAP_RETVALUE); |
| 5803 |
strlcat(STAP_RETVALUE, "}", MAXSTRINGLEN); |
| 5804 |
#endif /* CONFIG_COMPAT */ |
| 5805 |
%} |
| 5806 |
|
| 5807 |
%{ |
| 5808 |
#include <linux/times.h> |
| 5809 |
%} |
| 5810 |
|
| 5811 |
function _struct_tms_u:string(uaddr:long) |
| 5812 |
%{ /* pure */ |
| 5813 |
struct tms tm; |
| 5814 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5815 |
if (ptr == NULL) |
| 5816 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5817 |
else |
| 5818 |
{ |
| 5819 |
if (_stp_copy_from_user((char*)&tm, ptr, |
| 5820 |
sizeof(struct tms)) == 0) |
| 5821 |
{ |
| 5822 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 5823 |
"{tms_utime=%lu, tms_stime=%lu, tms_cutime=%lu, tms_cstime=%lu}", |
| 5824 |
tm.tms_utime, tm.tms_stime, tm.tms_cutime, tm.tms_cstime); |
| 5825 |
} |
| 5826 |
else |
| 5827 |
{ |
| 5828 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5829 |
(unsigned long)ptr); |
| 5830 |
} |
| 5831 |
} |
| 5832 |
%} |
| 5833 |
|
| 5834 |
%{ |
| 5835 |
#include <linux/kernel.h> |
| 5836 |
%} |
| 5837 |
|
| 5838 |
function _struct_sysinfo_u:string(uaddr:long) |
| 5839 |
%{ /* pure */ |
| 5840 |
struct sysinfo si; |
| 5841 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5842 |
if (ptr == NULL) |
| 5843 |
strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 5844 |
else |
| 5845 |
{ |
| 5846 |
if (_stp_copy_from_user((char*)&si, ptr, |
| 5847 |
sizeof(struct sysinfo)) == 0) |
| 5848 |
{ |
| 5849 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 5850 |
"{uptime=%ld, loads=[%lu, %lu, %lu], totalram=%lu, freeram=%lu, " |
| 5851 |
"sharedram=%lu, bufferram=%lu, totalswap=%lu, freeswap=%lu, procs=%u}", |
| 5852 |
si.uptime, si.loads[0], si.loads[1], si.loads[2], si.totalram, si.freeram, |
| 5853 |
si.sharedram, si.bufferram, si.totalswap, si.freeswap, si.procs); |
| 5854 |
} |
| 5855 |
else |
| 5856 |
{ |
| 5857 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5858 |
(unsigned long)ptr); |
| 5859 |
} |
| 5860 |
} |
| 5861 |
%} |
| 5862 |
|
| 5863 |
%{ |
| 5864 |
#include <linux/kexec.h> |
| 5865 |
static const _stp_val_array _stp_kexec_flags_list[] = { |
| 5866 |
#if defined(CONFIG_KEXEC) |
| 5867 |
V(KEXEC_ON_CRASH), |
| 5868 |
#ifdef KEXEC_PRESERVE_CONTEXT |
| 5869 |
V(KEXEC_PRESERVE_CONTEXT), |
| 5870 |
#endif |
| 5871 |
V(KEXEC_ARCH_DEFAULT), |
| 5872 |
V(KEXEC_ARCH_386), |
| 5873 |
V(KEXEC_ARCH_X86_64), |
| 5874 |
V(KEXEC_ARCH_PPC), |
| 5875 |
V(KEXEC_ARCH_PPC64), |
| 5876 |
V(KEXEC_ARCH_IA_64), |
| 5877 |
#ifdef KEXEC_ARCH_ARM |
| 5878 |
V(KEXEC_ARCH_ARM), |
| 5879 |
#endif |
| 5880 |
V(KEXEC_ARCH_S390), |
| 5881 |
V(KEXEC_ARCH_SH), |
| 5882 |
#ifdef KEXEC_ARCH_MIPS_LE |
| 5883 |
V(KEXEC_ARCH_MIPS_LE), |
| 5884 |
#endif |
| 5885 |
#ifdef KEXEC_ARCH_MIPS |
| 5886 |
V(KEXEC_ARCH_MIPS), |
| 5887 |
#endif |
| 5888 |
#endif /* CONFIG_KEXEC */ |
| 5889 |
{0, NULL} |
| 5890 |
}; |
| 5891 |
|
| 5892 |
static const _stp_val_array _stp_kexec_file_load_flags_list[] = { |
| 5893 |
#ifdef KEXEC_FILE_UNLOAD |
| 5894 |
V(KEXEC_FILE_UNLOAD), |
| 5895 |
#endif |
| 5896 |
#ifdef KEXEC_FILE_ON_CRASH |
| 5897 |
V(KEXEC_FILE_ON_CRASH), |
| 5898 |
#endif |
| 5899 |
#ifdef KEXEC_FILE_NO_INITRAMFS |
| 5900 |
V(KEXEC_FILE_NO_INITRAMFS), |
| 5901 |
#endif |
| 5902 |
{0, NULL} |
| 5903 |
}; |
| 5904 |
%} |
| 5905 |
|
| 5906 |
function _kexec_flags_str:string(flags:long) |
| 5907 |
%{ /* pure */ /* unprivileged */ |
| 5908 |
unsigned long flags = (unsigned long)STAP_ARG_flags; |
| 5909 |
_stp_lookup_or_str(_stp_kexec_flags_list, flags, STAP_RETVALUE, |
| 5910 |
MAXSTRINGLEN); |
| 5911 |
%} |
| 5912 |
|
| 5913 |
function _kexec_file_load_flags_str:string(flags:long) |
| 5914 |
%{ /* pure */ /* unprivileged */ |
| 5915 |
unsigned long flags = (unsigned long)STAP_ARG_flags; |
| 5916 |
_stp_lookup_or_str(_stp_kexec_file_load_flags_list, flags, |
| 5917 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 5918 |
%} |
| 5919 |
|
| 5920 |
%{ |
| 5921 |
#include <linux/signal.h> |
| 5922 |
|
| 5923 |
static const _stp_val_array _stp_sigaltstack_flags_list[] = { |
| 5924 |
V(SS_ONSTACK), |
| 5925 |
V(SS_DISABLE), |
| 5926 |
{0, NULL} |
| 5927 |
}; |
| 5928 |
|
| 5929 |
%} |
| 5930 |
|
| 5931 |
function _stp_sigaltstack_u:string(uaddr:long) |
| 5932 |
%{ /* pure */ |
| 5933 |
stack_t stk; |
| 5934 |
|
| 5935 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5936 |
int len; |
| 5937 |
|
| 5938 |
if (ptr == NULL || _stp_copy_from_user((void *)&stk, ptr, |
| 5939 |
sizeof(stk)) != 0) { |
| 5940 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5941 |
(unsigned long)ptr); |
| 5942 |
return; |
| 5943 |
} |
| 5944 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "{ss_sp=0x%lx, ss_flags=", |
| 5945 |
(unsigned long)stk.ss_sp); |
| 5946 |
len = strlen(STAP_RETVALUE); |
| 5947 |
_stp_lookup_str(_stp_sigaltstack_flags_list, stk.ss_flags, |
| 5948 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5949 |
len = strlen(STAP_RETVALUE); |
| 5950 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, ", ss_size=%lu}", |
| 5951 |
(unsigned long)stk.ss_size); |
| 5952 |
%} |
| 5953 |
|
| 5954 |
function _stp_compat_sigaltstack_u:string(uaddr:long) |
| 5955 |
%{ /* pure */ |
| 5956 |
#ifdef CONFIG_COMPAT |
| 5957 |
#if defined(CONFIG_GENERIC_SIGALTSTACK) \ |
| 5958 |
|| LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0) |
| 5959 |
compat_stack_t stk; |
| 5960 |
#elif defined(__x86_64__) |
| 5961 |
stack_ia32_t stk; |
| 5962 |
#elif defined(__s390x__) |
| 5963 |
stack_t32 stk; |
| 5964 |
#elif defined(__powerpc64__) |
| 5965 |
stack_32_t stk; |
| 5966 |
#endif |
| 5967 |
|
| 5968 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 5969 |
int len; |
| 5970 |
|
| 5971 |
if (ptr == NULL || _stp_copy_from_user((void *)&stk, ptr, |
| 5972 |
sizeof(stk)) != 0) { |
| 5973 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 5974 |
(unsigned long)ptr); |
| 5975 |
return; |
| 5976 |
} |
| 5977 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "{ss_sp=0x%lx, ss_flags=", |
| 5978 |
(unsigned long)stk.ss_sp); |
| 5979 |
len = strlen(STAP_RETVALUE); |
| 5980 |
_stp_lookup_str(_stp_sigaltstack_flags_list, stk.ss_flags, |
| 5981 |
STAP_RETVALUE + len, MAXSTRINGLEN - len); |
| 5982 |
len = strlen(STAP_RETVALUE); |
| 5983 |
snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, ", ss_size=%lu}", |
| 5984 |
(unsigned long)stk.ss_size); |
| 5985 |
#endif |
| 5986 |
%} |
| 5987 |
|
| 5988 |
%{ |
| 5989 |
#include <linux/fs.h> |
| 5990 |
static const _stp_val_array _stp_renameat2_flags_list[] = { |
| 5991 |
#ifdef RENAME_NOREPLACE |
| 5992 |
V(RENAME_NOREPLACE), |
| 5993 |
#endif |
| 5994 |
#ifdef RENAME_EXCHANGE |
| 5995 |
V(RENAME_EXCHANGE), |
| 5996 |
#endif |
| 5997 |
#ifdef RENAME_WHITEOUT |
| 5998 |
V(RENAME_WHITEOUT), |
| 5999 |
#endif |
| 6000 |
{0, NULL} |
| 6001 |
}; |
| 6002 |
%} |
| 6003 |
|
| 6004 |
function _renameat2_flags_str:string(flags:long) |
| 6005 |
%{ /* pure */ /* unprivileged */ |
| 6006 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 6007 |
_stp_lookup_or_str(_stp_renameat2_flags_list, flags, STAP_RETVALUE, |
| 6008 |
MAXSTRINGLEN); |
| 6009 |
%} |
| 6010 |
|
| 6011 |
%{ |
| 6012 |
// fanotify_init() and fanotify_mark() were enabled in kernel version |
| 6013 |
// 2.6.37 (but present in some earlier kernels). |
| 6014 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) \ |
| 6015 |
&& defined(__NR_fanotify_init) && defined(__NR_fanotify_mark) |
| 6016 |
#include <linux/fanotify.h> |
| 6017 |
static const _stp_val_array _stp_fanotify_init_class_flags_list[] = { |
| 6018 |
V(FAN_CLASS_NOTIF), |
| 6019 |
V(FAN_CLASS_CONTENT), |
| 6020 |
V(FAN_CLASS_PRE_CONTENT), |
| 6021 |
{0, NULL} |
| 6022 |
}; |
| 6023 |
|
| 6024 |
static const _stp_val_array _stp_fanotify_init_extra_flags_list[] = { |
| 6025 |
V(FAN_CLOEXEC), |
| 6026 |
V(FAN_NONBLOCK), |
| 6027 |
V(FAN_UNLIMITED_QUEUE), |
| 6028 |
V(FAN_UNLIMITED_MARKS), |
| 6029 |
{0, NULL} |
| 6030 |
}; |
| 6031 |
|
| 6032 |
static const _stp_val_array _stp_fanotify_mark_flags_list[] = { |
| 6033 |
V(FAN_MARK_ADD), |
| 6034 |
V(FAN_MARK_REMOVE), |
| 6035 |
V(FAN_MARK_FLUSH), |
| 6036 |
V(FAN_MARK_DONT_FOLLOW), |
| 6037 |
V(FAN_MARK_ONLYDIR), |
| 6038 |
V(FAN_MARK_MOUNT), |
| 6039 |
V(FAN_MARK_IGNORED_MASK), |
| 6040 |
V(FAN_MARK_IGNORED_SURV_MODIFY), |
| 6041 |
{0, NULL} |
| 6042 |
}; |
| 6043 |
|
| 6044 |
/* Note that FAN_CLOSE is (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE). So, |
| 6045 |
* we really can't use it. */ |
| 6046 |
static const _stp_val_array _stp_fanotify_mark_mask_list[] = { |
| 6047 |
V(FAN_ACCESS), |
| 6048 |
V(FAN_MODIFY), |
| 6049 |
V(FAN_CLOSE_WRITE), |
| 6050 |
V(FAN_CLOSE_NOWRITE), |
| 6051 |
V(FAN_OPEN), |
| 6052 |
V(FAN_Q_OVERFLOW), |
| 6053 |
V(FAN_OPEN_PERM), |
| 6054 |
V(FAN_ACCESS_PERM), |
| 6055 |
V(FAN_ONDIR), |
| 6056 |
V(FAN_EVENT_ON_CHILD), |
| 6057 |
{0, NULL} |
| 6058 |
}; |
| 6059 |
#endif |
| 6060 |
%} |
| 6061 |
|
| 6062 |
function _fanotify_init_flags_str:string(flags:long) |
| 6063 |
%{ /* pure */ /* unprivileged */ |
| 6064 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) \ |
| 6065 |
&& defined(__NR_fanotify_init) && defined(__NR_fanotify_mark) |
| 6066 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 6067 |
/* deprecation: linux commit 23c9deeb3285d */ |
| 6068 |
#ifndef FAN_ALL_CLASS_BITS |
| 6069 |
#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) |
| 6070 |
#endif |
| 6071 |
unsigned int flags_part1 = flags & FAN_ALL_CLASS_BITS; |
| 6072 |
unsigned int flags_part2 = flags & ~FAN_ALL_CLASS_BITS; |
| 6073 |
|
| 6074 |
_stp_lookup_str(_stp_fanotify_init_class_flags_list, flags_part1, |
| 6075 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6076 |
if (flags_part2) { |
| 6077 |
strlcat(STAP_RETVALUE, "|", MAXSTRINGLEN); |
| 6078 |
_stp_lookup_or_str(_stp_fanotify_init_extra_flags_list, |
| 6079 |
flags_part2, STAP_RETVALUE, MAXSTRINGLEN); |
| 6080 |
} |
| 6081 |
#endif |
| 6082 |
%} |
| 6083 |
|
| 6084 |
function _fanotify_mark_flags_str:string(flags:long) |
| 6085 |
%{ /* pure */ /* unprivileged */ |
| 6086 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) \ |
| 6087 |
&& defined(__NR_fanotify_init) && defined(__NR_fanotify_mark) |
| 6088 |
unsigned int flags = (unsigned int)STAP_ARG_flags; |
| 6089 |
|
| 6090 |
_stp_lookup_or_str(_stp_fanotify_mark_flags_list, flags, |
| 6091 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6092 |
#endif |
| 6093 |
%} |
| 6094 |
|
| 6095 |
function _fanotify_mark_mask_str:string(mask:long) |
| 6096 |
%{ /* pure */ /* unprivileged */ |
| 6097 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) \ |
| 6098 |
&& defined(__NR_fanotify_init) && defined(__NR_fanotify_mark) |
| 6099 |
__u64 mask = (__u64)STAP_ARG_mask; |
| 6100 |
|
| 6101 |
_stp_lookup_or_str(_stp_fanotify_mark_mask_list, mask, |
| 6102 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6103 |
#endif |
| 6104 |
%} |
| 6105 |
|
| 6106 |
%{ |
| 6107 |
#if defined(__NR_perf_event_open) && defined(CONFIG_PERF_EVENTS) |
| 6108 |
#include <linux/perf_event.h> |
| 6109 |
|
| 6110 |
static const _stp_val_array _stp_perf_event_open_flags_list[] = { |
| 6111 |
V(PERF_FLAG_FD_NO_GROUP), |
| 6112 |
V(PERF_FLAG_FD_OUTPUT), |
| 6113 |
#ifdef PERF_FLAG_PID_CGROUP |
| 6114 |
V(PERF_FLAG_PID_CGROUP), |
| 6115 |
#endif |
| 6116 |
#ifdef PERF_FLAG_FD_CLOEXEC |
| 6117 |
V(PERF_FLAG_FD_CLOEXEC), |
| 6118 |
#endif |
| 6119 |
{0, NULL} |
| 6120 |
}; |
| 6121 |
#endif |
| 6122 |
%} |
| 6123 |
|
| 6124 |
function _perf_event_open_flags_str:string(flags:long) |
| 6125 |
%{ /* pure */ /* unprivileged */ |
| 6126 |
#if defined(__NR_perf_event_open) && defined(CONFIG_PERF_EVENTS) |
| 6127 |
unsigned long flags = (unsigned long)STAP_ARG_flags; |
| 6128 |
|
| 6129 |
_stp_lookup_or_str(_stp_perf_event_open_flags_list, flags, |
| 6130 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6131 |
#endif |
| 6132 |
%} |
| 6133 |
|
| 6134 |
%{ |
| 6135 |
#ifdef CONFIG_CHECKPOINT_RESTORE |
| 6136 |
#include <linux/kcmp.h> |
| 6137 |
#endif |
| 6138 |
|
| 6139 |
static const _stp_val_array _stp_kcmp_type_list[] = { |
| 6140 |
#ifdef CONFIG_CHECKPOINT_RESTORE |
| 6141 |
V(KCMP_FILE), |
| 6142 |
V(KCMP_VM), |
| 6143 |
V(KCMP_FILES), |
| 6144 |
V(KCMP_FS), |
| 6145 |
V(KCMP_SIGHAND), |
| 6146 |
V(KCMP_IO), |
| 6147 |
V(KCMP_SYSVSEM), |
| 6148 |
V(KCMP_TYPES), |
| 6149 |
#endif |
| 6150 |
{0, NULL} |
| 6151 |
}; |
| 6152 |
%} |
| 6153 |
|
| 6154 |
function _kcmp_type_str:string(type:long) |
| 6155 |
%{ /* pure */ /* unprivileged */ |
| 6156 |
unsigned long type = (unsigned long)STAP_ARG_type; |
| 6157 |
_stp_lookup_str(_stp_kcmp_type_list, (unsigned int)STAP_ARG_type, |
| 6158 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6159 |
%} |
| 6160 |
|
| 6161 |
function _struct_sched_attr_u:string(uaddr:long) |
| 6162 |
%{ /* pure */ |
| 6163 |
/* struct sched_attr introduced in kernel commit d50dde5a10 along with SCHED_ATTR_SIZE_VER0 */ |
| 6164 |
#ifdef SCHED_ATTR_SIZE_VER0 |
| 6165 |
struct sched_attr sa; |
| 6166 |
char *ptr = (char *)(uintptr_t)STAP_ARG_uaddr; |
| 6167 |
if (ptr == NULL) |
| 6168 |
strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN); |
| 6169 |
else |
| 6170 |
{ |
| 6171 |
if (_stp_copy_from_user((char*)&sa, ptr, |
| 6172 |
sizeof(struct sched_attr)) == 0) |
| 6173 |
{ |
| 6174 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, |
| 6175 |
"{size=%u, sched_policy=%u, sched_flags=%llu, " |
| 6176 |
"sched_nice=%d, sched_priority=%u, sched_runtime=%llu, " |
| 6177 |
"sched_deadline=%llu, sched_period=%llu}", |
| 6178 |
sa.size, sa.sched_policy, sa.sched_flags, sa.sched_nice, |
| 6179 |
sa.sched_priority, sa.sched_runtime, sa.sched_deadline, |
| 6180 |
sa.sched_period); |
| 6181 |
} |
| 6182 |
else |
| 6183 |
{ |
| 6184 |
snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", |
| 6185 |
(unsigned long)ptr); |
| 6186 |
} |
| 6187 |
} |
| 6188 |
#endif |
| 6189 |
%} |
| 6190 |
|
| 6191 |
%{ |
| 6192 |
#ifdef CONFIG_SECCOMP |
| 6193 |
#include <linux/seccomp.h> |
| 6194 |
#endif |
| 6195 |
|
| 6196 |
static const _stp_val_array _stp_seccomp_op_list[] = { |
| 6197 |
#ifdef SECCOMP_SET_MODE_STRICT |
| 6198 |
V(SECCOMP_SET_MODE_STRICT), |
| 6199 |
#endif |
| 6200 |
#ifdef SECCOMP_SET_MODE_FILTER |
| 6201 |
V(SECCOMP_SET_MODE_FILTER), |
| 6202 |
#endif |
| 6203 |
{0, NULL} |
| 6204 |
}; |
| 6205 |
%} |
| 6206 |
|
| 6207 |
function _seccomp_op_str:string(op:long) |
| 6208 |
%{ /* pure */ /* unprivileged */ |
| 6209 |
_stp_lookup_str(_stp_seccomp_op_list, (unsigned int)STAP_ARG_op, |
| 6210 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6211 |
%} |
| 6212 |
|
| 6213 |
%{ |
| 6214 |
#ifdef CONFIG_BPF_SYSCALL |
| 6215 |
#include <uapi/linux/bpf.h> |
| 6216 |
#endif |
| 6217 |
|
| 6218 |
static const _stp_val_array _stp_bpf_cmd_list[] = { |
| 6219 |
#ifdef CONFIG_BPF_SYSCALL |
| 6220 |
V(BPF_MAP_CREATE), |
| 6221 |
V(BPF_MAP_LOOKUP_ELEM), |
| 6222 |
V(BPF_MAP_UPDATE_ELEM), |
| 6223 |
V(BPF_MAP_DELETE_ELEM), |
| 6224 |
V(BPF_MAP_GET_NEXT_KEY), |
| 6225 |
V(BPF_PROG_LOAD), |
| 6226 |
#endif |
| 6227 |
{0, NULL} |
| 6228 |
}; |
| 6229 |
%} |
| 6230 |
|
| 6231 |
function _bpf_cmd_str:string(cmd:long) |
| 6232 |
%{ /* pure */ /* unprivileged */ |
| 6233 |
_stp_lookup_str(_stp_bpf_cmd_list, (int)STAP_ARG_cmd, |
| 6234 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6235 |
%} |
| 6236 |
|
| 6237 |
%{ |
| 6238 |
#ifdef CONFIG_MEMBARRIER |
| 6239 |
#include <linux/membarrier.h> |
| 6240 |
#endif |
| 6241 |
|
| 6242 |
static const _stp_val_array _stp_membarrier_cmd_list[] = { |
| 6243 |
#ifdef CONFIG_MEMBARRIER |
| 6244 |
V(MEMBARRIER_CMD_QUERY), |
| 6245 |
V(MEMBARRIER_CMD_SHARED), |
| 6246 |
#endif |
| 6247 |
{0, NULL} |
| 6248 |
}; |
| 6249 |
%} |
| 6250 |
|
| 6251 |
function _membarrier_cmd_str:string(cmd:long) |
| 6252 |
%{ /* pure */ /* unprivileged */ |
| 6253 |
_stp_lookup_str(_stp_membarrier_cmd_list, (unsigned int)STAP_ARG_cmd, |
| 6254 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6255 |
%} |
| 6256 |
|
| 6257 |
%{ |
| 6258 |
static const _stp_val_array _stp_userfaultfd_flags_list[] = { |
| 6259 |
#ifdef O_NONBLOCK |
| 6260 |
V(O_NONBLOCK), |
| 6261 |
#endif |
| 6262 |
#ifdef O_CLOEXEC |
| 6263 |
V(O_CLOEXEC), |
| 6264 |
#endif |
| 6265 |
{0, NULL} |
| 6266 |
}; |
| 6267 |
%} |
| 6268 |
|
| 6269 |
function _userfaultfd_flags_str:string (f:long) |
| 6270 |
%{ /* pure */ /* unprivileged */ |
| 6271 |
unsigned int flags = (unsigned int)STAP_ARG_f; |
| 6272 |
_stp_lookup_or_str(_stp_userfaultfd_flags_list, flags, STAP_RETVALUE, |
| 6273 |
MAXSTRINGLEN); |
| 6274 |
%} |
| 6275 |
|
| 6276 |
%{ |
| 6277 |
static const _stp_val_array _stp_preadv2_flags_list[] = { |
| 6278 |
#ifdef RWF_HIPRI |
| 6279 |
V(RWF_HIPRI), |
| 6280 |
#endif |
| 6281 |
{0, NULL} |
| 6282 |
}; |
| 6283 |
%} |
| 6284 |
|
| 6285 |
function _preadv2_flags_str:string (f:long) |
| 6286 |
%{ /* pure */ /* unprivileged */ |
| 6287 |
unsigned int flags = (unsigned int)STAP_ARG_f; |
| 6288 |
_stp_lookup_or_str(_stp_preadv2_flags_list, flags, STAP_RETVALUE, |
| 6289 |
MAXSTRINGLEN); |
| 6290 |
%} |
| 6291 |
|
| 6292 |
%{ |
| 6293 |
static const _stp_val_array _stp_statx_mask_list[] = { |
| 6294 |
#ifdef AT_STATX_SYNC_TYPE |
| 6295 |
V(AT_STATX_SYNC_TYPE), |
| 6296 |
V(AT_STATX_SYNC_AS_STAT), |
| 6297 |
V(AT_STATX_FORCE_SYNC), |
| 6298 |
V(AT_STATX_DONT_SYNC), |
| 6299 |
#endif |
| 6300 |
{0, NULL} |
| 6301 |
}; |
| 6302 |
%} |
| 6303 |
|
| 6304 |
function _statx_mask_str:string(cmd:long) |
| 6305 |
%{ /* pure */ /* unprivileged */ |
| 6306 |
_stp_lookup_str(_stp_statx_mask_list, (int)STAP_ARG_cmd, |
| 6307 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6308 |
%} |
| 6309 |
|
| 6310 |
function _pkey_alloc_init_val_str:string(init_val:long) |
| 6311 |
%{ /* pure */ /* unprivileged */ |
| 6312 |
static const _stp_val_array pkey_alloc_init_val_list[] = { |
| 6313 |
V(PKEY_DISABLE_ACCESS), |
| 6314 |
V(PKEY_DISABLE_WRITE), |
| 6315 |
{0, NULL} |
| 6316 |
}; |
| 6317 |
_stp_lookup_or_str(pkey_alloc_init_val_list, (unsigned int)STAP_ARG_init_val, |
| 6318 |
STAP_RETVALUE, MAXSTRINGLEN); |
| 6319 |
%} |
| 6320 |
|
| 6321 |
/* Some syscall interjection mechanisms give us a pt_regs* structure |
| 6322 |
for the syscall parameters/context. */ |
| 6323 |
function __set_syscall_pt_regs(r) |
| 6324 |
%{ /* guru */ |
| 6325 |
CONTEXT->sregs = (void*)(uintptr_t) STAP_ARG_r; |
| 6326 |
%} |
| 6327 |
|
| 6328 |
|
| 6329 |
function _stp_syscall_nr:long () |
| 6330 |
%{ /* pure */ |
| 6331 |
if (CONTEXT->sregs) { |
| 6332 |
/* NB: same abi? */ |
| 6333 |
STAP_RETVALUE = _stp_syscall_get_nr(current, CONTEXT->sregs); |
| 6334 |
} else { |
| 6335 |
struct pt_regs *regs = _stp_current_pt_regs(); |
| 6336 |
if (!regs) { |
| 6337 |
CONTEXT->last_error = ("Cannot access syscall number" |
| 6338 |
" (no registers available)"); |
| 6339 |
return; |
| 6340 |
} |
| 6341 |
STAP_RETVALUE = _stp_syscall_get_nr(current, regs); |
| 6342 |
} |
| 6343 |
%} |