Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL

Assuming that syscalls may return negative values only as error codes,
always print non-error syscall return codes as unsigned.

* defs.h (RVAL_UDECIMAL): Remove.
(RVAL_DECIMAL): Rename to RVAL_UDECIMAL.
* syscall.c (syscall_exiting_trace) <case RVAL_DECIMAL>: Remove.
* clone.c (SYS_FUNC(fork)): Remove RVAL_UDECIMAL.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* uid.c (SYS_FUNC(getuid), SYS_FUNC(setfsuid)): Likewise.
* times.c (SYS_FUNC(times)): Always return 0.
* tests/inject-nf.c (main): Update expected output.
This commit is contained in:
Дмитрий Левин 2018-03-29 16:00:18 +00:00
parent fc56ecefd1
commit 92d7499fbf
8 changed files with 10 additions and 24 deletions

View File

@ -161,5 +161,5 @@ SYS_FUNC(unshare)
SYS_FUNC(fork)
{
return RVAL_DECODED | RVAL_UDECIMAL;
return RVAL_DECODED;
}

3
defs.h
View File

@ -320,10 +320,9 @@ extern const struct xlat tcp_states[];
extern const struct xlat whence_codes[];
/* Format of syscall return values */
#define RVAL_DECIMAL 000 /* decimal format */
#define RVAL_UDECIMAL 000 /* unsigned decimal format */
#define RVAL_HEX 001 /* hex format */
#define RVAL_OCTAL 002 /* octal format */
#define RVAL_UDECIMAL 003 /* unsigned decimal format */
#define RVAL_FD 010 /* file descriptor */
#define RVAL_MASK 013 /* mask for these values */

View File

@ -62,7 +62,7 @@ SYS_FUNC(lseek)
printxval(whence_codes, tcp->u_arg[2], "SEEK_???");
return RVAL_DECODED | RVAL_UDECIMAL;
return RVAL_DECODED;
}
/* llseek syscall takes explicitly two ulong arguments hi, lo,

View File

@ -373,7 +373,7 @@ SYS_FUNC(prctl)
return 0;
tcp->auxstr = xlookup(pr_mce_kill_policy,
(kernel_ulong_t) tcp->u_rval);
return tcp->auxstr ? RVAL_STR : RVAL_UDECIMAL;
return RVAL_STR;
case PR_SET_FP_MODE:
tprints(", ");

View File

@ -935,16 +935,6 @@ syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res)
tprintf("= %" PRI_klu, tcp->u_rval);
}
break;
case RVAL_DECIMAL:
#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
if (current_klongsize < sizeof(tcp->u_rval)) {
tprintf("= %d", (int) tcp->u_rval);
} else
#endif
{
tprintf("= %" PRI_kld, tcp->u_rval);
}
break;
case RVAL_FD:
if (show_fd_path) {
tprints("= ");

View File

@ -76,8 +76,8 @@ main(int ac, char **av)
(unsigned long long) err);
if (ac == 2) {
printf("%s() = %lld (INJECTED)\n",
SC_NAME, sign_extend_unsigned_to_ll(rc));
printf("%s() = %llu (INJECTED)\n",
SC_NAME, (unsigned long long) rc);
puts("+++ exited with 0 +++");
}

View File

@ -42,10 +42,7 @@ SYS_FUNC(times)
{
tms_t tbuf;
if (entering(tcp))
return 0;
if (!umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
if (exiting(tcp) && !umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
tprintf("{tms_utime=%llu, tms_stime=%llu, ",
zero_extend_signed_to_ull(tbuf.tms_utime),
zero_extend_signed_to_ull(tbuf.tms_stime));
@ -54,5 +51,5 @@ SYS_FUNC(times)
zero_extend_signed_to_ull(tbuf.tms_cstime));
}
return syserror(tcp) ? RVAL_DECIMAL : RVAL_UDECIMAL;
return 0;
}

4
uid.c
View File

@ -71,14 +71,14 @@
SYS_FUNC(getuid)
{
return RVAL_UDECIMAL | RVAL_DECODED;
return RVAL_DECODED;
}
SYS_FUNC(setfsuid)
{
printuid("", tcp->u_arg[0]);
return RVAL_UDECIMAL | RVAL_DECODED;
return RVAL_DECODED;
}
SYS_FUNC(setuid)