2011-04-07 20:25:40 +00:00
/*
2017-05-22 18:53:14 +02:00
* Copyright ( c ) 2011 Comtrol Corp .
2018-02-13 22:00:00 +00:00
* Copyright ( c ) 2011 - 2018 The strace developers .
2011-04-07 20:25:40 +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 .
*
*/
# include "defs.h"
2018-02-11 00:26:09 +00:00
# include <limits.h>
2015-07-30 16:23:58 +00:00
# include <poll.h>
2011-04-07 20:25:40 +00:00
# include "syscall.h"
2018-01-06 01:45:16 +00:00
# include "xstring.h"
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
struct path_set global_path_set ;
2011-04-07 20:25:40 +00:00
/*
* Return true if specified path matches one that we ' re tracing .
*/
2017-07-08 15:28:56 +07:00
static bool
pathmatch ( const char * path , struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2013-03-05 15:46:34 +01:00
unsigned i ;
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
for ( i = 0 ; i < set - > num_selected ; + + i ) {
if ( strcmp ( path , set - > paths_selected [ i ] ) = = 0 )
return true ;
2011-04-07 20:25:40 +00:00
}
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
}
/*
* Return true if specified path ( in user - space ) matches .
*/
2017-07-08 15:28:56 +07:00
static bool
upathmatch ( struct tcb * const tcp , const kernel_ulong_t upath ,
struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2011-06-22 14:32:43 +02:00
char path [ PATH_MAX + 1 ] ;
2011-04-07 20:25:40 +00:00
2017-06-17 18:49:58 +00:00
return umovestr ( tcp , upath , sizeof ( path ) , path ) > 0 & &
2017-07-08 15:28:56 +07:00
pathmatch ( path , set ) ;
2011-04-07 20:25:40 +00:00
}
/*
* Return true if specified fd maps to a path we ' re tracing .
*/
2017-07-08 15:28:56 +07:00
static bool
fdmatch ( struct tcb * tcp , int fd , struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2013-03-06 18:24:34 +01:00
char path [ PATH_MAX + 1 ] ;
int n = getfdpath ( tcp , fd , path , sizeof ( path ) ) ;
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
return n > = 0 & & pathmatch ( path , set ) ;
2011-04-07 20:25:40 +00: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 09:57:45 -08:00
* Specifying NULL will delete all paths .
2011-04-07 20:25:40 +00:00
*/
2013-03-05 15:46:34 +01:00
static void
2017-07-08 15:28:56 +07:00
storepath ( const char * path , struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2017-07-08 15:28:56 +07:00
if ( pathmatch ( path , set ) )
2013-03-05 15:46:34 +01:00
return ; /* already in table */
2011-04-07 20:25:40 +00:00
2017-12-13 13:52:59 +01:00
if ( set - > num_selected > = set - > size )
set - > paths_selected =
xgrowarray ( set - > paths_selected , & set - > size ,
sizeof ( set - > paths_selected [ 0 ] ) ) ;
set - > paths_selected [ set - > num_selected + + ] = path ;
2011-04-07 20:25:40 +00:00
}
/*
* Get path associated with fd .
*/
2013-03-06 18:24:34 +01:00
int
getfdpath ( struct tcb * tcp , int fd , char * buf , unsigned bufsize )
2011-04-07 20:25:40 +00:00
{
2012-03-15 18:11:51 +01:00
char linkpath [ sizeof ( " /proc/%u/fd/%u " ) + 2 * sizeof ( int ) * 3 ] ;
2011-04-07 20:25:40 +00:00
ssize_t n ;
if ( fd < 0 )
2013-03-06 18:24:34 +01:00
return - 1 ;
2011-04-07 20:25:40 +00:00
2018-01-06 01:45:16 +00:00
xsprintf ( linkpath , " /proc/%u/fd/%u " , tcp - > pid , fd ) ;
2013-03-06 18:24:34 +01: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-07 20:25:40 +00:00
}
/*
* Add a path to the set we ' re tracing . Also add the canonicalized
2017-07-21 20:14:58 +02:00
* version of the path . Specifying NULL will delete all paths .
2011-04-07 20:25:40 +00:00
*/
2013-03-05 15:46:34 +01:00
void
2017-07-08 15:28:56 +07:00
pathtrace_select_set ( const char * path , struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2012-03-15 18:03:56 +01:00
char * rpath ;
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
storepath ( path , set ) ;
2011-04-07 20:25:40 +00:00
rpath = realpath ( path , NULL ) ;
if ( rpath = = NULL )
2013-03-05 15:46:34 +01:00
return ;
2011-04-07 20:25:40 +00:00
/* if realpath and specified path are same, we're done */
2012-03-15 18:03:56 +01:00
if ( strcmp ( path , rpath ) = = 0 ) {
2011-04-07 20:25:40 +00:00
free ( rpath ) ;
2013-03-05 15:46:34 +01:00
return ;
2011-04-07 20:25:40 +00:00
}
Consistently use error_msg instead of fprintf(stderr)
* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.
2015-05-25 22:51:19 +00:00
error_msg ( " Requested path '%s' resolved into '%s' " , path , rpath ) ;
2017-07-08 15:28:56 +07:00
storepath ( rpath , set ) ;
2011-04-07 20:25:40 +00:00
}
2018-01-22 00:31:07 +00:00
static bool
match_xselect_args ( struct tcb * tcp , const kernel_ulong_t * args ,
struct path_set * set )
{
/* Kernel truncates arg[0] to int, we do the same. */
int nfds = ( int ) args [ 0 ] ;
/* Kernel rejects negative nfds, so we don't parse it either. */
if ( nfds < = 0 )
return false ;
/* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */
if ( nfds > 1024 * 1024 )
nfds = 1024 * 1024 ;
unsigned int fdsize = ( ( ( nfds + 7 ) / 8 ) + current_wordsize - 1 ) & - current_wordsize ;
fd_set * fds = xmalloc ( fdsize ) ;
for ( unsigned int i = 1 ; i < = 3 ; + + i ) {
if ( args [ i ] = = 0 )
continue ;
if ( umoven ( tcp , args [ i ] , fdsize , fds ) < 0 )
continue ;
for ( int j = 0 ; ; + + j ) {
j = next_set_bit ( fds , j , nfds ) ;
if ( j < 0 )
break ;
if ( fdmatch ( tcp , j , set ) ) {
free ( fds ) ;
return true ;
}
}
}
free ( fds ) ;
return false ;
}
2011-04-07 20:25:40 +00:00
/*
* Return true if syscall accesses a selected path
* ( or if no paths have been specified for tracing ) .
*/
2017-07-08 15:28:56 +07:00
bool
pathtrace_match_set ( struct tcb * tcp , struct path_set * set )
2011-04-07 20:25:40 +00:00
{
2013-02-22 13:26:10 +01:00
const struct_sysent * s ;
2011-04-07 20:25:40 +00:00
2013-02-21 16:13:47 +01:00
s = tcp - > s_ent ;
2011-04-07 20:25:40 +00: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 09:57:45 -08:00
if ( ! ( s - > sys_flags & ( TRACE_FILE | TRACE_DESC | TRACE_NETWORK ) ) )
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
/*
* Check for special cases where we need to do something
* other than test arg [ 0 ] .
*/
2015-07-10 22:24:58 +03:00
switch ( s - > sen ) {
case SEN_dup2 :
case SEN_dup3 :
2015-11-22 18:51:05 +00:00
case SEN_kexec_file_load :
2015-07-10 22:24:58 +03:00
case SEN_sendfile :
case SEN_sendfile64 :
case SEN_tee :
2011-04-07 20:25:40 +00:00
/* fd, fd */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] , set ) | |
fdmatch ( tcp , tcp - > u_arg [ 1 ] , set ) ;
2011-04-07 20:25:40 +00:00
2017-08-11 12:43:57 +07:00
case SEN_execveat :
2015-07-10 22:24:58 +03:00
case SEN_faccessat :
case SEN_fchmodat :
case SEN_fchownat :
2016-08-23 14:27:49 +00:00
case SEN_fstatat64 :
2015-07-10 22:24:58 +03:00
case SEN_futimesat :
case SEN_inotify_add_watch :
case SEN_mkdirat :
case SEN_mknodat :
2015-11-22 21:29:32 +00:00
case SEN_name_to_handle_at :
2015-07-10 22:24:58 +03:00
case SEN_newfstatat :
case SEN_openat :
case SEN_readlinkat :
2017-03-18 18:19:07 +03:00
case SEN_statx :
2015-07-10 22:24:58 +03:00
case SEN_unlinkat :
case SEN_utimensat :
2011-04-07 20:25:40 +00:00
/* fd, path */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] , set ) ;
2011-04-07 20:25:40 +00:00
2015-07-10 22:24:58 +03:00
case SEN_link :
case SEN_mount :
case SEN_pivotroot :
2011-04-07 20:25:40 +00:00
/* path, path */
2017-07-08 15:28:56 +07:00
return upathmatch ( tcp , tcp - > u_arg [ 0 ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] , set ) ;
2011-04-07 20:25:40 +00:00
2015-07-10 22:24:58 +03:00
case SEN_quotactl :
2017-08-06 19:22:06 +07:00
case SEN_symlink :
2012-10-26 23:43:13 +00:00
/* x, path */
2017-07-08 15:28:56 +07:00
return upathmatch ( tcp , tcp - > u_arg [ 1 ] , set ) ;
2012-10-26 23:43:13 +00:00
2015-07-10 22:24:58 +03:00
case SEN_linkat :
case SEN_renameat2 :
case SEN_renameat :
2011-04-07 20:25:40 +00:00
/* fd, path, fd, path */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] , set ) | |
fdmatch ( tcp , tcp - > u_arg [ 2 ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ 1 ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ 3 ] , set ) ;
2011-04-07 20:25:40 +00:00
2018-01-21 01:46:04 +00:00
# if HAVE_ARCH_OLD_MMAP
2015-07-10 22:24:58 +03:00
case SEN_old_mmap :
2018-01-21 01:46:04 +00:00
# if HAVE_ARCH_OLD_MMAP_PGOFF
2015-07-10 22:24:58 +03:00
case SEN_old_mmap_pgoff :
2018-01-17 02:38:55 +01:00
# endif
{
2018-01-21 23:23:31 +00:00
kernel_ulong_t * args =
fetch_indirect_syscall_args ( tcp , tcp - > u_arg [ 0 ] , 6 ) ;
2018-01-17 02:38:55 +01:00
return args & & fdmatch ( tcp , args [ 4 ] , set ) ;
}
# endif /* HAVE_ARCH_OLD_MMAP */
2015-07-10 22:24:58 +03:00
case SEN_mmap :
case SEN_mmap_4koff :
case SEN_mmap_pgoff :
2015-12-24 15:40:55 +00:00
case SEN_ARCH_mmap :
2011-04-07 20:25:40 +00:00
/* x, x, x, x, fd */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 4 ] , set ) ;
2011-04-07 20:25:40 +00:00
2015-07-10 22:24:58 +03:00
case SEN_symlinkat :
2017-08-06 12:39:56 +00:00
/* x, fd, path */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 1 ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ 2 ] , set ) ;
2011-04-07 20:25:40 +00:00
2016-02-13 03:45:32 +00:00
case SEN_copy_file_range :
2015-07-10 22:24:58 +03:00
case SEN_splice :
2016-02-13 03:45:32 +00:00
/* fd, x, fd, x, x, x */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] , set ) | |
fdmatch ( tcp , tcp - > u_arg [ 2 ] , set ) ;
2011-04-07 20:25:40 +00:00
2015-07-10 22:24:58 +03:00
case SEN_epoll_ctl :
2011-04-07 20:25:40 +00:00
/* x, x, fd, x */
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 2 ] , set ) ;
2011-04-07 20:25:40 +00:00
2015-07-10 22:24:58 +03:00
case SEN_fanotify_mark :
2017-07-23 11:44:36 +07:00
{
/* x, x, mask (64 bit), fd, path */
unsigned long long mask = 0 ;
int argn = getllval ( tcp , & mask , 2 ) ;
return fdmatch ( tcp , tcp - > u_arg [ argn ] , set ) | |
upathmatch ( tcp , tcp - > u_arg [ argn + 1 ] , set ) ;
}
2018-01-22 00:31:07 +00:00
# if HAVE_ARCH_OLD_SELECT
2015-07-10 22:24:58 +03:00
case SEN_oldselect :
2011-04-07 20:25:40 +00:00
{
2018-01-22 00:31:07 +00:00
kernel_ulong_t * args =
fetch_indirect_syscall_args ( tcp , tcp - > u_arg [ 0 ] , 5 ) ;
2011-04-07 20:25:40 +00:00
2018-01-22 00:31:07 +00:00
return args & & match_xselect_args ( tcp , args , set ) ;
2011-04-07 20:25:40 +00:00
}
2018-01-22 00:31:07 +00:00
# endif
case SEN_pselect6 :
case SEN_select :
return match_xselect_args ( tcp , tcp - > u_arg , set ) ;
2015-07-10 22:24:58 +03:00
case SEN_poll :
case SEN_ppoll :
2011-04-07 20:25:40 +00:00
{
struct pollfd fds ;
unsigned nfds ;
2016-12-26 10:26:03 +00:00
kernel_ulong_t start , cur , end ;
2011-04-07 20:25:40 +00:00
start = tcp - > u_arg [ 0 ] ;
nfds = tcp - > u_arg [ 1 ] ;
2017-07-21 20:15:24 +02:00
if ( nfds > 1024 * 1024 )
nfds = 1024 * 1024 ;
2011-04-07 20:25:40 +00:00
end = start + sizeof ( fds ) * nfds ;
if ( nfds = = 0 | | end < start )
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
2017-07-20 21:14:42 +02:00
for ( cur = start ; cur < end ; cur + = sizeof ( fds ) ) {
if ( umove ( tcp , cur , & fds ) )
break ;
if ( fdmatch ( tcp , fds . fd , set ) )
2017-07-08 15:28:56 +07:00
return true ;
2017-07-20 21:14:42 +02:00
}
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
}
2018-01-15 23:33:18 +00:00
case SEN_accept4 :
case SEN_accept :
2015-07-25 23:55:51 +00:00
case SEN_bpf :
2015-07-10 22:24:58 +03:00
case SEN_epoll_create :
2015-08-01 23:07:19 +00:00
case SEN_epoll_create1 :
2015-07-10 22:24:58 +03:00
case SEN_eventfd2 :
case SEN_eventfd :
case SEN_fanotify_init :
2017-08-06 19:22:06 +07:00
case SEN_inotify_init :
2015-07-10 22:24:58 +03:00
case SEN_inotify_init1 :
2015-07-28 23:03:41 +00:00
case SEN_memfd_create :
Enhance decoding of mq_* syscalls
* mq.c (SYS_FUNC(mq_open)): Add RVAL_FD to return value.
(SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive), SYS_FUNC(mq_notify),
SYS_FUNC(mq_getsetattr)): Print the first argument using printfd.
* NEWS: Mention this change.
* pathtrace.c (pathtrace_match_set) <SEN_mq_getsetattr, SEN_mq_notify,
SEN_mq_open, SEN_mq_timedreceive, SEN_mq_timedsend>: Skip matching.
* linux/32/syscallent.h (mq_getsetattr, mq_notify, mq_open,
mq_timedreceive, mq_timedsend): Add TD flag.
* linux/64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/crisv10/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/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/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
2018-01-15 22:47:38 +00:00
case SEN_mq_getsetattr :
case SEN_mq_notify :
case SEN_mq_open :
case SEN_mq_timedreceive :
case SEN_mq_timedsend :
2015-07-10 22:24:58 +03:00
case SEN_perf_event_open :
case SEN_pipe :
2016-02-12 16:15:23 +00:00
case SEN_pipe2 :
2015-07-10 22:24:58 +03:00
case SEN_printargs :
2018-01-15 23:33:18 +00:00
case SEN_signalfd4 :
case SEN_signalfd :
2015-07-10 22:24:58 +03:00
case SEN_socket :
case SEN_socketpair :
case SEN_timerfd_create :
case SEN_timerfd_gettime :
case SEN_timerfd_settime :
2015-11-22 19:56:00 +00:00
case SEN_userfaultfd :
2011-04-07 20:25:40 +00: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 09:57:45 -08: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-07 20:25:40 +00:00
*/
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
}
/*
* Our fallback position for calls that haven ' t already
* been handled is to just check arg [ 0 ] .
*/
if ( s - > sys_flags & TRACE_FILE )
2017-07-08 15:28:56 +07:00
return upathmatch ( tcp , tcp - > u_arg [ 0 ] , set ) ;
2011-04-07 20:25:40 +00: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 09:57:45 -08:00
if ( s - > sys_flags & ( TRACE_DESC | TRACE_NETWORK ) )
2017-07-08 15:28:56 +07:00
return fdmatch ( tcp , tcp - > u_arg [ 0 ] , set ) ;
2011-04-07 20:25:40 +00:00
2017-07-08 15:28:56 +07:00
return false ;
2011-04-07 20:25:40 +00:00
}