1999-02-19 00:21:36 +00:00
/*
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 Rick Sladkey < jrs @ world . std . com >
2018-06-14 11:00:00 +00:00
* Copyright ( c ) 1995 - 2018 The strace developers .
1999-02-19 00:21:36 +00:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
2016-08-05 15:06:43 +00:00
# ifndef STRACE_LINUX_DUMMY_H
# define STRACE_LINUX_DUMMY_H
2013-05-01 15:56:22 +00:00
# ifndef HAVE_STRUCT___OLD_KERNEL_STAT
# define sys_oldfstat printargs
# define sys_oldstat printargs
# endif
1999-02-19 00:21:36 +00:00
/* still unfinished */
2018-06-13 23:51:31 +00:00
# define sys_rseq printargs
2012-03-11 15:43:04 +00:00
# define sys_vm86 printargs
Wire up new syscalls
* linux/dummy.h (sys_bpf, sys_execveat, sys_getrandom,
sys_kexec_file_load, sys_memfd_create, sys_seccomp): New stub aliases.
* linux/32/syscallent.h (seccomp, getrandom, memfd_create, bpf,
execveat): New entries.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/ia64/syscallent.h (getrandom, memfd_create, bpf, execveat):
New entries.
* linux/m68k/syscallent.h: Likewise.
* linux/s390/syscallent.h: (seccomp, getrandom, memfd_create, bpf,
s390_pci_mmio_write, s390_pci_mmio_read, execveat): New entries.
* linux/s390x/syscallent.h: Likewise.
* linux/x86_64/syscallent.h (seccomp, getrandom, memfd_create,
kexec_file_load, bpf, execveat): New entries.
* linux/x32/syscallent.h: Likewise.
* linux/xtensa/syscallent.h (seccomp, getrandom, memfd_create):
New entries.
2015-01-12 18:53:32 +00:00
# define sys_vm86old printargs
1999-02-19 00:21:36 +00:00
2002-12-15 23:58:21 +00:00
/* machine-specific */
2016-12-21 18:01:21 +00:00
# ifndef HAVE_STRUCT_USER_DESC
2014-04-09 12:46:05 +00:00
# define sys_modify_ldt printargs
2010-05-28 22:28:51 +02:00
# endif
2016-12-21 18:01:21 +00:00
# if !(defined HAVE_STRUCT_USER_DESC || defined M68K || defined MIPS)
# define sys_set_thread_area printargs
# endif
# if !(defined HAVE_STRUCT_USER_DESC || defined M68K)
# define sys_get_thread_area printargs
# endif
2016-01-08 18:52:05 +00:00
# ifdef ALPHA
# define sys_getdtablesize printargs
# endif
2002-12-15 23:58:21 +00:00
1999-02-19 00:21:36 +00:00
/* like another call */
2011-10-12 16:40:17 +00:00
# define sys_acct sys_chdir
Remove redundant parsers
* desc.c (sys_dup): Remove.
* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
sys_unlink, sys_symlink, sys_rename): Remove.
* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* pathtrace.c (pathtrace_match): Update.
* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* svr4/dummy.h: Likewise.
* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
2011-11-28 22:48:53 +00:00
# define sys_chroot sys_chdir
2015-07-19 22:55:56 +00:00
# define sys_connect sys_bind
1999-02-19 00:21:36 +00:00
# define sys_fchdir sys_close
2011-10-12 16:40:17 +00:00
# define sys_fdatasync sys_close
2012-03-11 15:28:03 +00:00
# define sys_fsync sys_close
Decode UID/GID in -y mode
* defs.h (RVAL_UID, RVAL_GID): New macro constants.
(printgid): New function declaration.
* ipc_msgctl.c (print_msqid_ds, print_msqid_ds): Use printgid for
printing GID.
* ipc_shmctl.c (print_shmid_ds, print_shmid_ds): Likewise.
* keyctl.c (keyctl_chown_key): Likewise.
* nlattr.c (decode_nla_gid): Likewise.
* linux/dummy.h (sys_getgid, sys_getgid16, sys_getresgid,
sys_getresgid16, sys_setfsgid, sys_setfsgid16, sys_setgid, sys_setgid16,
sys_setregid, sys_setregid16, sys_setresgid, sys_setresgid16): Remove
macros.
(sys_getegid): Define to sys_getgid instead of sys_getuid.
(sys_getegid16): Define to sys_getgid16 instead of sys_geteuid16.
* linux/syscall.h (getresgid16, getgid16, setfsgid16, setresgid16,
setregid16, setgid16): New external SYS_FUNC declarations.
* msghdr.c (print_scm_creds); Use PRINT_FIELD_GID for printing GID.
* net.c (print_get_ucred): Likewise.
* netlink_inet_diag.c (decode_inet_diag_msg): Likewise.
* netlink_smc_diag.c (decode_smc_diag_msg): Likewise.
* print_fields.h (PRINT_FIELD_UID); Use printuid for printing UID.
(PRINT_FIELD_GID): New macro.
* print_struct_stat.c (print_struct_stat): Use printuid for printing
UID, printgid for printing GID.
* printsiginfo.c (printsigsource): Use printuid for printing UID.
* resource.c (print_priority_who): New function.
(SYS_FUNC(getpriority), SYS_FUNC(setpriority)): Use print_priority_who
for printing the second argument.
* statx.c (SYS_FUNC(statx)): Use PRINT_FIELD_UID for printing UID,
PRINT_FIELD_GID for printing GID.
* syscall.c (syscall_exiting_trace): Handle RVAL_UID and RVAL_GID.
* tests/overflowuid.c: Include stdio.h.
(printuid): New function.
* tests/setfsugid.c (printugid): Rename from printuid, update call
sites.
* tests/setgroups.c: Likewise.
* tests/setugid.c: Likewise.
* tests/tests.h (printuid): New declaration.
* uid.c (printgid, sys_getresgid, sys_getgid, sys_setfsgid,
sys_setresgid, sys_setregid, sys_setgid): Add SIZEIFY wrappers.
(gid_t, gid_t_, gid_t__): Define similarly to uid_t, uid_t_, uid_t__.
Include grp.h, pwd.h, sys/types.h.
(enum id_type): New enumeration.
(SYS_FUNC(getuid), SYS_FUNC(setfsuid), ): Return RVAL_UID flag.
(SYS_FUNC(getgid), SYS_FUNC(setfsgid), SYS_FUNC(setgid),
SYS_FUNC(getresgid), SYS_FUNC(setregid), SYS_FUNC(setresgid)): New
functions.
(get_print_id): Rename from get_print_uid, add idt argument, call
printuid or printgid depending on it. Update call sites.
(SYS_FUNC(chown), SYS_FUNC(fchown), print_gid): Use printgid
for printing GID.
(ID_CACHE_SIZE): New macro constant.
(print_id): New function.
(printuid): Implement using print_id.
(printgid): New function.
* xlat/priorities.in: Provide fallback values.
2018-10-26 02:18:41 +02:00
# define sys_getegid sys_getgid
# define sys_getegid16 sys_getgid16
2012-03-11 15:43:04 +00:00
# define sys_geteuid sys_getuid
Fix decoding of 16-bit *chown and [gs]et*[gu]id syscalls
Define two sets of parsers on architectures that support (either
directly or via multiarch) 16-bit and 32-bit uid/gid syscalls
simultaneously. Since the code in these two sets is essentially
the same and the key difference between them is the size of uid_t,
implement it by parametrizing uid_t and names of parser functions.
* defs.h (NEED_UID16_PARSERS): New macro.
* linux/syscall.h [NEED_UID16_PARSERS] (sys_chown16, sys_fchown16,
sys_getresuid16, sys_getuid16, sys_setfsuid16, sys_setresuid16,
sys_setreuid16, sys_setuid16): New prototypes.
* linux/dummy.h (sys_geteuid16): Alias to sys_getuid16.
(sys_getegid16, sys_getgid16, sys_getresgid16, sys_setfsgid16,
sys_setgid16, sys_setregid16, sys_setresgid16): Alias to corresponding
sys_*uid16 functions.
* uid.c: Stop including <asm/posix_types.h>.
Parametrize uid_t and names of all exported functions.
(get_print_uid): New function.
(sys_getresuid): Use it.
(printuid): Check for (uid_t) -1.
* uid16.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/arm/syscallent.h: Use sys_chown16, sys_fchown16, sys_getegid16,
sys_geteuid16, sys_getgid16, sys_getresgid16, sys_getresuid16,
sys_getuid16, sys_setfsgid16, sys_setfsuid16, sys_setgid16,
sys_setregid16, sys_setresgid16, sys_setresuid16, sys_setreuid16,
and sys_setuid16 parsers for *chown and [gs]et*[gu]id syscall entries.
* linux/bfin/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* tests/uid16.c: New file.
* tests/uid16.test: New test.
* tests/Makefile.am (CHECK_PROGRAMS): Add uid16.
(TESTS): Add uid16.test.
* tests/.gitignore: Add uid16.
2014-12-13 21:49:01 +00:00
# define sys_geteuid16 sys_getuid16
2014-12-02 21:36:04 +00:00
# define sys_getpeername sys_getsockname
2013-05-01 15:56:22 +00:00
# define sys_lstat sys_stat
# define sys_lstat64 sys_stat64
2014-12-01 18:24:55 +00:00
# define sys_mkdir sys_chmod
# define sys_mkdirat sys_fchmodat
2011-10-12 16:40:17 +00:00
# define sys_mlock sys_munmap
Remove redundant parsers
* desc.c (sys_dup): Remove.
* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
sys_unlink, sys_symlink, sys_rename): Remove.
* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* pathtrace.c (pathtrace_match): Update.
* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* svr4/dummy.h: Likewise.
* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
2011-11-28 22:48:53 +00:00
# define sys_mq_unlink sys_chdir
2011-10-12 16:40:17 +00:00
# define sys_munlock sys_munmap
2013-05-01 15:56:22 +00:00
# define sys_oldlstat sys_oldstat
Remove redundant parsers
* desc.c (sys_dup): Remove.
* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
sys_unlink, sys_symlink, sys_rename): Remove.
* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* pathtrace.c (pathtrace_match): Update.
* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* svr4/dummy.h: Likewise.
* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
2011-11-28 22:48:53 +00:00
# define sys_pivotroot sys_link
# define sys_rename sys_link
# define sys_rmdir sys_chdir
2012-02-28 16:39:44 +01:00
# define sys_sched_get_priority_max sys_sched_get_priority_min
2014-12-02 21:42:34 +00:00
# define sys_setdomainname sys_sethostname
2011-10-12 16:40:17 +00:00
# define sys_swapoff sys_chdir
Remove redundant parsers
* desc.c (sys_dup): Remove.
* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
sys_unlink, sys_symlink, sys_rename): Remove.
* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* pathtrace.c (pathtrace_match): Update.
* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* svr4/dummy.h: Likewise.
* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
2011-11-28 22:48:53 +00:00
# define sys_symlink sys_link
Add syscall entries for new linux syscalls
* linux/dummy.h: Add printargs parsers for new syscalls.
* linux/arm/syscallent.h: Add entries for sys_clock_adjtime,
sys_name_to_handle_at, sys_open_by_handle_at, sys_sendmmsg, sys_setns
and sys_syncfs.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Add entries for sys_clock_adjtime,
sys_name_to_handle_at, sys_open_by_handle_at, sys_setns and sys_syncfs.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Add entry for sys_setns.
* linux/bfin/syscallent.h: Add entries for sys_sendmmsg and sys_setns.
* linux/hppa/syscallent.h: Add entries for sys_clock_adjtime,
fanotify_init, fanotify_mark, sys_name_to_handle_at,
sys_open_by_handle_at, sys_sendmmsg, sys_setns and sys_syncfs.
2011-11-26 23:37:23 +00:00
# define sys_syncfs sys_close
2011-10-12 16:40:17 +00:00
# define sys_umount sys_chdir
Remove redundant parsers
* desc.c (sys_dup): Remove.
* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
sys_unlink, sys_symlink, sys_rename): Remove.
* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* pathtrace.c (pathtrace_match): Update.
* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
* svr4/dummy.h: Likewise.
* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
2011-11-28 22:48:53 +00:00
# define sys_unlink sys_chdir
2011-10-12 16:40:17 +00:00
# define sys_uselib sys_chdir
2014-05-12 13:43:10 +00:00
# define sys_vfork sys_fork
1999-02-19 00:21:36 +00:00
/* printargs does the right thing */
2016-02-14 16:26:37 +00:00
# define sys_getpgrp printargs
1999-02-19 00:21:36 +00:00
# define sys_getpid printargs
# define sys_getppid printargs
2011-10-12 19:03:29 +00:00
# define sys_gettid printargs
2011-10-12 16:40:17 +00:00
# define sys_idle printargs
# define sys_munlockall printargs
# define sys_pause printargs
2015-07-10 22:24:48 +03:00
# define sys_printargs printargs
2011-10-12 16:40:17 +00:00
# define sys_sched_yield printargs
2012-03-11 15:43:04 +00:00
# define sys_setsid printargs
2011-10-12 19:03:29 +00:00
# define sys_set_tid_address printargs
2012-03-11 15:43:04 +00:00
# define sys_setup printargs
2011-10-12 16:40:17 +00:00
# define sys_sync printargs
2016-01-13 20:47:52 +00:00
# define sys_syscall printargs
1999-02-19 00:21:36 +00:00
# define sys_vhangup printargs
2016-02-14 16:26:37 +00:00
/* printargs_u does the right thing */
# define sys_alarm printargs_u
/* printargs_d does the right thing */
2016-11-26 23:45:05 +00:00
# define sys_exit printargs_d
2016-02-14 16:26:37 +00:00
# define sys_getpgid printargs_d
# define sys_getsid printargs_d
# define sys_nice printargs_d
# define sys_setpgid printargs_d
# define sys_setpgrp printargs_d
# define sys_timer_delete printargs_d
# define sys_timer_getoverrun printargs_d
2012-02-27 14:18:02 +01:00
1999-02-19 00:21:36 +00:00
/* unimplemented */
2011-10-12 16:40:17 +00:00
# define sys_afs_syscall printargs
# define sys_break printargs
2016-10-16 14:42:32 +03:00
# define sys_create_module printargs
1999-02-19 00:21:36 +00:00
# define sys_ftime printargs
2011-10-12 16:40:17 +00:00
# define sys_get_kernel_syms printargs
2015-11-24 02:39:01 +00:00
# define sys_getpmsg printargs
2011-10-12 16:40:17 +00:00
# define sys_gtty printargs
1999-02-19 00:21:36 +00:00
# define sys_lock printargs
# define sys_mpx printargs
2011-11-28 15:53:20 +00:00
# define sys_nfsservctl printargs
2011-10-12 16:40:17 +00:00
# define sys_prof printargs
2015-11-24 02:39:01 +00:00
# define sys_profil printargs
# define sys_putpmsg printargs
2015-11-24 02:30:45 +00:00
# define sys_query_module printargs
2011-10-12 19:03:29 +00:00
# define sys_security printargs
2011-10-12 16:40:17 +00:00
# define sys_stty printargs
2016-04-20 17:15:05 +00:00
# define sys_timerfd printargs
2011-10-12 19:03:29 +00:00
# define sys_tuxcall printargs
2011-10-12 16:40:17 +00:00
# define sys_ulimit printargs
2011-10-12 19:03:29 +00:00
# define sys_vserver printargs
1999-02-19 00:21:36 +00:00
/* deprecated */
2011-10-12 16:40:17 +00:00
# define sys_bdflush printargs
2016-08-05 15:06:43 +00:00
# endif /* !STRACE_LINUX_DUMMY_H */