strace/stream.c

434 lines
9.4 KiB
C
Raw Normal View History

1999-02-19 03:21:36 +03:00
/*
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
1999-12-23 17:20:14 +03:00
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
1999-02-19 03:21:36 +03: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"
#ifdef HAVE_POLL_H
# include <poll.h>
#endif
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
#ifdef HAVE_STROPTS_H
# include <stropts.h>
#endif
#ifdef HAVE_SYS_CONF_H
# include <sys/conf.h>
#endif
#ifndef HAVE_STROPTS_H
1999-02-19 03:21:36 +03:00
#define RS_HIPRI 1
struct strbuf {
int maxlen; /* no. of bytes in buffer */
int len; /* no. of bytes returned */
const char *buf; /* pointer to data */
1999-02-19 03:21:36 +03:00
};
#define MORECTL 1
#define MOREDATA 2
#endif /* !HAVE_STROPTS_H */
1999-02-19 03:21:36 +03:00
static const struct xlat msgflags[] = {
1999-02-19 03:21:36 +03:00
{ RS_HIPRI, "RS_HIPRI" },
{ 0, NULL },
};
static void
printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
1999-02-19 03:21:36 +03:00
{
if (sbp->maxlen == -1 && getting)
tprints("{maxlen=-1}");
1999-02-19 03:21:36 +03:00
else {
tprints("{");
1999-02-19 03:21:36 +03:00
if (getting)
tprintf("maxlen=%d, ", sbp->maxlen);
tprintf("len=%d, buf=", sbp->len);
printstr(tcp, (unsigned long) sbp->buf, sbp->len);
tprints("}");
1999-02-19 03:21:36 +03:00
}
}
static void
printstrbufarg(struct tcb *tcp, long arg, int getting)
1999-02-19 03:21:36 +03:00
{
struct strbuf buf;
if (arg == 0)
tprints("NULL");
1999-02-19 03:21:36 +03:00
else if (umove(tcp, arg, &buf) < 0)
tprints("{...}");
1999-02-19 03:21:36 +03:00
else
printstrbuf(tcp, &buf, getting);
tprints(", ");
1999-02-19 03:21:36 +03:00
}
int
sys_putmsg(struct tcb *tcp)
1999-02-19 03:21:36 +03:00
{
int i;
if (entering(tcp)) {
/* fd */
tprintf("%ld, ", tcp->u_arg[0]);
/* control and data */
for (i = 1; i < 3; i++)
printstrbufarg(tcp, tcp->u_arg[i], 0);
/* flags */
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> * util.c (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument, "const char *", with similar meaning to the third argument of printxval(). * defs.h (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument. * bjm.c (sys_query_module) [LINUX]: Pass third argument to printflags(). * desc.c (sys_fcntl): Likewise. (sys_flock) [LOCK_SH]: Likewise. (print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise. * file.c (sys_open): Likewise. (solaris_open) [LINUXSPARC]: Likewise. (sys_access): Likewise. (sys_chflags, sys_fchflags) [FREEBSD]: Likewise. (realprintstat) [HAVE_LONG_LONG_OFF_T && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (printstat64) [HAVE_STAT64 && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (sys_setxattr, sys_fsetxattr): Likewise. * ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget, sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise. (sys_mq_open) [LINUX]: Likewise. (printmqattr) [HAVE_MQUEUE_H]: Likewise. * mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mprotect): Likewise. (sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise. (sys_msync) [MS_ASYNC]: Likewise. (sys_mctl) [MC_SYNC]: Likewise. (sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]: Likewise. * net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise. (sys_send, sys_sendto): Likewise. (sys_sendmsg) [HAVE_SENDMSG]: Likewise. (sys_recv, sys_recvfrom): Likewise. (sys_recvmsg) [HAVE_SENDMSG]: Likewise. (printicmpfilter) [ICMP_FILTER]: Likewise. * proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise. * process.c (sys_clone) [LINUX]: Likewise. (printwaitn): Likewise. (sys_waitid) [SVR4 || LINUX]: Likewise. * signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise. (sys_sigaction): Likewise. (printcontext) [SVR4]: Likewise. (print_stack_t) [LINUX) || FREEBSD]: Likewise. (sys_rt_sigaction) [LINUX]: Likewise. * sock.c (sock_ioctl) [LINUX]: Likewise. * stream.c (sys_putmsg, sys_getmsg): Likewise. (sys_putpmsg) [SYS_putpmsg]: Likewise. (sys_getpmsg) [SYS_getpmsg]: Likewise. (sys_poll): Likewise. (print_transport_message) [TI_BIND]: Likewise. (stream_ioctl): Likewise. * system.c (sys_mount, sys_reboot): Likewise. (sys_cacheflush) [LINUX && M68K]: Likewise. (sys_capget, sys_capset) [SYS_capget]: Likewise. * term.c (term_ioctl) [TIOCMGET]: Likewise. * time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]: Likewise. Fixes RH#159310.
2005-06-01 23:02:36 +04:00
printflags(msgflags, tcp->u_arg[3], "RS_???");
1999-02-19 03:21:36 +03:00
}
return 0;
}
#if defined(SPARC) || defined(SPARC64)
1999-02-19 03:21:36 +03:00
int
sys_getmsg(struct tcb *tcp)
1999-02-19 03:21:36 +03:00
{
int i, flags;
if (entering(tcp)) {
/* fd */
tprintf("%lu, ", tcp->u_arg[0]);
} else {
if (syserror(tcp)) {
tprintf("%#lx, %#lx, %#lx",
tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
return 0;
}
/* control and data */
for (i = 1; i < 3; i++)
printstrbufarg(tcp, tcp->u_arg[i], 1);
/* pointer to flags */
if (tcp->u_arg[3] == 0)
tprints("NULL");
1999-02-19 03:21:36 +03:00
else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
tprints("[?]");
1999-02-19 03:21:36 +03:00
else {
tprints("[");
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> * util.c (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument, "const char *", with similar meaning to the third argument of printxval(). * defs.h (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument. * bjm.c (sys_query_module) [LINUX]: Pass third argument to printflags(). * desc.c (sys_fcntl): Likewise. (sys_flock) [LOCK_SH]: Likewise. (print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise. * file.c (sys_open): Likewise. (solaris_open) [LINUXSPARC]: Likewise. (sys_access): Likewise. (sys_chflags, sys_fchflags) [FREEBSD]: Likewise. (realprintstat) [HAVE_LONG_LONG_OFF_T && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (printstat64) [HAVE_STAT64 && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (sys_setxattr, sys_fsetxattr): Likewise. * ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget, sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise. (sys_mq_open) [LINUX]: Likewise. (printmqattr) [HAVE_MQUEUE_H]: Likewise. * mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mprotect): Likewise. (sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise. (sys_msync) [MS_ASYNC]: Likewise. (sys_mctl) [MC_SYNC]: Likewise. (sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]: Likewise. * net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise. (sys_send, sys_sendto): Likewise. (sys_sendmsg) [HAVE_SENDMSG]: Likewise. (sys_recv, sys_recvfrom): Likewise. (sys_recvmsg) [HAVE_SENDMSG]: Likewise. (printicmpfilter) [ICMP_FILTER]: Likewise. * proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise. * process.c (sys_clone) [LINUX]: Likewise. (printwaitn): Likewise. (sys_waitid) [SVR4 || LINUX]: Likewise. * signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise. (sys_sigaction): Likewise. (printcontext) [SVR4]: Likewise. (print_stack_t) [LINUX) || FREEBSD]: Likewise. (sys_rt_sigaction) [LINUX]: Likewise. * sock.c (sock_ioctl) [LINUX]: Likewise. * stream.c (sys_putmsg, sys_getmsg): Likewise. (sys_putpmsg) [SYS_putpmsg]: Likewise. (sys_getpmsg) [SYS_getpmsg]: Likewise. (sys_poll): Likewise. (print_transport_message) [TI_BIND]: Likewise. (stream_ioctl): Likewise. * system.c (sys_mount, sys_reboot): Likewise. (sys_cacheflush) [LINUX && M68K]: Likewise. (sys_capget, sys_capset) [SYS_capget]: Likewise. * term.c (term_ioctl) [TIOCMGET]: Likewise. * time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]: Likewise. Fixes RH#159310.
2005-06-01 23:02:36 +04:00
printflags(msgflags, flags, "RS_???");
tprints("]");
1999-02-19 03:21:36 +03:00
}
/* decode return value */
switch (tcp->u_rval) {
case MORECTL:
tcp->auxstr = "MORECTL";
break;
case MORECTL|MOREDATA:
tcp->auxstr = "MORECTL|MOREDATA";
break;
case MOREDATA:
tcp->auxstr = "MORECTL";
break;
default:
tcp->auxstr = NULL;
break;
}
}
return RVAL_HEX | RVAL_STR;
}
#endif
1999-02-19 03:21:36 +03:00
#if defined SYS_putpmsg || defined SYS_getpmsg
static const struct xlat pmsgflags[] = {
#ifdef MSG_HIPRI
1999-02-19 03:21:36 +03:00
{ MSG_HIPRI, "MSG_HIPRI" },
#endif
#ifdef MSG_AND
1999-02-19 03:21:36 +03:00
{ MSG_ANY, "MSG_ANY" },
#endif
#ifdef MSG_BAND
1999-02-19 03:21:36 +03:00
{ MSG_BAND, "MSG_BAND" },
#endif
1999-02-19 03:21:36 +03:00
{ 0, NULL },
};
#endif
1999-02-19 03:21:36 +03:00
#ifdef SYS_putpmsg
1999-02-19 03:21:36 +03:00
int
sys_putpmsg(struct tcb *tcp)
1999-02-19 03:21:36 +03:00
{
int i;
if (entering(tcp)) {
/* fd */
tprintf("%ld, ", tcp->u_arg[0]);
/* control and data */
for (i = 1; i < 3; i++)
printstrbufarg(tcp, tcp->u_arg[i], 0);
/* band */
tprintf("%ld, ", tcp->u_arg[3]);
/* flags */
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> * util.c (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument, "const char *", with similar meaning to the third argument of printxval(). * defs.h (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument. * bjm.c (sys_query_module) [LINUX]: Pass third argument to printflags(). * desc.c (sys_fcntl): Likewise. (sys_flock) [LOCK_SH]: Likewise. (print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise. * file.c (sys_open): Likewise. (solaris_open) [LINUXSPARC]: Likewise. (sys_access): Likewise. (sys_chflags, sys_fchflags) [FREEBSD]: Likewise. (realprintstat) [HAVE_LONG_LONG_OFF_T && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (printstat64) [HAVE_STAT64 && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (sys_setxattr, sys_fsetxattr): Likewise. * ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget, sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise. (sys_mq_open) [LINUX]: Likewise. (printmqattr) [HAVE_MQUEUE_H]: Likewise. * mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mprotect): Likewise. (sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise. (sys_msync) [MS_ASYNC]: Likewise. (sys_mctl) [MC_SYNC]: Likewise. (sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]: Likewise. * net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise. (sys_send, sys_sendto): Likewise. (sys_sendmsg) [HAVE_SENDMSG]: Likewise. (sys_recv, sys_recvfrom): Likewise. (sys_recvmsg) [HAVE_SENDMSG]: Likewise. (printicmpfilter) [ICMP_FILTER]: Likewise. * proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise. * process.c (sys_clone) [LINUX]: Likewise. (printwaitn): Likewise. (sys_waitid) [SVR4 || LINUX]: Likewise. * signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise. (sys_sigaction): Likewise. (printcontext) [SVR4]: Likewise. (print_stack_t) [LINUX) || FREEBSD]: Likewise. (sys_rt_sigaction) [LINUX]: Likewise. * sock.c (sock_ioctl) [LINUX]: Likewise. * stream.c (sys_putmsg, sys_getmsg): Likewise. (sys_putpmsg) [SYS_putpmsg]: Likewise. (sys_getpmsg) [SYS_getpmsg]: Likewise. (sys_poll): Likewise. (print_transport_message) [TI_BIND]: Likewise. (stream_ioctl): Likewise. * system.c (sys_mount, sys_reboot): Likewise. (sys_cacheflush) [LINUX && M68K]: Likewise. (sys_capget, sys_capset) [SYS_capget]: Likewise. * term.c (term_ioctl) [TIOCMGET]: Likewise. * time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]: Likewise. Fixes RH#159310.
2005-06-01 23:02:36 +04:00
printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
1999-02-19 03:21:36 +03:00
}
return 0;
}
#endif /* SYS_putpmsg */
1999-02-19 03:21:36 +03:00
#ifdef SYS_getpmsg
1999-02-19 03:21:36 +03:00
int
sys_getpmsg(struct tcb *tcp)
1999-02-19 03:21:36 +03:00
{
int i, flags;
if (entering(tcp)) {
/* fd */
tprintf("%lu, ", tcp->u_arg[0]);
} else {
if (syserror(tcp)) {
tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
return 0;
}
/* control and data */
for (i = 1; i < 3; i++)
printstrbufarg(tcp, tcp->u_arg[i], 1);
/* pointer to band */
printnum(tcp, tcp->u_arg[3], "%d");
tprints(", ");
1999-02-19 03:21:36 +03:00
/* pointer to flags */
if (tcp->u_arg[4] == 0)
tprints("NULL");
1999-02-19 03:21:36 +03:00
else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
tprints("[?]");
1999-02-19 03:21:36 +03:00
else {
tprints("[");
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> * util.c (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument, "const char *", with similar meaning to the third argument of printxval(). * defs.h (printxval): Change third argument from "char *" to "const char *". (printflags): Add third argument. * bjm.c (sys_query_module) [LINUX]: Pass third argument to printflags(). * desc.c (sys_fcntl): Likewise. (sys_flock) [LOCK_SH]: Likewise. (print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise. * file.c (sys_open): Likewise. (solaris_open) [LINUXSPARC]: Likewise. (sys_access): Likewise. (sys_chflags, sys_fchflags) [FREEBSD]: Likewise. (realprintstat) [HAVE_LONG_LONG_OFF_T && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (printstat64) [HAVE_STAT64 && HAVE_STRUCT_STAT_ST_FLAGS]: Likewise. (sys_setxattr, sys_fsetxattr): Likewise. * ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget, sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise. (sys_mq_open) [LINUX]: Likewise. (printmqattr) [HAVE_MQUEUE_H]: Likewise. * mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise. (sys_mprotect): Likewise. (sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise. (sys_msync) [MS_ASYNC]: Likewise. (sys_mctl) [MC_SYNC]: Likewise. (sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]: Likewise. * net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise. (sys_send, sys_sendto): Likewise. (sys_sendmsg) [HAVE_SENDMSG]: Likewise. (sys_recv, sys_recvfrom): Likewise. (sys_recvmsg) [HAVE_SENDMSG]: Likewise. (printicmpfilter) [ICMP_FILTER]: Likewise. * proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise. * process.c (sys_clone) [LINUX]: Likewise. (printwaitn): Likewise. (sys_waitid) [SVR4 || LINUX]: Likewise. * signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise. (sys_sigaction): Likewise. (printcontext) [SVR4]: Likewise. (print_stack_t) [LINUX) || FREEBSD]: Likewise. (sys_rt_sigaction) [LINUX]: Likewise. * sock.c (sock_ioctl) [LINUX]: Likewise. * stream.c (sys_putmsg, sys_getmsg): Likewise. (sys_putpmsg) [SYS_putpmsg]: Likewise. (sys_getpmsg) [SYS_getpmsg]: Likewise. (sys_poll): Likewise. (print_transport_message) [TI_BIND]: Likewise. (stream_ioctl): Likewise. * system.c (sys_mount, sys_reboot): Likewise. (sys_cacheflush) [LINUX && M68K]: Likewise. (sys_capget, sys_capset) [SYS_capget]: Likewise. * term.c (term_ioctl) [TIOCMGET]: Likewise. * time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]: Likewise. Fixes RH#159310.
2005-06-01 23:02:36 +04:00
printflags(pmsgflags, flags, "MSG_???");
tprints("]");
1999-02-19 03:21:36 +03:00
}
/* decode return value */
switch (tcp->u_rval) {
case MORECTL:
tcp->auxstr = "MORECTL";
break;
case MORECTL|MOREDATA:
tcp->auxstr = "MORECTL|MOREDATA";
break;
case MOREDATA:
tcp->auxstr = "MORECTL";
break;
default:
tcp->auxstr = NULL;
break;
}
}
return RVAL_HEX | RVAL_STR;
}
#endif /* SYS_getpmsg */
1999-02-19 03:21:36 +03:00
#ifdef HAVE_SYS_POLL_H
static const struct xlat pollflags[] = {
#ifdef POLLIN
1999-02-19 03:21:36 +03:00
{ POLLIN, "POLLIN" },
{ POLLPRI, "POLLPRI" },
{ POLLOUT, "POLLOUT" },
#ifdef POLLRDNORM
{ POLLRDNORM, "POLLRDNORM" },
#endif
#ifdef POLLWRNORM
{ POLLWRNORM, "POLLWRNORM" },
#endif
#ifdef POLLRDBAND
{ POLLRDBAND, "POLLRDBAND" },
#endif
#ifdef POLLWRBAND
{ POLLWRBAND, "POLLWRBAND" },
#endif
{ POLLERR, "POLLERR" },
{ POLLHUP, "POLLHUP" },
{ POLLNVAL, "POLLNVAL" },
#endif
1999-02-19 03:21:36 +03:00
{ 0, NULL },
};
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
static int
decode_poll(struct tcb *tcp, long pts)
1999-02-19 03:21:36 +03:00
{
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> Deal with memory management issues. * defs.h (tprint_iov): Update prototype. * desc.c (sys_epoll_wait) [HAVE_SYS_EPOLL_H]: Do not allocate epoll_event array of arbitrary size on the stack, to avoid stack overflow. * file.c (print_xattr_val): Check for integer overflow during malloc size calculation, to avoid heap corruption. * io.c (tprint_iov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change iovec array handling to avoid heap memory allocation. * mem.c (get_nodes) [LINUX]: Check for integer overflow during size calculation and do not allocate array of arbitrary size on the stack, to avoid stack overflow. * net.c (printcmsghdr) [HAVE_SENDMSG]: Do not allocate array of arbitrary size on the stack, to avoid stack overflow. Do not trust cmsg.cmsg_len to avoid read beyond the end of allocated object. (printmsghdr) [HAVE_SENDMSG]: Update tprint_iov() usage. * process.c (sys_setgroups): Check for integer overflow during malloc size calculation, to avoid heap corruption. Change gid_t array handling to avoid heap memory allocation. (sys_getgroups): Likewise. (sys_setgroups32) [LINUX]: Likewise. (sys_getgroups32) [LINUX]: Likewise. * stream.c (sys_poll) [HAVE_SYS_POLL_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change pollfd array handling to avoid heap memory allocation. * system.c (sys_sysctl) [LINUX]: Check for integer overflow during malloc size calculation, to avoid heap corruption. * util.c (dumpiov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Fixes RH#159196.
2005-06-01 23:22:06 +04:00
struct pollfd fds;
unsigned nfds;
unsigned long size, start, cur, end, abbrev_end;
int failed = 0;
1999-02-19 03:21:36 +03:00
if (entering(tcp)) {
nfds = tcp->u_arg[1];
size = sizeof(fds) * nfds;
start = tcp->u_arg[0];
end = start + size;
if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
tprintf("%#lx, %d, ",
tcp->u_arg[0], nfds);
return 0;
}
if (abbrev(tcp)) {
abbrev_end = start + max_strlen * sizeof(fds);
if (abbrev_end < start)
abbrev_end = end;
} else {
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> Deal with memory management issues. * defs.h (tprint_iov): Update prototype. * desc.c (sys_epoll_wait) [HAVE_SYS_EPOLL_H]: Do not allocate epoll_event array of arbitrary size on the stack, to avoid stack overflow. * file.c (print_xattr_val): Check for integer overflow during malloc size calculation, to avoid heap corruption. * io.c (tprint_iov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change iovec array handling to avoid heap memory allocation. * mem.c (get_nodes) [LINUX]: Check for integer overflow during size calculation and do not allocate array of arbitrary size on the stack, to avoid stack overflow. * net.c (printcmsghdr) [HAVE_SENDMSG]: Do not allocate array of arbitrary size on the stack, to avoid stack overflow. Do not trust cmsg.cmsg_len to avoid read beyond the end of allocated object. (printmsghdr) [HAVE_SENDMSG]: Update tprint_iov() usage. * process.c (sys_setgroups): Check for integer overflow during malloc size calculation, to avoid heap corruption. Change gid_t array handling to avoid heap memory allocation. (sys_getgroups): Likewise. (sys_setgroups32) [LINUX]: Likewise. (sys_getgroups32) [LINUX]: Likewise. * stream.c (sys_poll) [HAVE_SYS_POLL_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change pollfd array handling to avoid heap memory allocation. * system.c (sys_sysctl) [LINUX]: Check for integer overflow during malloc size calculation, to avoid heap corruption. * util.c (dumpiov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Fixes RH#159196.
2005-06-01 23:22:06 +04:00
abbrev_end = end;
}
tprints("[");
for (cur = start; cur < end; cur += sizeof(fds)) {
if (cur > start)
tprints(", ");
if (cur >= abbrev_end) {
tprints("...");
break;
}
if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
tprints("?");
failed = 1;
break;
}
if (fds.fd < 0) {
tprintf("{fd=%d}", fds.fd);
continue;
}
tprints("{fd=");
printfd(tcp, fds.fd);
tprints(", events=");
printflags(pollflags, fds.events, "POLL???");
tprints("}");
}
tprints("]");
if (failed)
tprintf(" %#lx", start);
tprintf(", %d, ", nfds);
return 0;
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> Deal with memory management issues. * defs.h (tprint_iov): Update prototype. * desc.c (sys_epoll_wait) [HAVE_SYS_EPOLL_H]: Do not allocate epoll_event array of arbitrary size on the stack, to avoid stack overflow. * file.c (print_xattr_val): Check for integer overflow during malloc size calculation, to avoid heap corruption. * io.c (tprint_iov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change iovec array handling to avoid heap memory allocation. * mem.c (get_nodes) [LINUX]: Check for integer overflow during size calculation and do not allocate array of arbitrary size on the stack, to avoid stack overflow. * net.c (printcmsghdr) [HAVE_SENDMSG]: Do not allocate array of arbitrary size on the stack, to avoid stack overflow. Do not trust cmsg.cmsg_len to avoid read beyond the end of allocated object. (printmsghdr) [HAVE_SENDMSG]: Update tprint_iov() usage. * process.c (sys_setgroups): Check for integer overflow during malloc size calculation, to avoid heap corruption. Change gid_t array handling to avoid heap memory allocation. (sys_getgroups): Likewise. (sys_setgroups32) [LINUX]: Likewise. (sys_getgroups32) [LINUX]: Likewise. * stream.c (sys_poll) [HAVE_SYS_POLL_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change pollfd array handling to avoid heap memory allocation. * system.c (sys_sysctl) [LINUX]: Check for integer overflow during malloc size calculation, to avoid heap corruption. * util.c (dumpiov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Fixes RH#159196.
2005-06-01 23:22:06 +04:00
} else {
static char outstr[1024];
char *outptr;
#define end_outstr (outstr + sizeof(outstr))
const char *flagstr;
if (syserror(tcp))
return 0;
if (tcp->u_rval == 0) {
tcp->auxstr = "Timeout";
return RVAL_STR;
1999-02-19 03:21:36 +03:00
}
nfds = tcp->u_arg[1];
size = sizeof(fds) * nfds;
start = tcp->u_arg[0];
end = start + size;
if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
return 0;
if (abbrev(tcp)) {
abbrev_end = start + max_strlen * sizeof(fds);
if (abbrev_end < start)
abbrev_end = end;
} else {
abbrev_end = end;
1999-02-19 03:21:36 +03:00
}
outptr = outstr;
for (cur = start; cur < end; cur += sizeof(fds)) {
if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
if (outptr < end_outstr - 2)
*outptr++ = '?';
failed = 1;
break;
}
if (!fds.revents)
continue;
if (outptr == outstr) {
*outptr++ = '[';
} else {
if (outptr < end_outstr - 3)
outptr = stpcpy(outptr, ", ");
}
if (cur >= abbrev_end) {
if (outptr < end_outstr - 4)
outptr = stpcpy(outptr, "...");
break;
}
if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
2011-06-07 14:13:24 +04:00
flagstr = sprintflags("", pollflags, fds.revents);
if (outptr < end_outstr - (strlen(flagstr) + 2)) {
outptr = stpcpy(outptr, flagstr);
*outptr++ = '}';
}
1999-02-19 03:21:36 +03:00
}
if (failed)
return 0;
if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
*outptr++ = ']';
*outptr = '\0';
if (pts) {
if (outptr < end_outstr - (10 + TIMESPEC_TEXT_BUFSIZE)) {
outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
sprint_timespec(outptr, tcp, pts);
}
1999-02-19 03:21:36 +03:00
}
if (outptr == outstr)
return 0;
tcp->auxstr = outstr;
return RVAL_STR;
#undef end_outstr
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> Deal with memory management issues. * defs.h (tprint_iov): Update prototype. * desc.c (sys_epoll_wait) [HAVE_SYS_EPOLL_H]: Do not allocate epoll_event array of arbitrary size on the stack, to avoid stack overflow. * file.c (print_xattr_val): Check for integer overflow during malloc size calculation, to avoid heap corruption. * io.c (tprint_iov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change iovec array handling to avoid heap memory allocation. * mem.c (get_nodes) [LINUX]: Check for integer overflow during size calculation and do not allocate array of arbitrary size on the stack, to avoid stack overflow. * net.c (printcmsghdr) [HAVE_SENDMSG]: Do not allocate array of arbitrary size on the stack, to avoid stack overflow. Do not trust cmsg.cmsg_len to avoid read beyond the end of allocated object. (printmsghdr) [HAVE_SENDMSG]: Update tprint_iov() usage. * process.c (sys_setgroups): Check for integer overflow during malloc size calculation, to avoid heap corruption. Change gid_t array handling to avoid heap memory allocation. (sys_getgroups): Likewise. (sys_setgroups32) [LINUX]: Likewise. (sys_getgroups32) [LINUX]: Likewise. * stream.c (sys_poll) [HAVE_SYS_POLL_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change pollfd array handling to avoid heap memory allocation. * system.c (sys_sysctl) [LINUX]: Check for integer overflow during malloc size calculation, to avoid heap corruption. * util.c (dumpiov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Fixes RH#159196.
2005-06-01 23:22:06 +04:00
}
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
}
int
sys_poll(struct tcb *tcp)
{
int rc = decode_poll(tcp, 0);
if (entering(tcp)) {
1999-02-19 03:21:36 +03:00
#ifdef INFTIM
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
if (tcp->u_arg[2] == INFTIM)
tprints("INFTIM");
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
else
1999-02-19 03:21:36 +03:00
#endif
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
tprintf("%ld", tcp->u_arg[2]);
}
return rc;
1999-02-19 03:21:36 +03:00
}
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
int
sys_ppoll(struct tcb *tcp)
{
int rc = decode_poll(tcp, tcp->u_arg[2]);
if (entering(tcp)) {
print_timespec(tcp, tcp->u_arg[2]);
tprints(", ");
2006-10-13 Ulrich Drepper <drepper@redhat.com> Bernhard Kaindl <bk@suse.de> Dmitry V. Levin <ldv@altlinux.org> Michael Holzheu <holzheu@de.ibm.com> Add hooks for new syscalls. Add decoders for *at, inotify*, pselect6, ppoll and unshare syscalls. * defs.h: Declare print_sigset. * desc.c (sys_pselect6): New function. * file.c (decode_open, decode_access, decode_mkdir, decode_readlink, decode_chmod, decode_utimes, decode_mknod): New functions. (sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod, sys_utimes, sys_mknod): Use them. [LINUX] (fstatatflags, unlinkatflags, inotify_modes): New variables. [LINUX] (print_dirfd, sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch, sys_inotify_rm_watch): New functions. * process.c [LINUX] (sys_unshare): New function. * signal.c (print_sigset): New function. (sys_sigprocmask): Use it. * stream.c (decode_poll): New function. (sys_poll): Use it. [LINUX] (sys_ppoll): New function. * linux/syscall.h: Delcare new syscall handlers. * linux/syscallent.h: Hook up new syscalls. * linux/alpha/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. Fixes RH#178633.
2006-10-14 00:25:12 +04:00
print_sigset(tcp, tcp->u_arg[3], 0);
tprintf(", %lu", tcp->u_arg[4]);
}
return rc;
}
2005-05-31 Dmitry V. Levin <ldv@altlinux.org> Deal with memory management issues. * defs.h (tprint_iov): Update prototype. * desc.c (sys_epoll_wait) [HAVE_SYS_EPOLL_H]: Do not allocate epoll_event array of arbitrary size on the stack, to avoid stack overflow. * file.c (print_xattr_val): Check for integer overflow during malloc size calculation, to avoid heap corruption. * io.c (tprint_iov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change iovec array handling to avoid heap memory allocation. * mem.c (get_nodes) [LINUX]: Check for integer overflow during size calculation and do not allocate array of arbitrary size on the stack, to avoid stack overflow. * net.c (printcmsghdr) [HAVE_SENDMSG]: Do not allocate array of arbitrary size on the stack, to avoid stack overflow. Do not trust cmsg.cmsg_len to avoid read beyond the end of allocated object. (printmsghdr) [HAVE_SENDMSG]: Update tprint_iov() usage. * process.c (sys_setgroups): Check for integer overflow during malloc size calculation, to avoid heap corruption. Change gid_t array handling to avoid heap memory allocation. (sys_getgroups): Likewise. (sys_setgroups32) [LINUX]: Likewise. (sys_getgroups32) [LINUX]: Likewise. * stream.c (sys_poll) [HAVE_SYS_POLL_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Change pollfd array handling to avoid heap memory allocation. * system.c (sys_sysctl) [LINUX]: Check for integer overflow during malloc size calculation, to avoid heap corruption. * util.c (dumpiov) [HAVE_SYS_UIO_H]: Check for integer overflow during malloc size calculation, to avoid heap corruption. Fixes RH#159196.
2005-06-01 23:22:06 +04:00
#else /* !HAVE_SYS_POLL_H */
int
sys_poll(struct tcb *tcp)
{
return 0;
}
#endif