Print syscall names only for defined syscalls
The string literal "__NR_syscall_4294967295" is semantically incorrect as there is no such constant defined. * syscall.c (syscall_name): Return NULL if there is no syscall corresponding to the given number. * defs.h (syscall_name): Document this behaviour. * printsiginfo.c (print_si_info): Print syscall name with "__NR_" prefix only if there is a syscall corresponding to si_syscall number; print a plain syscall number otherwise. * tests/ptrace.c (main): Update expected output.
This commit is contained in:
parent
2432f78415
commit
9936b91d9f
7
defs.h
7
defs.h
@ -457,6 +457,13 @@ extern void call_summary(FILE *);
|
||||
extern void clear_regs(void);
|
||||
extern void get_regs(pid_t pid);
|
||||
extern int get_scno(struct tcb *tcp);
|
||||
/**
|
||||
* Convert syscall number to syscall name.
|
||||
*
|
||||
* @param scno Syscall number.
|
||||
* @return String literal corresponding to the syscall number in case latter
|
||||
* is valid; NULL otherwise.
|
||||
*/
|
||||
extern const char *syscall_name(long scno);
|
||||
extern const char *err_name(unsigned long err);
|
||||
|
||||
|
@ -189,13 +189,21 @@ print_si_info(const siginfo_t *sip)
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_SIGINFO_T_SI_SYSCALL
|
||||
case SIGSYS:
|
||||
case SIGSYS: {
|
||||
const char *scname =
|
||||
syscall_name((unsigned) sip->si_syscall);
|
||||
|
||||
tprints(", si_call_addr=");
|
||||
printaddr((unsigned long) sip->si_call_addr);
|
||||
tprintf(", si_syscall=__NR_%s, si_arch=",
|
||||
syscall_name((unsigned) sip->si_syscall));
|
||||
tprints(", si_syscall=");
|
||||
if (scname)
|
||||
tprintf("__NR_%s", scname);
|
||||
else
|
||||
tprintf("%u", (unsigned) sip->si_syscall);
|
||||
tprints(", si_arch=");
|
||||
printxval(audit_arch, sip->si_arch, "AUDIT_ARCH_???");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (sip->si_pid || sip->si_uid)
|
||||
|
@ -990,14 +990,7 @@ shuffle_scno(unsigned long scno)
|
||||
const char *
|
||||
syscall_name(long scno)
|
||||
{
|
||||
static char buf[sizeof("syscall_%lu") + sizeof(long)*3];
|
||||
|
||||
if (SCNO_IS_VALID(scno))
|
||||
return sysent[scno].sys_name;
|
||||
else {
|
||||
sprintf(buf, "syscall_%lu", scno);
|
||||
return buf;
|
||||
}
|
||||
return SCNO_IS_VALID(scno) ? sysent[scno].sys_name: NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -345,7 +345,7 @@ main(void)
|
||||
do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (unsigned long) sip);
|
||||
printf("ptrace(PTRACE_SETSIGINFO, %u, %#lx, {si_signo=SIGSYS"
|
||||
", si_code=SYS_SECCOMP, si_errno=ENOENT, si_call_addr=%p"
|
||||
", si_syscall=__NR_syscall_%u, si_arch=AUDIT_ARCH_X86_64})"
|
||||
", si_syscall=%u, si_arch=AUDIT_ARCH_X86_64})"
|
||||
" = %s\n",
|
||||
(unsigned) pid, bad_request, sip->si_call_addr, sip->si_syscall,
|
||||
errstr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user