2011-04-08 00:25:40 +04:00
/*
* Copyright ( c ) 2011 , Comtrol Corp .
* 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 .
*
*/
# include "defs.h"
2011-08-30 20:05:26 +04:00
# include <sys/param.h>
2013-11-06 05:17:05 +04:00
# if defined HAVE_POLL_H
2012-03-16 15:02:22 +04:00
# include <poll.h>
2013-11-06 05:17:05 +04:00
# elif defined HAVE_SYS_POLL_H
2012-03-16 15:02:22 +04:00
# include <sys / poll.h>
2011-04-08 00:25:40 +04:00
# endif
# include "syscall.h"
2013-03-05 19:01:53 +04:00
const char * * paths_selected = NULL ;
2013-03-05 18:46:34 +04:00
static unsigned num_selected = 0 ;
2011-04-08 00:25:40 +04:00
/*
* Return true if specified path matches one that we ' re tracing .
*/
static int
pathmatch ( const char * path )
{
2013-03-05 18:46:34 +04:00
unsigned i ;
2011-04-08 00:25:40 +04:00
2013-03-05 18:46:34 +04:00
for ( i = 0 ; i < num_selected ; + + i ) {
2013-03-05 19:01:53 +04:00
if ( strcmp ( path , paths_selected [ i ] ) = = 0 )
2011-04-08 00:25:40 +04:00
return 1 ;
}
return 0 ;
}
/*
* Return true if specified path ( in user - space ) matches .
*/
static int
upathmatch ( struct tcb * tcp , unsigned long upath )
{
2011-06-22 16:32:43 +04:00
char path [ PATH_MAX + 1 ] ;
2011-04-08 00:25:40 +04:00
2013-02-26 23:23:27 +04:00
return umovestr ( tcp , upath , sizeof path , path ) > 0 & &
2011-04-08 00:25:40 +04:00
pathmatch ( path ) ;
}
/*
* Return true if specified fd maps to a path we ' re tracing .
*/
static int
fdmatch ( struct tcb * tcp , int fd )
{
2013-03-06 21:24:34 +04:00
char path [ PATH_MAX + 1 ] ;
int n = getfdpath ( tcp , fd , path , sizeof ( path ) ) ;
2011-04-08 00:25:40 +04:00
2013-03-06 21:24:34 +04:00
return n > = 0 & & pathmatch ( path ) ;
2011-04-08 00:25:40 +04:00
}
/*
* Add a path to the set we ' re tracing .
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-01 21:57:45 +04:00
* Specifying NULL will delete all paths .
2011-04-08 00:25:40 +04:00
*/
2013-03-05 18:46:34 +04:00
static void
2011-04-08 00:25:40 +04:00
storepath ( const char * path )
{
2013-03-05 18:46:34 +04:00
unsigned i ;
2011-04-08 00:25:40 +04:00
2013-03-05 18:46:34 +04:00
if ( pathmatch ( path ) )
return ; /* already in table */
2011-04-08 00:25:40 +04:00
2013-03-05 18:46:34 +04:00
i = num_selected + + ;
2013-03-05 19:01:53 +04:00
paths_selected = realloc ( paths_selected , num_selected * sizeof ( paths_selected [ 0 ] ) ) ;
if ( ! paths_selected )
2013-03-05 18:46:34 +04:00
die_out_of_memory ( ) ;
2013-03-05 19:01:53 +04:00
paths_selected [ i ] = path ;
2011-04-08 00:25:40 +04:00
}
/*
* Get path associated with fd .
*/
2013-03-06 21:24:34 +04:00
int
getfdpath ( struct tcb * tcp , int fd , char * buf , unsigned bufsize )
2011-04-08 00:25:40 +04:00
{
2012-03-15 21:11:51 +04:00
char linkpath [ sizeof ( " /proc/%u/fd/%u " ) + 2 * sizeof ( int ) * 3 ] ;
2011-04-08 00:25:40 +04:00
ssize_t n ;
if ( fd < 0 )
2013-03-06 21:24:34 +04:00
return - 1 ;
2011-04-08 00:25:40 +04:00
2012-03-15 21:03:56 +04:00
sprintf ( linkpath , " /proc/%u/fd/%u " , tcp - > pid , fd ) ;
2013-03-06 21:24:34 +04:00
n = readlink ( linkpath , buf , bufsize - 1 ) ;
/*
* NB : if buf is too small , readlink doesn ' t fail ,
* it returns truncated result ( IOW : n = = bufsize - 1 ) .
*/
if ( n > = 0 )
buf [ n ] = ' \0 ' ;
return n ;
2011-04-08 00:25:40 +04:00
}
/*
* Add a path to the set we ' re tracing . Also add the canonicalized
* version of the path . Secifying NULL will delete all paths .
*/
2013-03-05 18:46:34 +04:00
void
2011-04-08 00:25:40 +04:00
pathtrace_select ( const char * path )
{
2012-03-15 21:03:56 +04:00
char * rpath ;
2011-04-08 00:25:40 +04:00
2013-03-05 18:46:34 +04:00
storepath ( path ) ;
2011-04-08 00:25:40 +04:00
rpath = realpath ( path , NULL ) ;
if ( rpath = = NULL )
2013-03-05 18:46:34 +04:00
return ;
2011-04-08 00:25:40 +04:00
/* if realpath and specified path are same, we're done */
2012-03-15 21:03:56 +04:00
if ( strcmp ( path , rpath ) = = 0 ) {
2011-04-08 00:25:40 +04:00
free ( rpath ) ;
2013-03-05 18:46:34 +04:00
return ;
2011-04-08 00:25:40 +04:00
}
fprintf ( stderr , " Requested path '%s' resolved into '%s' \n " ,
path , rpath ) ;
2013-03-05 18:46:34 +04:00
storepath ( rpath ) ;
2011-04-08 00:25:40 +04:00
}
/*
* Return true if syscall accesses a selected path
* ( or if no paths have been specified for tracing ) .
*/
int
pathtrace_match ( struct tcb * tcp )
{
2013-02-22 16:26:10 +04:00
const struct_sysent * s ;
2011-04-08 00:25:40 +04:00
2013-02-21 19:13:47 +04:00
s = tcp - > s_ent ;
2011-04-08 00:25:40 +04:00
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-01 21:57:45 +04:00
if ( ! ( s - > sys_flags & ( TRACE_FILE | TRACE_DESC | TRACE_NETWORK ) ) )
2011-04-08 00:25:40 +04:00
return 0 ;
/*
* Check for special cases where we need to do something
* other than test arg [ 0 ] .
*/
if ( s - > sys_func = = sys_dup2 | |
s - > sys_func = = sys_dup3 | |
s - > sys_func = = sys_sendfile | |
s - > sys_func = = sys_sendfile64 | |
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-29 02:48:53 +04:00
s - > sys_func = = sys_tee )
2011-04-08 00:25:40 +04:00
{
/* fd, fd */
return fdmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
fdmatch ( tcp , tcp - > u_arg [ 1 ] ) ;
}
if ( s - > sys_func = = sys_inotify_add_watch | |
s - > sys_func = = sys_faccessat | |
s - > sys_func = = sys_fchmodat | |
s - > sys_func = = sys_futimesat | |
s - > sys_func = = sys_unlinkat | |
s - > sys_func = = sys_newfstatat | |
s - > sys_func = = sys_mknodat | |
s - > sys_func = = sys_openat | |
s - > sys_func = = sys_readlinkat | |
s - > sys_func = = sys_utimensat | |
s - > sys_func = = sys_fchownat | |
2011-06-07 14:13:24 +04:00
s - > sys_func = = sys_pipe2 )
2011-04-08 00:25:40 +04:00
{
/* fd, path */
return fdmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] ) ;
}
if ( s - > sys_func = = sys_link | |
2011-06-07 14:13:24 +04:00
s - > sys_func = = sys_mount )
2011-04-08 00:25:40 +04:00
{
/* path, path */
return upathmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] ) ;
}
2012-10-27 03:43:13 +04:00
if ( s - > sys_func = = sys_quotactl )
{
/* x, path */
return upathmatch ( tcp , tcp - > u_arg [ 1 ] ) ;
}
2011-04-08 00:25:40 +04:00
if ( s - > sys_func = = sys_renameat | |
2014-08-14 12:05:41 +04:00
s - > sys_func = = sys_renameat2 | |
2011-06-07 14:13:24 +04:00
s - > sys_func = = sys_linkat )
2011-04-08 00:25:40 +04:00
{
/* fd, path, fd, path */
return fdmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
fdmatch ( tcp , tcp - > u_arg [ 2 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 3 ] ) ;
}
Add x32 support to strace
X32 support is added to Linux kernel 3.4. In a nutshell, x32 is x86-64 with
32bit pointers. At system call level, x32 is also identical to x86-64,
as shown by many changes like "defined(X86_64) || defined(X32)". The
main differerence bewteen x32 and x86-64 is off_t in x32 is long long
instead of long.
This patch adds x32 support to strace. Tested on Linux/x32.
* configure.ac: Support X32.
* defs.h: Set SUPPORTED_PERSONALITIES to 3 for X86_64,
Set PERSONALITY2_WORDSIZE to 4 for X86_64.
Add tcb::ext_arg for X32.
* file.c (stat): New for X32.
(sys_lseek): Use 64-bit version for X32.
(printstat64): Check current_personality != 1 for X86_64.
* ipc.c (indirect_ipccall): Check current_personality == 1
for X86_64.
* mem.c (sys_mmap64): Also use tcp->u_arg for X32. Print NULL
for zero address. Call printllval for offset for X32.
* pathtrace.c (pathtrace_match): Don't check sys_old_mmap for
X32.
* process.c (ARG_FLAGS): Defined for X32.
(ARG_STACK): Likewise.
(ARG_PTID): Likewise.
(change_syscall): Handle X32.
(struct_user_offsets): Support X32.
(sys_arch_prctl): Likewise.
* signal.c: Include <asm/sigcontext.h> for X32.
(SA_RESTORER): Also define for X32.
* syscall.c (update_personality): Support X32 for X86_64.
(is_restart_error): Likewise.
(syscall_fixup_on_sysenter): Likewise.
(get_syscall_args): Likewise.
(get_syscall_result): Likewise.
(get_error): Likewise.
(__X32_SYSCALL_BIT): Define if not defined.
(__X32_SYSCALL_MASK): Likewise.
(get_scno): Check DS register value for X32. Use
__X32_SYSCALL_MASK on X32 system calls.
* util.c (printllval): Use ext_arg for X32.
(printcall): Support X32.
(change_syscall): Likewise.
(arg0_offset): Likewise.
(arg1_offset): Likewise.
* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent.h,
linux/x32/ioctlent.h.in, linux/x32/signalent.h,
linux/x32/syscallent.h, linux/x86_64/errnoent2.h,
linux/x86_64/ioctlent2.h, linux/x86_64/signalent2.h and
linux/x86_64/syscallent2.h.
* linux/x32/errnoent.h: New.
* linux/x32/ioctlent.h.in: Likewise.
* linux/x32/signalent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/errnoent2.h: Likewise.
* linux/x86_64/ioctlent2.h: Likewise.
* linux/x86_64/signalent2.h: Likewise.
* linux/x86_64/syscallent2.h: Likewise.
Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-16 15:00:01 +04:00
if (
s - > sys_func = = sys_old_mmap | |
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
# if defined(S390)
s - > sys_func = = sys_old_mmap_pgoff | |
# endif
s - > sys_func = = sys_mmap | |
s - > sys_func = = sys_mmap_pgoff | |
s - > sys_func = = sys_mmap_4koff
) {
2011-04-08 00:25:40 +04:00
/* x, x, x, x, fd */
return fdmatch ( tcp , tcp - > u_arg [ 4 ] ) ;
}
2011-06-22 16:32:43 +04:00
if ( s - > sys_func = = sys_symlinkat ) {
2011-04-08 00:25:40 +04:00
/* path, fd, path */
return fdmatch ( tcp , tcp - > u_arg [ 1 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
2011-06-07 14:13:24 +04:00
upathmatch ( tcp , tcp - > u_arg [ 2 ] ) ;
2011-04-08 00:25:40 +04:00
}
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-29 02:48:53 +04:00
if ( s - > sys_func = = sys_splice ) {
2011-04-08 00:25:40 +04:00
/* fd, x, fd, x, x */
return fdmatch ( tcp , tcp - > u_arg [ 0 ] ) | |
fdmatch ( tcp , tcp - > u_arg [ 2 ] ) ;
}
2011-06-22 16:32:43 +04:00
if ( s - > sys_func = = sys_epoll_ctl ) {
2011-04-08 00:25:40 +04:00
/* x, x, fd, x */
return fdmatch ( tcp , tcp - > u_arg [ 2 ] ) ;
}
2014-02-05 08:13:18 +04:00
if ( s - > sys_func = = sys_fanotify_mark ) {
/* x, x, x, fd, path */
return fdmatch ( tcp , tcp - > u_arg [ 3 ] ) | |
upathmatch ( tcp , tcp - > u_arg [ 4 ] ) ;
}
2011-04-08 00:25:40 +04:00
if ( s - > sys_func = = sys_select | |
s - > sys_func = = sys_oldselect | |
2011-06-07 14:13:24 +04:00
s - > sys_func = = sys_pselect6 )
2011-04-08 00:25:40 +04:00
{
2011-09-01 18:35:44 +04:00
int i , j ;
2013-11-09 23:46:55 +04:00
int nfds ;
2011-04-08 00:25:40 +04:00
long * args , oldargs [ 5 ] ;
unsigned fdsize ;
fd_set * fds ;
2013-11-09 23:46:55 +04:00
args = tcp - > u_arg ;
2011-06-22 16:32:43 +04:00
if ( s - > sys_func = = sys_oldselect ) {
2011-04-08 00:25:40 +04:00
if ( umoven ( tcp , tcp - > u_arg [ 0 ] , sizeof oldargs ,
( char * ) oldargs ) < 0 )
{
fprintf ( stderr , " umoven() failed \n " ) ;
return 0 ;
}
args = oldargs ;
2013-11-09 23:46:55 +04:00
}
2011-04-08 00:25:40 +04:00
2013-11-09 23:46:55 +04:00
/* Kernel truncates arg[0] to int, we do the same. */
nfds = ( int ) args [ 0 ] ;
/* Kernel rejects negative nfds, so we don't parse it either. */
if ( nfds < = 0 )
return 0 ;
2011-09-01 18:35:44 +04:00
/* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */
2013-11-09 23:46:55 +04:00
if ( nfds > 1024 * 1024 )
2011-09-01 18:35:44 +04:00
nfds = 1024 * 1024 ;
2013-11-09 23:46:55 +04:00
fdsize = ( ( ( nfds + 7 ) / 8 ) + current_wordsize - 1 ) & - current_wordsize ;
2011-04-08 00:25:40 +04:00
fds = malloc ( fdsize ) ;
2011-08-31 16:00:02 +04:00
if ( ! fds )
die_out_of_memory ( ) ;
2011-04-08 00:25:40 +04:00
2011-06-22 16:32:43 +04:00
for ( i = 1 ; i < = 3 ; + + i ) {
2011-04-08 00:25:40 +04:00
if ( args [ i ] = = 0 )
continue ;
2011-06-22 16:32:43 +04:00
if ( umoven ( tcp , args [ i ] , fdsize , ( char * ) fds ) < 0 ) {
2011-04-08 00:25:40 +04:00
fprintf ( stderr , " umoven() failed \n " ) ;
continue ;
}
2013-11-09 23:46:55 +04:00
for ( j = 0 ; ; j + + ) {
j = next_set_bit ( fds , j , nfds ) ;
if ( j < 0 )
break ;
if ( fdmatch ( tcp , j ) ) {
2011-04-08 00:25:40 +04:00
free ( fds ) ;
return 1 ;
}
2013-11-09 23:46:55 +04:00
}
2011-04-08 00:25:40 +04:00
}
free ( fds ) ;
return 0 ;
}
if ( s - > sys_func = = sys_poll | |
2011-06-07 14:13:24 +04:00
s - > sys_func = = sys_ppoll )
2011-04-08 00:25:40 +04:00
{
struct pollfd fds ;
unsigned nfds ;
unsigned long start , cur , end ;
start = tcp - > u_arg [ 0 ] ;
nfds = tcp - > u_arg [ 1 ] ;
end = start + sizeof ( fds ) * nfds ;
if ( nfds = = 0 | | end < start )
return 0 ;
for ( cur = start ; cur < end ; cur + = sizeof ( fds ) )
if ( ( umoven ( tcp , cur , sizeof fds , ( char * ) & fds ) = = 0 )
& & fdmatch ( tcp , fds . fd ) )
return 1 ;
return 0 ;
}
if ( s - > sys_func = = printargs | |
s - > sys_func = = sys_pipe | |
s - > sys_func = = sys_pipe2 | |
s - > sys_func = = sys_eventfd2 | |
s - > sys_func = = sys_eventfd | |
s - > sys_func = = sys_inotify_init1 | |
s - > sys_func = = sys_timerfd_create | |
s - > sys_func = = sys_timerfd_settime | |
s - > sys_func = = sys_timerfd_gettime | |
s - > sys_func = = sys_epoll_create | |
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-01 21:57:45 +04:00
s - > sys_func = = sys_socket | |
s - > sys_func = = sys_socketpair | |
2014-02-05 08:13:18 +04:00
s - > sys_func = = sys_fanotify_init )
2011-04-08 00:25:40 +04:00
{
/*
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-01 21:57:45 +04:00
* These have TRACE_FILE or TRACE_DESCRIPTOR or TRACE_NETWORK set ,
* but they don ' t have any file descriptor or path args to test .
2011-04-08 00:25:40 +04:00
*/
return 0 ;
}
/*
* Our fallback position for calls that haven ' t already
* been handled is to just check arg [ 0 ] .
*/
if ( s - > sys_flags & TRACE_FILE )
return upathmatch ( tcp , tcp - > u_arg [ 0 ] ) ;
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-01 21:57:45 +04:00
if ( s - > sys_flags & ( TRACE_DESC | TRACE_NETWORK ) )
2011-04-08 00:25:40 +04:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] ) ;
return 0 ;
}