Lines 6-11
Link Here
|
6 |
|
6 |
|
7 |
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
7 |
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
8 |
|
8 |
|
|
|
9 |
#include <errno.h> |
9 |
#include <fcntl.h> |
10 |
#include <fcntl.h> |
10 |
#include <stddef.h> |
11 |
#include <stddef.h> |
11 |
#include <stdint.h> |
12 |
#include <stdint.h> |
Lines 354-370
intptr_t SIGSYSSchedHandler(const struct
Link Here
|
354 |
} |
355 |
} |
355 |
|
356 |
|
356 |
intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, |
357 |
intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, |
357 |
void* fs_denied_errno) { |
358 |
void* aux) { |
358 |
if (args.nr == __NR_fstatat_default) { |
359 |
switch (args.nr) { |
359 |
if (*reinterpret_cast<const char*>(args.args[1]) == '\0' && |
360 |
#if defined(__NR_newfstatat) |
360 |
args.args[3] == static_cast<uint64_t>(AT_EMPTY_PATH)) { |
361 |
case __NR_newfstatat: |
361 |
return syscall(__NR_fstat_default, static_cast<int>(args.args[0]), |
362 |
#endif |
362 |
reinterpret_cast<default_stat_struct*>(args.args[2])); |
363 |
#if defined(__NR_fstatat64) |
363 |
} |
364 |
case __NR_fstatat64: |
364 |
return -reinterpret_cast<intptr_t>(fs_denied_errno); |
365 |
#endif |
|
|
366 |
#if defined(__NR_newfstatat) || defined(__NR_fstatat64) |
367 |
if (*reinterpret_cast<const char *>(args.args[1]) == '\0' |
368 |
&& args.args[3] == static_cast<uint64_t>(AT_EMPTY_PATH)) { |
369 |
return sandbox::sys_fstat64(static_cast<int>(args.args[0]), |
370 |
reinterpret_cast<struct stat64 *>(args.args[2])); |
371 |
} else { |
372 |
errno = EACCES; |
373 |
return -1; |
374 |
} |
375 |
break; |
376 |
#endif |
365 |
} |
377 |
} |
366 |
|
378 |
|
367 |
CrashSIGSYS_Handler(args, fs_denied_errno); |
379 |
CrashSIGSYS_Handler(args, aux); |
368 |
|
380 |
|
369 |
// Should never be reached. |
381 |
// Should never be reached. |
370 |
RAW_CHECK(false); |
382 |
RAW_CHECK(false); |
Lines 403-411
bpf_dsl::ResultExpr RewriteSchedSIGSYS()
Link Here
|
403 |
return bpf_dsl::Trap(SIGSYSSchedHandler, NULL); |
415 |
return bpf_dsl::Trap(SIGSYSSchedHandler, NULL); |
404 |
} |
416 |
} |
405 |
|
417 |
|
406 |
bpf_dsl::ResultExpr RewriteFstatatSIGSYS(int fs_denied_errno) { |
418 |
bpf_dsl::ResultExpr RewriteFstatatSIGSYS() { |
407 |
return bpf_dsl::Trap(SIGSYSFstatatHandler, |
419 |
return bpf_dsl::Trap(SIGSYSFstatatHandler, NULL); |
408 |
reinterpret_cast<void*>(fs_denied_errno)); |
|
|
409 |
} |
420 |
} |
410 |
|
421 |
|
411 |
void AllocateCrashKeys() { |
422 |
void AllocateCrashKeys() { |