Change scno type from long to unsigned long
Use an unsigned type for syscall numbers as they are not intended for signed arithmetics. Introduce kernel_scno_t as a typedef to unsigned long, that could be changed later to kernel_ulong_t. * kernel_types.h (kernel_scno_t): New type, typedef to unsigned long. * defs.h (struct tcb): Change type of scno field from long to kernel_scno_t. (syscall_name): Change argument type from long to kernel_scno_t. (scno_in_range, scno_is_valid): Change argument type from unsigned long to kernel_scno_t. * linux/aarch64/set_scno.c (arch_set_scno): Change scno argument type from long to kernel_scno_t. * linux/alpha/set_scno.c (arch_set_scno): Likewise. * linux/arc/set_scno.c (arch_set_scno): Likewise. * linux/arm/set_scno.c (arch_set_scno): Likewise. * linux/avr32/set_scno.c (arch_set_scno): Likewise. * linux/bfin/set_scno.c (arch_set_scno): Likewise. * linux/crisv10/set_scno.c (arch_set_scno): Likewise. * linux/hppa/set_scno.c (arch_set_scno): Likewise. * linux/i386/set_scno.c (arch_set_scno): Likewise. * linux/ia64/set_scno.c (arch_set_scno): Likewise. * linux/m68k/set_scno.c (arch_set_scno): Likewise. * linux/metag/set_scno.c (arch_set_scno): Likewise. * linux/microblaze/set_scno.c (arch_set_scno): Likewise. * linux/mips/set_scno.c (arch_set_scno): Likewise. * linux/nios2/set_scno.c (arch_set_scno): Likewise. * linux/or1k/set_scno.c (arch_set_scno): Likewise. * linux/powerpc/set_scno.c (arch_set_scno): Likewise. * linux/riscv/set_scno.c (arch_set_scno): Likewise. * linux/s390/set_scno.c (arch_set_scno): Likewise. * linux/sh/set_scno.c (arch_set_scno): Likewise. * linux/sh64/set_scno.c (arch_set_scno): Likewise. * linux/sparc/set_scno.c (arch_set_scno): Likewise. * linux/tile/set_scno.c (arch_set_scno): Likewise. * linux/x86_64/set_scno.c (arch_set_scno): Likewise. * linux/xtensa/set_scno.c (arch_set_scno): Likewise. * linux/aarch64/get_scno.c (arch_get_scno): Change scno variable type from long to kernel_scno_t. * linux/alpha/get_scno.c (arch_get_scno): Likewise. * linux/arm/get_scno.c (arch_get_scno): Likewise. * linux/sh/get_scno.c (arch_get_scno): Likewise. * linux/x86_64/get_scno.c (arch_get_scno): Likewise. * syscall.c (arch_set_scno): Likewise. (shuffle_scno): Change return type from long to kernel_scno_t. (syscall_name): Change argument type from long to kernel_scno_t.
This commit is contained in:
parent
ae39bba347
commit
0547dc1ad5
8
defs.h
8
defs.h
@ -229,7 +229,7 @@ struct tcb {
|
||||
int pid; /* If 0, this tcb is free */
|
||||
int qual_flg; /* qual_flags[scno] or DEFAULT_QUAL_FLAGS + RAW */
|
||||
unsigned long u_error; /* Error code */
|
||||
long scno; /* System call number */
|
||||
kernel_scno_t scno; /* System call number */
|
||||
long u_arg[MAX_ARGS]; /* System call arguments */
|
||||
#if HAVE_STRUCT_TCB_EXT_ARG
|
||||
long long ext_arg[MAX_ARGS];
|
||||
@ -467,7 +467,7 @@ extern int get_scno(struct tcb *tcp);
|
||||
* @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 *syscall_name(kernel_scno_t scno);
|
||||
extern const char *err_name(unsigned long err);
|
||||
|
||||
extern bool is_erestart(struct tcb *);
|
||||
@ -879,7 +879,7 @@ extern struct fault_opts *fault_vec[SUPPORTED_PERSONALITIES];
|
||||
|
||||
/* Checks that sysent[scno] is not out of range. */
|
||||
static inline bool
|
||||
scno_in_range(unsigned long scno)
|
||||
scno_in_range(kernel_scno_t scno)
|
||||
{
|
||||
return scno < nsyscalls;
|
||||
}
|
||||
@ -890,7 +890,7 @@ scno_in_range(unsigned long scno)
|
||||
* and its sysent[scno].sys_flags has no TRACE_INDIRECT_SUBCALL flag set.
|
||||
*/
|
||||
static inline bool
|
||||
scno_is_valid(unsigned long scno)
|
||||
scno_is_valid(kernel_scno_t scno)
|
||||
{
|
||||
return scno_in_range(scno)
|
||||
&& sysent[scno].sys_func
|
||||
|
@ -47,6 +47,8 @@ typedef unsigned long kernel_ulong_t;
|
||||
|
||||
# endif
|
||||
|
||||
typedef unsigned long kernel_scno_t;
|
||||
|
||||
typedef struct {
|
||||
kernel_ulong_t d_ino;
|
||||
kernel_ulong_t d_off;
|
||||
|
@ -2,7 +2,7 @@
|
||||
static int
|
||||
arch_get_scno(struct tcb *tcp)
|
||||
{
|
||||
long scno = 0;
|
||||
kernel_scno_t scno = 0;
|
||||
|
||||
switch (aarch64_io.iov_len) {
|
||||
case sizeof(aarch64_regs):
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
unsigned int n = (uint16_t) scno;
|
||||
const struct iovec io = {
|
||||
|
@ -2,7 +2,7 @@
|
||||
static int
|
||||
arch_get_scno(struct tcb *tcp)
|
||||
{
|
||||
long scno = 0;
|
||||
kernel_scno_t scno = 0;
|
||||
|
||||
if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
|
||||
return -1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, REG_R0, scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
arc_regs.scratch.r8 = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -31,7 +31,7 @@
|
||||
static int
|
||||
arch_get_scno(struct tcb *tcp)
|
||||
{
|
||||
long scno = 0;
|
||||
kernel_scno_t scno = 0;
|
||||
|
||||
/* Note: we support only 32-bit CPUs, not 26-bit */
|
||||
|
||||
@ -47,7 +47,7 @@ arch_get_scno(struct tcb *tcp)
|
||||
if (errno)
|
||||
return -1;
|
||||
/* EABI syscall convention? */
|
||||
if ((unsigned long) scno != 0xef000000) {
|
||||
if (scno != 0xef000000) {
|
||||
/* No, it's OABI */
|
||||
if ((scno & 0x0ff00000) != 0x0f900000) {
|
||||
error_msg("pid %d unknown syscall trap 0x%08lx",
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
unsigned int n = (uint16_t) scno;
|
||||
int rc = ptrace(PTRACE_SET_SYSCALL, tcp->pid, NULL, (unsigned long) n);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
avr32_regs.r8 = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, PT_ORIG_P0, scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, 4 * PT_R9, scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, PT_GR20, scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
#ifdef HAVE_GETREGS_OLD
|
||||
return upoke(tcp->pid, 4 * ORIG_EAX, scno);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
if (ia64_ia32mode)
|
||||
ia64_regs.gr[0] = scno;
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
m68k_regs.orig_d0 = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
metag_regs.dx[0][1] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, 0, scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
mips_REG_V0 = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
nios2_regs.regs[2] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
or1k_regs.gpr[11] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
#ifdef HAVE_GETREGS_OLD
|
||||
return upoke(tcp->pid, sizeof(long) * PT_R0, scno);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
riscv_regs.a7 = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
s390_regset.gprs[2] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -2,7 +2,7 @@
|
||||
static int
|
||||
arch_get_scno(struct tcb *tcp)
|
||||
{
|
||||
long scno = 0;
|
||||
kernel_scno_t scno = 0;
|
||||
|
||||
/*
|
||||
* In the new syscall ABI, the system call number is in R3.
|
||||
@ -10,11 +10,11 @@ arch_get_scno(struct tcb *tcp)
|
||||
if (upeek(tcp->pid, 4*(REG_REG0+3), &scno) < 0)
|
||||
return -1;
|
||||
|
||||
if (scno < 0) {
|
||||
if ((long) scno < 0) {
|
||||
/* Odd as it may seem, a glibc bug has been known to cause
|
||||
glibc to issue bogus negative syscall numbers. So for
|
||||
our purposes, make strace print what it *should* have been */
|
||||
long correct_scno = (scno & 0xff);
|
||||
kernel_scno_t correct_scno = (scno & 0xff);
|
||||
if (debug_flag)
|
||||
error_msg("Detected glibc bug: bogus system call"
|
||||
" number = %ld, correcting to %ld",
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, 4 * (REG_REG0 + 3), scno);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, REG_SYSCALL, scno);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
sparc_regs.u_regs[U_REG_G1] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
tile_regs.regs[10] = scno;
|
||||
return set_regs(tcp->pid);
|
||||
|
@ -40,7 +40,7 @@
|
||||
static int
|
||||
arch_get_scno(struct tcb *tcp)
|
||||
{
|
||||
long scno = 0;
|
||||
kernel_scno_t scno = 0;
|
||||
unsigned int currpers;
|
||||
|
||||
#ifndef __X32_SYSCALL_BIT
|
||||
|
@ -5,7 +5,7 @@
|
||||
#endif /* !HAVE_GETREGS_OLD */
|
||||
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
#ifdef HAVE_GETREGS_OLD
|
||||
return upoke(tcp->pid, 8 * ORIG_RAX, scno);
|
||||
|
@ -1,5 +1,5 @@
|
||||
static int
|
||||
arch_set_scno(struct tcb *tcp, long scno)
|
||||
arch_set_scno(struct tcb *tcp, kernel_scno_t scno)
|
||||
{
|
||||
return upoke(tcp->pid, SYSCALL_NR, scno);
|
||||
}
|
||||
|
18
syscall.c
18
syscall.c
@ -345,7 +345,7 @@ decode_socket_subcall(struct tcb *tcp)
|
||||
if (call < 1 || call >= SYS_socket_nsubcalls)
|
||||
return;
|
||||
|
||||
const unsigned long scno = SYS_socket_subcall + call;
|
||||
const kernel_scno_t scno = SYS_socket_subcall + call;
|
||||
const unsigned int nargs = sysent[scno].nargs;
|
||||
uint64_t buf[nargs];
|
||||
|
||||
@ -491,10 +491,10 @@ dumpio(struct tcb *tcp)
|
||||
* Shuffle syscall numbers so that we don't have huge gaps in syscall table.
|
||||
* The shuffling should be an involution: shuffle_scno(shuffle_scno(n)) == n.
|
||||
*/
|
||||
#if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
|
||||
static long
|
||||
shuffle_scno(unsigned long scno)
|
||||
static kernel_scno_t
|
||||
shuffle_scno(kernel_scno_t scno)
|
||||
{
|
||||
#if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
|
||||
if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
|
||||
return scno;
|
||||
|
||||
@ -504,7 +504,7 @@ shuffle_scno(unsigned long scno)
|
||||
if (scno == 0x000ffff0)
|
||||
return ARM_FIRST_SHUFFLED_SYSCALL;
|
||||
|
||||
#define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
|
||||
# define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
|
||||
/*
|
||||
* Is it ARM specific syscall?
|
||||
* Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
|
||||
@ -517,12 +517,10 @@ shuffle_scno(unsigned long scno)
|
||||
if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
|
||||
return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
|
||||
}
|
||||
#endif /* ARM || AARCH64 */
|
||||
|
||||
return scno;
|
||||
}
|
||||
#else
|
||||
# define shuffle_scno(scno) ((long)(scno))
|
||||
#endif
|
||||
|
||||
const char *
|
||||
err_name(unsigned long err)
|
||||
@ -544,7 +542,7 @@ clear_regs(void)
|
||||
static int get_syscall_args(struct tcb *);
|
||||
static int get_syscall_result(struct tcb *);
|
||||
static int arch_get_scno(struct tcb *tcp);
|
||||
static int arch_set_scno(struct tcb *, long);
|
||||
static int arch_set_scno(struct tcb *, kernel_scno_t);
|
||||
static void get_error(struct tcb *, const bool);
|
||||
static int arch_set_error(struct tcb *);
|
||||
|
||||
@ -1272,7 +1270,7 @@ get_syscall_result(struct tcb *tcp)
|
||||
#endif
|
||||
|
||||
const char *
|
||||
syscall_name(long scno)
|
||||
syscall_name(kernel_scno_t scno)
|
||||
{
|
||||
#if defined X32_PERSONALITY_NUMBER && defined __X32_SYSCALL_BIT
|
||||
if (current_personality == X32_PERSONALITY_NUMBER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user