Long/address printing in non-native personalities
Hello. It's been brought to my attention that one of strace tests (nsyscalls) is failing when x32 ABI is used. $ cat tests-mx32/nsyscalls.log 1c1 < syscall_546(0xbadc0ded, 0xbadc1ded, 0xbadc2ded, 0xbadc3ded, 0xbadc4ded, 0xbadc5ded) = -1 (errno 38) --- > syscall_546(0xbadc0ded, 0xbadc1ded, 0xbadc2ded, 0xbadc3ded, 0xbadc4ded, > 0xbadc5ded) = -1 (errno 38) nsyscalls.test: failed test: ../strace -e trace=none ./nsyscalls output mismatch FAIL nsyscalls.test (exit status: 1) Upon investigation, it has been revealed that the problem is in the way strace handles tracee's long integer variables, which, in turn, has been brought to light by the quirk in the way argument passing code being generated by GCC. More specifically, when a 6-parameter syscall is called (as nsyscalls tests does), 7 parameters should be passed to libc's syscall() wrapper: syscall number itself and its parameters. As a result, 7th argument should be passed via stack in accordance with x32 ABI ( https://docs.google.com/viewer?a=v=sites=ZGVmYXVsdGRvbWFpbnx4MzJhYml8Z3g6MzVkYzQwOWIwOGU4YzViYw , page 22). Also, in conformance with x32 ABI, all arguments should be extended to 8 bytes in size. Standard does not explicitly specify the way this should be performed, and that's where GCC does something strange: it sign-extends parameters passed via stack while zero-extends parameters passed via registers (or, more precisely, doesn't care about higher bits at all in latter case, for obvious reasons): Dump of assembler code for function main: 0x00400370 <+0>: push %rbx 0x00400371 <+1>: mov $0xbadc4ded,%r9d 0x00400377 <+7>: mov $0xbadc3ded,%r8d 0x0040037d <+13>: mov $0xbadc2ded,%ecx 0x00400382 <+18>: mov $0xbadc1ded,%edx 0x00400387 <+23>: mov $0xbadc0ded,%esi 0x0040038c <+28>: sub $0x8,%esp 0x0040038f <+31>: mov $0x4222,%edi 0x00400394 <+36>: xor %eax,%eax => 0x00400396 <+38>: pushq $0xbadc5ded 0x0040039b <+43>: callq 0x400350And this is what leads to test failure — strace does not care about tracee's size of long when it prints syscall arguments (printargs() in syscall.c simply calls tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i])). Moreover, it similarly does not care about tracee's pointer size in places where it prints them (my first attempt to fix this issue was by (incorrectly) utilising printnum_ulong(), but it failed hilariously, since umoven_or_printaddr(), which is apparently called before actual printing, leads to precisely the same results since it simply calls tprintf("%#lx", addr)). As a result, I propose the following change where all cases when tracee's long (or pointer, since they have the same size in Linux ABIs AFAIK) should be printed are handled via printaddr() and logic regarding dispatching current_wordsize is added to printaddr() itself (maybe it also should be renamed to printlong() or something more suitable). I'm not really sure whether GCC's behaviour is correct, but it (at least) doesn't contradict common sense (and x32 ABI spec) as far as I can see, since higher 32 bits are not used anyway. --- syscall.c |7 +-- util.c| 25 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/syscall.c b/syscall.c index d71ead3..4d9d152 100644 --- a/syscall.c +++ b/syscall.c @@ -636,8 +636,11 @@ printargs(struct tcb *tcp) if (entering(tcp)) { int i; int n = tcp->s_ent->nargs; - for (i = 0; i < n; i++) - tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i]); + for (i = 0; i < n; i++) { + if (i) + tprints(", "); + printaddr(tcp->u_arg[i]); + } } return 0; } diff --git a/util.c b/util.c index 9c8c978..ba0d2a6 100644 --- a/util.c +++ b/util.c @@ -398,10 +398,15 @@ printflags64(const struct xlat *xlat, uint64_t flags, const char *dflt) void printaddr(const long addr) { - if (!addr) + if (!addr) { tprints("NULL"); - else - tprintf("%#lx", addr); + } else { + if (current_wordsize sizeof(int)) { + tprintf("%#lx", addr); + } else { + tprintf("%#x", (unsigned int)addr); + } + } } #define DEF_PRINTNUM(name, type) \ @@ -761,7 +766,7 @@ printpathn(struct tcb *tcp, long addr, unsigned int n) /* Fetch one byte more to find out whether path length n. */ nul_seen = umovestr(tcp, addr, n + 1, path); if (nul_seen < 0) - tprintf("%#lx", addr); + printaddr(addr); else { path[n++] = '\0'; print_quoted_string(path, n, QUOTE_0_TERMINATED); @@ -812,7 +817,7 @@ printstr(struct tcb *tcp, long addr, long len) * because string_quote may look one byte ahead. */ if (umovestr(tcp, addr, size + 1, str) <
[PATCH] Split qualify/multipers-related stuff into separate files
This is an initial attempt ("proof of concept") of division of enormous syscall.c into more local pieces. Originally it was intended to split out qualify-related stuff, but in process it is revealed that there is also significant part of multipers-related stuff which is also should be isolated from syscall.c in order to successfully separate qualify stuff. Notable tricks: * Reliance on SYS_socket_subcall/SYS_ipc_subcall defined in syscallent.h which is not a normal header. As a result, decode_socket_subcall/decode_ipc_subcall are provided and called disregarding of presence of these macros (they are defined as no-op in case macros are not defined) * MAX_NSYSCALLS is derived from nsyscalls, which, in turn, derived from size of array produced from inclusion of syscallent.h. As a result, all references to MAX_NSYSCALLS are replaced with get_nsyscalls(). * Reliance on qual_vec in qual_flags. New function get_qual() is defined and gual_flags is converted to functional macro which calls it providing current personality. This change passes tests on x86_64 and m32/x86_64, but surely needs additional testing (especially on different architectures) in case split of this sort proves itself useful. * Makefile.am(strace_SOURCES): Add multipers.c, multipers.h, qualify.c, qualify.h. * defs.h: Part of definitions moved to multipers.h. * multipers.c: New file. Contains parts of syscall.c related to support of multiple personalities. * multipers.h: New file. Contains parts of defs.h related to support of multiple personalities along with public interface of multipers.c (existing calls: set_personality, update_personality, decode_socket_subcall, decode_ipc_subcall; new calls: get_nsyscalls, *get_sysents). * qualify.c: New file. Contains parts of syscall.c related to entity tracing qualification. * qualify.h: New file. Contains public interface implemented in qualify.c (num_quals, qual_vec, get_qual, qualify). * strace.c: Include multipers.h and qualify.h. (print_signalled, print_stopped) Replace qual_flags array subscription with call. * syscall.c: Parts of definitions related to multiple personalities support and entity qualification moved to multipers.c and qualify.c, respectively. (decode_mips_subcall, dumpio, get_scno) Replace qual_flags array subscription with call. (trace_syscall_entering) Removing preprocessor checks around decode_socket_subcall/decode_ipc_subcall calls. --- Makefile.am |4 + defs.h | 196 +--- multipers.c | 380 +++ multipers.h | 215 ++ qualify.c | 231 qualify.h | 19 ++ strace.c|6 +- syscall.c | 580 +-- 8 files changed, 860 insertions(+), 771 deletions(-) create mode 100644 multipers.c create mode 100644 multipers.h create mode 100644 qualify.c create mode 100644 qualify.h diff --git a/Makefile.am b/Makefile.am index cb0bd92..4e94dce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -161,6 +161,8 @@ strace_SOURCES =\ msghdr.c\ msghdr.h\ mtd.c \ + multipers.c \ + multipers.h \ native_defs.h \ net.c \ netlink.c \ @@ -187,6 +189,8 @@ strace_SOURCES =\ process_vm.c\ ptp.c \ ptrace.h\ + qualify.c \ + qualify.h \ quota.c \ readahead.c \ readlink.c \ diff --git a/defs.h b/defs.h index eabce52..85c8e14 100644 --- a/defs.h +++ b/defs.h @@ -58,6 +58,7 @@ #include #include "mpers_type.h" +#include "multipers.h" #include "gcc_compat.h" #ifndef HAVE_STRERROR @@ -151,146 +152,6 @@ extern char *stpcpy(char *dst, const char *src); # define ERESTART_RESTARTBLOCK 516 #endif -#if defined(SPARC) || defined(SPARC64) -# define PERSONALITY0_WORDSIZE 4 -# if defined(SPARC64) -# define SUPPORTED_PERSONALITIES 2 -# define PERSONALITY1_WORDSIZE 8 -# ifdef HAVE_M32_MPERS -# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" -# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" -# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" -# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" -# endif -# endif -#endif - -#ifdef X86_64 -# define SUPPORTED_PERSONALITIES 3 -# define PERSONALITY0_WORDSIZE 8 -# define PERSONALITY1_WORDSIZE 4 -# define PERSONALITY2_WORDSIZE 4 -# ifdef HAVE_M32_MPERS -# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" -# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" -# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" -# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" -# endif -# ifdef HAVE_MX32_MPERS -# define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h" -# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h" -# define
[PATCH] Unify usage of include guards.
This commit is an attempt to unify usage of include guards (in top-level headers, at least). As a side note, different files with *.h extension have different semantics: for example, printargs.h is included multiple times in order to generate slightly varying code depending on values of macro definitions - maybe it's better to change extension of such files to *.inc or *.i. * defs.h: Add include guard. * flock.h: Likewise. * ipc_defs.h: Likewise. * mpers_type.h: Likewise. * printsiginfo.h: Likewise. * ptrace.h: Likewise. * regs.h: Likewise. * seccomp_fprog.h: Likewise. * gcc_compat.h: Include guard updated in order to have the same formatting as the others. * kernel_types.h: Likewise. * msghdr.h: Likewise. * sigevent.h: Likewise. * xlat.h: Add missing include guard definition. --- defs.h |5 + flock.h |5 + gcc_compat.h|6 +++--- ipc_defs.h |5 + kernel_types.h |5 ++--- mpers_type.h|5 + msghdr.h|6 +++--- printsiginfo.h |5 + ptrace.h|5 + regs.h |5 + seccomp_fprog.h |5 + sigevent.h |6 +++--- xlat.h |3 ++- 13 files changed, 53 insertions(+), 13 deletions(-) diff --git a/defs.h b/defs.h index bfe76e2..eabce52 100644 --- a/defs.h +++ b/defs.h @@ -27,6 +27,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef STRACE_DEFS_H +#define STRACE_DEFS_H + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -901,3 +904,5 @@ extern unsigned num_quals; #define PRI__d64 PRI__64"d" #define PRI__u64 PRI__64"u" #define PRI__x64 PRI__64"x" + +#endif /* #ifndef STRACE_DEFS_H */ diff --git a/flock.h b/flock.h index b1ab8ff..b438ea5 100644 --- a/flock.h +++ b/flock.h @@ -25,6 +25,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef STRACE_FLOCK_H +#define STRACE_FLOCK_H + #include #if defined HAVE_STRUCT_FLOCK @@ -42,3 +45,5 @@ typedef struct __kernel_flock64 struct_kernel_flock64; #else # error struct flock64 definition not found in #endif + +#endif /* #ifndef STRACE_FLOCK_H */ diff --git a/gcc_compat.h b/gcc_compat.h index c06d3c1..0f76fbb 100644 --- a/gcc_compat.h +++ b/gcc_compat.h @@ -25,8 +25,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCC_COMPAT_H_ -#define GCC_COMPAT_H_ +#ifndef STRACE_GCC_COMPAT_H +#define STRACE_GCC_COMPAT_H #if defined __GNUC__ && defined __GNUC_MINOR__ # define GNUC_PREREQ(maj, min) \ @@ -76,4 +76,4 @@ # define ATTRIBUTE_ALLOC_SIZE(args)/* empty */ #endif -#endif +#endif /* #ifndef STRACE_GCC_COMPAT_H */ diff --git a/ipc_defs.h b/ipc_defs.h index b6c85c1..0ece103 100644 --- a/ipc_defs.h +++ b/ipc_defs.h @@ -25,6 +25,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef STRACE_IPC_DEFS_H +#define STRACE_IPC_DEFS_H + #ifdef HAVE_SYS_IPC_H # include #elif defined HAVE_LINUX_IPC_H @@ -40,3 +43,5 @@ #define PRINTCTL(flagset, arg, dflt) \ if ((arg) & IPC_64) tprints("IPC_64|"); \ printxval((flagset), (arg) &~ IPC_64, dflt) + +#endif /* #ifndef STRACE_IPC_DEFS_H */ diff --git a/kernel_types.h b/kernel_types.h index 3dee761..47fbff4 100644 --- a/kernel_types.h +++ b/kernel_types.h @@ -26,8 +26,7 @@ */ #ifndef STRACE_KERNEL_TYPES_H - -# define STRACE_KERNEL_TYPES_H +#define STRACE_KERNEL_TYPES_H # if defined HAVE___KERNEL_LONG_T && defined HAVE___KERNEL_ULONG_T @@ -55,4 +54,4 @@ typedef struct { chard_name[1]; } kernel_dirent; -#endif +#endif /* #ifndef STRACE_KERNEL_TYPES_H */ diff --git a/mpers_type.h b/mpers_type.h index 4ce569b..f9bb2c5 100644 --- a/mpers_type.h +++ b/mpers_type.h @@ -26,6 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef STRACE_MPERS_TYPE_H +#define STRACE_MPERS_TYPE_H + #ifdef IN_MPERS # define STRINGIFY(a) #a # define DEF_MPERS_TYPE(args) STRINGIFY(args.h) @@ -45,3 +48,5 @@ # define MPERS_DEFS "native_defs.h" # endif #endif + +#endif /* #ifndef STRACE_MPERS_TYPE_H */ diff --git a/msghdr.h b/msghdr.h index 41a07d7..b56fe61 100644 --- a/msghdr.h +++ b/msghdr.h @@ -1,5 +1,5 @@ -#ifndef MSGHDR_H_ -# define MSGHDR_H_ +#ifndef STRACE_MSGHDR_H +#define STRACE_MSGHDR_H /* For definitions of struct msghdr and struct mmsghdr. */ # include @@ -14,4 +14,4 @@ struct mmsghdr { struct tcb; extern void print_struct_msghdr(struct tcb *, const struct msghdr *, const int *, unsigned long); -#endif /* MSGHDR_H_ */ +#endif /* #ifndef STRACE_MSGHDR_H */ diff --git a/printsiginfo.h b/printsiginfo.h index cb2d99d..f2dd62f 100644 --- a/printsiginfo.h +++ b/printsiginfo.h @@ -1 +1,6 @@ +#ifndef STRACE_PRINTSIGINFO_H +#define STRACE_PRINTSIGINFO_H + extern void printsiginfo(const siginfo_t *); + +#endif /* #ifndef STRACE_PRINTSIGINFO_H */ diff --git a/ptrace.h b/ptrace.h index 2e7d5e3..aba61b7 100644 --- a/ptrace.h +++ b/ptrace.h @@
Re: Feature request: coloured output
On Mon, Feb 6, 2017 at 3:41 PM, Philip Withnall <phi...@tecnocode.co.uk> wrote: > Hi, > > I’ve got a feature request for strace: optional coloured output, which > would use ANSI escape sequences (on supported terminals) to embolden > and colourise various bits of the strace output to make it easier to > read. Some suggestions for the highlighting: > • De-emphasise PIDs at the start of a line by putting them in grey > • Emphasise syscall names by emboldening them > • Emphasise error return values by colouring them red > > If piping through to another program, or running on a terminal which > doesn’t support them, the escape sequences should not be used. As it stands, implementation of this feature whould tackle quite an amount of code, since printing routines are spread accross decoders. It could be implemented partially for preamles, return codes and some types (like UIDs), but not for the structure field names and inline comments, for example. Personally, I would hope that the structured output conversion would be finalized and merged before the thermal death of the Universe, and see this feature being implemented there, since in this case code changes would be localised in the legacy formatter. Otherwise, it could be implemented partially (for some preamble bits and return values) now and decoder-related part later. > Thanks, > Philip > > (Please include me in CC in any replies, as I’m not subscribed to the > list.) > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel > -- Eugene Syromyatnikov mailto:evg...@gmail.com xmpp:esyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: GSOC : Introducing myself
On Sat, Feb 18, 2017 at 6:24 PM, Animesh Kashyap <annimesh2...@gmail.com> wrote: > > Are there any flags indicating "easy-to-fix" bugs or "minor" bugs that > I can get started with. That would be really helpful. Well, strace itself does not utilise bug tracker of any sort; bugs and suggestions usually reported via this mailing list (like suggestion [1], reported recently). You can try to have a look at lists of bugs related to strace packages in various distributions (like [2] or [3]), but these are mostly loosely related since they are reported against old versions and most of them are ususally reported upstream and fixed or get stale. [1] https://sourceforge.net/p/strace/mailman/message/35650550/ [2] https://bugs.debian.org/cgi-bin/pkgreport.cgi?dist=unstable;package=strace [3] https://bugzilla.redhat.com/buglist.cgi?component=strace_id=7101439=bug_status%2Cpriority%2Cbug_severity=Fedora_based_on=_format=advanced -- Eugene Syromyatnikov mailto:evg...@gmail.com xmpp:esyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: GSOC : Introducing myself
On Tue, Feb 21, 2017 at 11:24 AM, Animesh Kashyap <annimesh2...@gmail.com> wrote: > On Sun, Feb 19, 2017 at 12:20 AM, Eugene Syromyatnikov <evg...@gmail.com> > wrote: >> Well, strace itself does not utilise bug tracker of any sort; bugs and >> suggestions usually reported via this mailing list (like suggestion >> [1], reported recently). You can try to have a look at lists of bugs >> related to strace packages in various distributions (like [2] or [3]), >> but these are mostly loosely related since they are reported against >> old versions and most of them are ususally reported upstream and fixed >> or get stale. > > Hello, > > I read the resources provided and am reading the mailing list. I have > successfully cloned and built strace. There are two projects specified > on the wiki page : > "https://sourceforge.net/p/strace/wiki/GoogleSummerOfCode2017/; : Well, it's not projects in term "GSoC project ideas" (which are provided under "List of project ideas for students"), it's more like some potential areas which still need improvement and do not require much involment in order to tackle them, so they are deemed as a good place to start. > 1) Adding tests for better coverage > 2) Adding new classes for -e trace=class. Yes, that's correct. > Should I start working on one of these or is there some other small > feature that does not require much knowledge of internals of strace > that I should work on? I think I already mentioned [1], it requires some other knowledge (regarding ANSI terminals and terminfo/termcap, mostly), however. Overall, there is also vast field of work regarding support of various ioctl() calls, but it is difficult to recommend since it already requires some understanding of strace and kernel inner workings in order to be done right (from my point of view). [1] https://sourceforge.net/p/strace/mailman/message/35650550/ -- Eugene Syromyatnikov mailto:evg...@gmail.com xmpp:esyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: strace cant parse struct msghdr RHEL
ags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010}, >> MSG_WAITALL) = 4188 >> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL, >> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read >> (13250 < 20480) @0xff8bac3e: Input/output error >> 0x2ff8bac3e, msg_controllen=38647082208, >> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010}, >> 0) = 12 >> ./strace: Out of memory >> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL, >> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072, >> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010}, >> MSG_WAITALL) = 12 >> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL, >> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072, >> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010}, >> MSG_WAITALL) = 4188 >> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL, >> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read >> (13250 < 20480) @0xff8bac3e: Input/output error >> 0x2ff8bac3e, msg_controllen=38647082208, >> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010}, >> 0) = 12 >> ./strace: Out of memory >> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL, >> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072, >> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010}, >> MSG_WAITALL) = 4188 >> sendmsg(8, {msg_name=NULL, msg_namelen=-7631616, msg_iov=NULL, >> msg_iovlen=10, msg_control=[{cmsg_len=17920, cmsg_level=SOL_IP, >> cmsg_type=0x8d00 /* IP_??? */}, {cmsg_len=3158845, >> cmsg_level=0x5f534d4e /* SOL_??? */, cmsg_type=0x4e5f534f}, ...], >> msg_controllen=300847264664, >> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_DONTWAIT|MSG_EOR|MSG_SYN|MSG_CONFIRM|MSG_MORE|0xff8b0010}, >> 0) = 74 >> sendmsg(8, {msg_name=NULL, msg_namelen=-7631504, msg_iov=NULL, >> msg_iovlen=29510720283184520, msg_control=[{cmsg_len=2048, >> cmsg_level=SOL_IP, cmsg_type=0x8d70 /* IP_??? */}, >> {cmsg_len=3971745833, cmsg_level=0x7ff00bc7 /* SOL_??? */, >> cmsg_type=0xbda}, ...], msg_controllen=38647074288, >> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_DONTWAIT|MSG_WAITALL|MSG_SYN|MSG_CONFIRM|MSG_MORE|0xff8b}, >> 0) = 12 >> ./strace: Out of memory >> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL, >> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read >> (13250 < 20480) @0xff8bac3e: Input/output error >> 0x2ff8bac3e, msg_controllen=38647082208, >> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010}, >> 0) = 12 >> ./strace: Out of memory > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene Syromyatnikov mailto:evg...@gmail.com xmpp:esyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH] Move SH-specific argument number calculation to getllval
This change prevents scattering of ll-related hacks and simplifies pread/pwrite syscalls parsers' logic a bit. * util.c (getllval): Add fixup for arg_no for SuperH when argument number is equal to 3 (see comment). * io.c (PREAD_OFFSET_ARG): Macro removed. (SYS_FUNC(pread)): Always use argument number 3 for "count" argument printing. (SYS_FUNC(pwrite)): Likewise. --- io.c | 15 ++- util.c | 12 +++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/io.c b/io.c index 58323a7..ee84973 100644 --- a/io.c +++ b/io.c @@ -150,17 +150,6 @@ SYS_FUNC(writev) return RVAL_DECODED; } -/* The SH4 ABI does allow long longs in odd-numbered registers, but - does not allow them to be split between registers and memory - and - there are only four argument registers for normal functions. As a - result pread takes an extra padding argument before the offset. This - was changed late in the 2.4 series (around 2.4.20). */ -#if defined(SH) -#define PREAD_OFFSET_ARG 4 -#else -#define PREAD_OFFSET_ARG 3 -#endif - SYS_FUNC(pread) { if (entering(tcp)) { @@ -172,7 +161,7 @@ SYS_FUNC(pread) else printstr(tcp, tcp->u_arg[1], tcp->u_rval); tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%lld", PREAD_OFFSET_ARG); + printllval(tcp, "%lld", 3); } return 0; } @@ -183,7 +172,7 @@ SYS_FUNC(pwrite) tprints(", "); printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%lld", PREAD_OFFSET_ARG); + printllval(tcp, "%lld", 3); return RVAL_DECODED; } diff --git a/util.c b/util.c index afa3290..ea67606 100644 --- a/util.c +++ b/util.c @@ -275,7 +275,17 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no) defined XTENSA /* Align arg_no to the next even number. */ arg_no = (arg_no + 1) & 0xe; -# endif +# elif defined SH + /* The SH4 ABI does allow long longs in odd-numbered registers, but + does not allow them to be split between registers and memory - and + there are only four argument registers for normal functions. As a + result, pread, for example, takes an extra padding argument before + the offset. This was changed late in the 2.4 series (around 2.4.20). +*/ + if (arg_no == 3) + arg_no++; +# endif /* defined __ARM_EABI__ || defined LINUX_MIPSO32 || defined POWERPC || + defined XTENSA || defined SH */ *val = LONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]); arg_no += 2; #endif -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/2] Fix old_value argument retrieval in timerfd_settime parser
This is done similar to timer_settime syscall parser. * time.c (SYS_FUNC(timerfd_settime)): retrieve old_value argument on exiting and not on entering. Return 0 instead of RVAL_DECODED (since call hasn't been decoded in full on entering). --- time.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/time.c b/time.c index 963d0ea..b32eddf 100644 --- a/time.c +++ b/time.c @@ -314,15 +314,17 @@ SYS_FUNC(timerfd_create) SYS_FUNC(timerfd_settime) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); - tprints(", "); - print_itimerspec(tcp, tcp->u_arg[2]); - tprints(", "); - print_itimerspec(tcp, tcp->u_arg[3]); - - return RVAL_DECODED; + if (entering(tcp)) { + printfd(tcp, tcp->u_arg[0]); + tprints(", "); + printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); + tprints(", "); + print_itimerspec(tcp, tcp->u_arg[2]); + tprints(", "); + } else { + print_itimerspec(tcp, tcp->u_arg[3]); + } + return 0; } SYS_FUNC(timerfd_gettime) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/2] Minor bug in timerfd_settime parser
Hello. I've stumbled upon a subtle bug in timerfd_settime parser - it retrieves old_value argument on entering and not on exiting. Turns out it hasn't been noticed by timerfd_xettime test since it fills old_value argument buffer with exactly the same values as returned by the call (more precisely, it doesn't specify any values so it is filled with zeroes, which are obviously returned by the first timerfd_settime call). Upon investigation, it is revealed that timer_xettime test follows the same pattern. As a result, the following patch set consists of two patches - first one updates tests and second one fixes the aforementioned problem. Eugene Syromyatnikov (2): Fill old_value argument in timer{,fd}_xettime tests Fix old_value argument retrieval in timerfd_settime parser tests/timer_xettime.c |4 tests/timerfd_xettime.c |4 time.c | 20 +++- 3 files changed, 19 insertions(+), 9 deletions(-) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/2] Test and minor printf format fix for the readahead syscall
Hello. There is some initial implementation of readahead syscall decoder test. While it is implemented, it has been noticed that incorrect format is used for printing "count" argument. Eugene Syromyatnikov (2): readahead: Fix print format for the "count" argument tests: check decoding of readahead syscall readahead.c |2 +- tests/.gitignore |1 + tests/Makefile.am|2 ++ tests/readahead.c| 63 ++ tests/readahead.test |6 + 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/2] tests: check decoding of readahead syscall
* tests/readahead.c: New file. * tests/readahead.test: New test. * tests/.gitignore: Add readahead. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add readahead.test. --- Simple test for simple decoder. tests/.gitignore |1 + tests/Makefile.am|2 ++ tests/readahead.c| 63 ++ tests/readahead.test |6 + 4 files changed, 72 insertions(+) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test diff --git a/tests/.gitignore b/tests/.gitignore index 5c5d092..8c41bea 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -185,6 +185,7 @@ pselect6 ptrace pwritev read-write +readahead readdir readlink readlinkat diff --git a/tests/Makefile.am b/tests/Makefile.am index b879bf4..d7421fc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -241,6 +241,7 @@ check_PROGRAMS = \ ptrace \ pwritev \ read-write \ + readahead \ readdir \ readlink \ readlinkat \ @@ -568,6 +569,7 @@ DECODER_TESTS = \ ptrace.test \ pwritev.test \ read-write.test \ + readahead.test \ readdir.test \ readlink.test \ readlinkat.test \ diff --git a/tests/readahead.c b/tests/readahead.c new file mode 100644 index 000..307dbff --- /dev/null +++ b/tests/readahead.c @@ -0,0 +1,63 @@ +#include "tests.h" +#include + +#ifdef __NR_readahead + +# include +# include + +static const int fds[] = { + -0x8000, + -100, + -1, + 0, + 1, + 2, + 0x7fff, +}; + +static const off64_t offsets[] = { + -0x8000LL, + -0x5060708090a0b0c0LL, + -1LL, +0, +1, +0xbadfaced, +0x7fffLL, +}; + +static const unsigned long counts[] = { + 0UL, + 0xdeadca75, + (unsigned long)0xface1e55beeff00dULL, + (unsigned long)0xULL, +}; + +int +main(void) +{ + unsigned i; + unsigned j; + unsigned k; + ssize_t rc; + + for (i = 0; i < ARRAY_SIZE(fds); i++) + for (j = 0; j < ARRAY_SIZE(offsets); j++) + for (k = 0; k < ARRAY_SIZE(counts); k++) { + rc = readahead(fds[i], offsets[j], counts[k]); + + printf("readahead(%d, %lld, %lu) = " + "%ld %s (%m)\n", fds[i], + (long long)offsets[j], counts[k], rc, + errno2name()); + } + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_readahead") + +#endif diff --git a/tests/readahead.test b/tests/readahead.test new file mode 100755 index 000..397c690 --- /dev/null +++ b/tests/readahead.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check readahead syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a1 -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH] Makefile.am: use readlink as a fallback for realpath
Since realpath utility is fairly new in GNU coreutils, there could be possibility that it is not present in the system. Instead of checking its presence in configure script it probably makes sense to resort to calling readlink since it is (probably) more widespread. --- Makefile.am |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 65f5c64..b77c2e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -256,7 +256,8 @@ endif @CODE_COVERAGE_RULES@ CODE_COVERAGE_BRANCH_COVERAGE = 1 CODE_COVERAGE_GENHTML_OPTIONS = $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) \ - --prefix $(shell realpath -Ls $(abs_top_srcdir)/..) + --prefix $(shell realpath -Ls $(abs_top_srcdir)/.. || \ + readlink -f $(abs_top_srcdir)/..) CODE_COVERAGE_IGNORE_PATTERN = '/usr/include/*' strace_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) strace_CFLAGS += $(CODE_COVERAGE_CFLAGS) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 3/5] tests/futex: Add support for return codes other than 0 and -1 to sprintrc
* tests/futex.c (sprintrc): Print the actual return code provided, not just "0"; checks for snprintf return code added. --- tests/futex.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/futex.c b/tests/futex.c index 28d9df8..09a6c25 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -150,7 +150,15 @@ const char *sprintrc(long rc) if (rc == 0) return "0"; - snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()); + int ret = (rc == -1) + ? snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()) + : snprintf(buf, sizeof(buf), "%ld", rc); + + if (ret < 0) + perror_msg_and_fail("snprintf"); + if ((size_t) ret >= sizeof(buf)) + error_msg_and_fail("snprintf overflow: got %d, expected " + "no more than %zu", ret, sizeof(buf)); return buf; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 1/5] tests/futex: Rename retstr to sprintrc
* tests/futex.c (retstr): Rename to sprintstr, (main): Convert all retstr calls to sprintrc. --- tests/futex.c | 88 + 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/tests/futex.c b/tests/futex.c index dfdf68d..fe3741a 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -143,7 +143,7 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) printf(") = -1 ENOSYS (%m)\n"); } -const char *retstr(int rc) +const char *sprintrc(long rc) { enum { RES_BUF_SIZE = 256 }; static char buf[RES_BUF_SIZE]; @@ -204,34 +204,34 @@ main(int argc, char *argv[]) (rc == -1) && (errno == EFAULT)); printf("futex(NULL, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", VAL_PR, (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, - retstr(rc)); + sprintrc(rc)); /* uaddr is faulty */ CHECK_FUTEX(uaddr + 1, FUTEX_WAIT, VAL, tmout, uaddr2, VAL3, (rc == -1) && (errno == EFAULT)); printf("futex(%p, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", uaddr + 1, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* timeout is faulty */ CHECK_FUTEX(uaddr, FUTEX_WAIT, VAL, tmout + 1, uaddr2, VAL3, (rc == -1) && (errno == EFAULT)); printf("futex(%p, FUTEX_WAIT, %u, %p) = %s\n", - uaddr, 0xfacefeed, tmout + 1, retstr(rc)); + uaddr, 0xfacefeed, tmout + 1, sprintrc(rc)); /* uaddr is not as provided; uaddr2 is faulty but ignored */ CHECK_FUTEX(uaddr, FUTEX_WAIT, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* uaddr is not as provided; uaddr2 is faulty but ignored */ CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_WAIT, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_PRIVATE, %u, {%jd, %jd}) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* Next 2 tests are with CLOCKRT bit set */ @@ -241,14 +241,16 @@ main(int argc, char *argv[]) VAL, tmout, uaddr2, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT|FUTEX_CLOCK_REALTIME, %u, " "{%jd, %jd}) = %s\n", uaddr, VAL_PR, - (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, + sprintrc(rc)); CHECK_FUTEX_ENOSYS(uaddr, FUTEX_CLOCK_REALTIME | FUTEX_PRIVATE_FLAG | FUTEX_WAIT , VAL, tmout, uaddr2, 0, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME, %u, " "{%jd, %jd}) = %s\n", uaddr, VAL_PR, - (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, + sprintrc(rc)); /* FUTEX_WAIT_BITSET - FUTEX_WAIT which provides additional bitmask * which should be matched at least in one bit with @@ -266,20 +268,20 @@ main(int argc, char *argv[]) VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_BITSET, %u, {%jd, %jd}, %#x) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, VAL3_PR, retstr(rc)); + (intmax_t)tmout->tv_nsec, VAL3_PR, sprintrc(rc)); /* val3 of 0 is invalid */ CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1, 0, (rc == -1) && (errno == EINVAL)); printf("futex(%p, FUTEX_WAIT_BITSET, %u, {%jd, %jd}, %#x) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, 0, retstr(rc)); + (intmax_t)tmout->tv_nsec, 0, sprintrc(rc)); CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_BITSET_PRIVATE, %u, {%jd, %jd}, %#x) = " "%s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, VAL3_PR, retstr(rc)); + (intmax_t)tmout->tv_nsec, VAL3_PR, sprintrc(rc)); /* Next 3 tests are with CLOCKRT bit set */ @@ -288,7 +290,7 @@ main(int argc, char *argv[]) printf("futex(%p,
[PATCH v2 2/5] tests/futex: Increase static sprintrc buffer size
* tests/futex.c (sprintrc) : Value increased from 256 to 4096. --- tests/futex.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/futex.c b/tests/futex.c index fe3741a..28d9df8 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -145,8 +145,7 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) const char *sprintrc(long rc) { - enum { RES_BUF_SIZE = 256 }; - static char buf[RES_BUF_SIZE]; + static char buf[4096]; if (rc == 0) return "0"; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 4/5] tests: Move return code printing into a separate file
* tests/tests.h: Add sprintrc declaration. * tests/futex.c (sprintrc): Remove. * tests/sprintrc.c: New file. * tests/Makefile.am (libtests_a_SOURCES): Add sprintrc.c. --- tests/Makefile.am |1 + tests/futex.c | 20 tests/sprintrc.c | 33 + tests/tests.h |3 +++ 4 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 tests/sprintrc.c diff --git a/tests/Makefile.am b/tests/Makefile.am index b879bf4..2cf9674 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -54,6 +54,7 @@ libtests_a_SOURCES = \ printflags.c \ printxval.c \ signal2name.c \ + sprintrc.c \ tail_alloc.c \ tests.h \ tprintf.c \ diff --git a/tests/futex.c b/tests/futex.c index 09a6c25..63669d2 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -143,26 +143,6 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) printf(") = -1 ENOSYS (%m)\n"); } -const char *sprintrc(long rc) -{ - static char buf[4096]; - - if (rc == 0) - return "0"; - - int ret = (rc == -1) - ? snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()) - : snprintf(buf, sizeof(buf), "%ld", rc); - - if (ret < 0) - perror_msg_and_fail("snprintf"); - if ((size_t) ret >= sizeof(buf)) - error_msg_and_fail("snprintf overflow: got %d, expected " - "no more than %zu", ret, sizeof(buf)); - - return buf; -} - # define CHECK_INVALID_CLOCKRT(op, ...) \ do { \ invalid_op(uaddr, FUTEX_CLOCK_REALTIME | (op), __VA_ARGS__); \ diff --git a/tests/sprintrc.c b/tests/sprintrc.c new file mode 100644 index 000..a12dc24 --- /dev/null +++ b/tests/sprintrc.c @@ -0,0 +1,33 @@ +#include "tests.h" + +#include +#include + +/** + * Provides pointer to static string buffer with printed return code in format + * used by strace - with errno and error message. + * + * @param rc Return code. + * @return Pointer to (statically allocated) buffer containing decimal + * representation of return code and errno/error message in case @rc + * is equal to -1. + */ +const char *sprintrc(long rc) +{ + static char buf[4096]; + + if (rc == 0) + return "0"; + + int ret = (rc == -1) + ? snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()) + : snprintf(buf, sizeof(buf), "%ld", rc); + + if (ret < 0) + perror_msg_and_fail("snprintf"); + if ((size_t) ret >= sizeof(buf)) + error_msg_and_fail("snprintf overflow: got %d, expected " + "no more than %zu", ret, sizeof(buf)); + + return buf; +} diff --git a/tests/tests.h b/tests/tests.h index 81abe82..3043f97 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -99,6 +99,9 @@ const char *errno2name(void); /* Translate signal number to its name. */ const char *signal2name(int); +/* Print return code and, in case return code is -1, errno information. */ +const char *sprintrc(long rc); + struct xlat; /* Print flags in symbolic form according to xlat table. */ -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 5/5] tests: check decoding of readahead syscall
* tests/readahead.c: New file. * tests/readahead.test: New test. * tests/.gitignore: Add readahead. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add readahead.test. --- tests/.gitignore |1 + tests/Makefile.am|2 ++ tests/readahead.c| 62 ++ tests/readahead.test |6 + 4 files changed, 71 insertions(+) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test diff --git a/tests/.gitignore b/tests/.gitignore index 5c5d092..8c41bea 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -185,6 +185,7 @@ pselect6 ptrace pwritev read-write +readahead readdir readlink readlinkat diff --git a/tests/Makefile.am b/tests/Makefile.am index 2cf9674..0b3b818 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -242,6 +242,7 @@ check_PROGRAMS = \ ptrace \ pwritev \ read-write \ + readahead \ readdir \ readlink \ readlinkat \ @@ -569,6 +570,7 @@ DECODER_TESTS = \ ptrace.test \ pwritev.test \ read-write.test \ + readahead.test \ readdir.test \ readlink.test \ readlinkat.test \ diff --git a/tests/readahead.c b/tests/readahead.c new file mode 100644 index 000..e58fcac --- /dev/null +++ b/tests/readahead.c @@ -0,0 +1,62 @@ +#include "tests.h" +#include + +#ifdef __NR_readahead + +# include +# include + +static const int fds[] = { + -0x8000, + -100, + -1, + 0, + 1, + 2, + 0x7fff, +}; + +static const off64_t offsets[] = { + -0x8000LL, + -0x5060708090a0b0c0LL, + -1LL, +0, +1, +0xbadfaced, +0x7fffLL, +}; + +static const unsigned long counts[] = { + 0UL, + 0xdeadca75, + (unsigned long)0xface1e55beeff00dULL, + (unsigned long)0xULL, +}; + +int +main(void) +{ + unsigned i; + unsigned j; + unsigned k; + ssize_t rc; + + for (i = 0; i < ARRAY_SIZE(fds); i++) + for (j = 0; j < ARRAY_SIZE(offsets); j++) + for (k = 0; k < ARRAY_SIZE(counts); k++) { + rc = readahead(fds[i], offsets[j], counts[k]); + + printf("readahead(%d, %lld, %lu) = %s\n", + fds[i], (long long)offsets[j], + counts[k], sprintrc(rc)); + } + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_readahead") + +#endif diff --git a/tests/readahead.test b/tests/readahead.test new file mode 100755 index 000..397c690 --- /dev/null +++ b/tests/readahead.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check readahead syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a1 -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2] tests: Some additional aio checks
* aio.c: Additional checks added. --- Changes since v1: * All io_submit checks now use long as second argument, last io_submit check now always passes positive nr value. * Additional decoder checks reworked a bit in order to increase coverage. tests/aio.c | 137 +++ 1 file changed, 137 insertions(+) diff --git a/tests/aio.c b/tests/aio.c index 8c5bfa7..11c4913 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -111,6 +111,53 @@ main(void) }; const struct iocb *cbv = tail_memdup(proto_cbv, sizeof(proto_cbv)); + /* For additional decoder testing */ + const struct iocb proto_cbv2[] = { + { + .aio_data = 0xbadfacedc0ffeeed, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 0xf00d, + .aio_reqprio = 0, + .aio_fildes = 0xdefaced1, + .aio_buf = 0, + }, + { + .aio_data = 0, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 1, + .aio_reqprio = 0xbeef, + .aio_fildes = 0xdefaced1, + .aio_buf = 0, + .aio_nbytes = 0x1020304050607080, + .aio_offset = 0xdeadda7abadc0ded, +# ifdef IOCB_FLAG_RESFD + .aio_flags = 0xfacef157, + .aio_resfd = 0xded1ca7e, +# endif + }, + { + .aio_data = 0, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 1, + .aio_reqprio = 0xbeef, + .aio_fildes = 0xdefaced1, + .aio_buf = 0xbadc0ffeedefaced, + .aio_nbytes = 0x8090a0b0c0d0e0f0, + .aio_offset = 0xdeadda7abadc0ded, + }, + { + .aio_data = 0, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 8, + .aio_reqprio = 0xbeef, + .aio_fildes = 0xdefaced1, + .aio_buf = 0, + .aio_nbytes = 0x8090a0b0c0d0e0f0, + .aio_offset = 0xdeadda7abadc0ded, + }, + }; + const struct iocb *cbv2 = tail_memdup(proto_cbv2, sizeof(proto_cbv2)); + const struct iocb proto_cbc = { .aio_data = 0xdeadbeefbadc0ded, .aio_reqprio = 99, @@ -128,6 +175,13 @@ main(void) }; const long *cbvs = tail_memdup(proto_cbvs, sizeof(proto_cbvs)); + const long proto_cbvs2[] = { + (long) [0], (long) [1], + (long) [2], (long) [3], + (long) NULL, (long) 0xdeadc0dedeadda7a, + }; + const long *cbvs2 = tail_memdup(proto_cbvs2, sizeof(proto_cbvs2)); + unsigned long *ctx = tail_alloc(sizeof(unsigned long)); *ctx = 0; @@ -142,10 +196,26 @@ main(void) if (open("/dev/zero", O_RDONLY)) perror_msg_and_skip("open: %s", "/dev/zero"); + assert(syscall(__NR_io_setup, 0xdeadbeef, NULL) == -1); + printf("io_setup(%u, NULL) = %s\n", 0xdeadbeef, sprintrc(-1)); + + assert(syscall(__NR_io_setup, lnr, ctx + 1) == -1); + printf("io_setup(%u, %p) = %s\n", nr, ctx + 1, sprintrc(-1)); + if (syscall(__NR_io_setup, lnr, ctx)) perror_msg_and_skip("io_setup"); printf("io_setup(%u, [%lu]) = 0\n", nr, *ctx); + assert(syscall(__NR_io_submit, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, NULL) == -1); + printf("io_submit(%lu, %ld, NULL) = %s\n", + (aio_context_t) 0xface1e55deadbeef, (long) 0xca7faceddeadf00d, + sprintrc(-1)); + + assert(syscall(__NR_io_submit, *ctx, nr, cbs + nr) == -1); + printf("io_submit(%lu, %ld, %p) = %s\n", + *ctx, (long)nr, cbs + nr, sprintrc(-1)); + assert(syscall(__NR_io_submit, *ctx, -1L, cbs) == -1); printf("io_submit(%lu, -1, %p) = %s\n", *ctx, cbs, sprintrc(-1)); @@ -165,6 +235,22 @@ main(void) sizeof_data1, (long long) cb[1].aio_offset, nr); + assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, ev + 1, + NULL) == -1); + printf("io_getevents(%lu, %ld, %ld, %p, NULL) = %s\n", + (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, + ev + 1, sprintrc(-1)); + + assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, NULL, + ts + 1) == -1); +
[PATCH v2] Makefile.am: use dirname as a fallback for realpath
Since realpath utility is fairly new in GNU coreutils, there could be possibility that it is not present in the system. Instead of checking its presence in configure script it probably makes sense to fall back to dirname call since it is more widespread. Initial implementation utilized readlink instead of dirname; changed as per Dmitry Levin's suggestion. --- Changes from v1: * dirname has been utilized instead of readlink. Makefile.am |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 65f5c64..91733bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -256,7 +256,8 @@ endif @CODE_COVERAGE_RULES@ CODE_COVERAGE_BRANCH_COVERAGE = 1 CODE_COVERAGE_GENHTML_OPTIONS = $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) \ - --prefix $(shell realpath -Ls $(abs_top_srcdir)/..) + --prefix $(shell realpath -Ls $(abs_top_srcdir)/.. || \ + dirname $(abs_top_srcdir)) CODE_COVERAGE_IGNORE_PATTERN = '/usr/include/*' strace_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) strace_CFLAGS += $(CODE_COVERAGE_CFLAGS) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 3/7] tests: Add sprintrc_grep function
sprintrc_grep function is sprintrc function equivalent suitable for tests where grep-base pattern matching is employed. * tests/sprintrc.c (enum sprintrc_fmt): New sprintrc format enumeration. (sprintrc_ex): New function, renamed from sprintrc with updates regarding support of different formats. (sprintrc): Calls sprintrc_ex with SPRINTRC_FMT_RAW. (sprintrc_grep): Calls sprintrc_ex with SPRINTRC_FMT_GREP. * tests/tests.h: sprintrc_grep declaration added. --- tests/sprintrc.c | 41 ++--- tests/tests.h|2 ++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/sprintrc.c b/tests/sprintrc.c index 5e27680..a573a27 100644 --- a/tests/sprintrc.c +++ b/tests/sprintrc.c @@ -28,25 +28,40 @@ #include "tests.h" #include +enum sprintrc_fmt { + SPRINTRC_FMT_RAW, + SPRINTRC_FMT_GREP, +}; + /** * Provides pointer to static string buffer with printed return code in format * used by strace - with errno and error message. * - * @param rc Return code. - * @return Pointer to (statically allocated) buffer containing decimal - * representation of return code and errno/error message in case @rc - * is equal to -1. + * @param rc Return code. + * @param fmt Output format. Currently, raw (used for diff matching) and grep + *(for extended POSIX regex-based pattern matching) formats are + *supported. + * @returnPointer to (statically allocated) buffer containing decimal + *representation of return code and errno/error message in case @rc + *is equal to -1. */ -const char * -sprintrc(long rc) +static inline const char * +sprintrc_ex(long rc, enum sprintrc_fmt fmt) { + static const char *formats[] = { + [SPRINTRC_FMT_RAW] = "-1 %s (%m)", + [SPRINTRC_FMT_GREP] = "-1 %s \\(%m\\)", + }; static char buf[4096]; + if (fmt >= ARRAY_SIZE(formats)) + perror_msg_and_fail("sprintrc_ex: incorrect format provided"); + if (rc == 0) return "0"; int ret = (rc == -1) - ? snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()) + ? snprintf(buf, sizeof(buf), formats[fmt], errno2name()) : snprintf(buf, sizeof(buf), "%ld", rc); if (ret < 0) @@ -57,3 +72,15 @@ sprintrc(long rc) return buf; } + +const char * +sprintrc(long rc) +{ + return sprintrc_ex(rc, SPRINTRC_FMT_RAW); +} + +const char * +sprintrc_grep(long rc) +{ + return sprintrc_ex(rc, SPRINTRC_FMT_GREP); +} diff --git a/tests/tests.h b/tests/tests.h index 3043f97..2599120 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -101,6 +101,8 @@ const char *signal2name(int); /* Print return code and, in case return code is -1, errno information. */ const char *sprintrc(long rc); +/* sprintrc variant suitable for usage as part of grep pattern. */ +const char *sprintrc_grep(long rc); struct xlat; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/7] tests: Perform more strict structure allocation in sched_xetattr test
tail_alloc with precise size of the structure is used now. * tests/sched_xetattr.c: Eliminate usage of anonymous union type; rename sched to sched_attr; change type of sched_attr to struct pointer; use tail_alloc for sched_attr allocation; update printf statements accrodingly. --- tests/sched_xetattr.c | 58 - 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index b982cca..e85f9bc 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -37,50 +37,48 @@ int main(void) { - static union { - struct { - uint32_t size; - uint32_t sched_policy; - uint64_t sched_flags; - uint32_t sched_nice; - uint32_t sched_priority; - uint64_t sched_runtime; - uint64_t sched_deadline; - uint64_t sched_period; - } attr; - char buf[256]; - } sched; + struct { + uint32_t size; + uint32_t sched_policy; + uint64_t sched_flags; + uint32_t sched_nice; + uint32_t sched_priority; + uint64_t sched_runtime; + uint64_t sched_deadline; + uint64_t sched_period; + } *sched_attr = tail_alloc(sizeof(*sched_attr)); - if (syscall(__NR_sched_getattr, 0, , sizeof(sched), 0)) + if (syscall(__NR_sched_getattr, 0, sched_attr, sizeof(*sched_attr), 0)) perror_msg_and_skip("sched_getattr"); printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " "sched_flags=%s, sched_nice=%u, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " - "sched_period=%" PRIu64 "\\}, 256, 0\\) += 0\n", - sched.attr.size, - sched.attr.sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0", - sched.attr.sched_nice, - sched.attr.sched_priority, - sched.attr.sched_runtime, - sched.attr.sched_deadline, - sched.attr.sched_period); + "sched_period=%" PRIu64 "\\}, %zu, 0\\) += 0\n", + sched_attr->size, + sched_attr->sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0", + sched_attr->sched_nice, + sched_attr->sched_priority, + sched_attr->sched_runtime, + sched_attr->sched_deadline, + sched_attr->sched_period, + sizeof(*sched_attr)); - sched.attr.sched_flags |= 1; - if (syscall(__NR_sched_setattr, 0, , 0)) + sched_attr->sched_flags |= 1; + if (syscall(__NR_sched_setattr, 0, sched_attr, 0)) perror_msg_and_skip("sched_setattr"); printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " "sched_flags=%s, sched_nice=%u, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " "sched_period=%" PRIu64 "\\}, 0\\) += 0\n", - sched.attr.size, + sched_attr->size, "SCHED_FLAG_RESET_ON_FORK", - sched.attr.sched_nice, - sched.attr.sched_priority, - sched.attr.sched_runtime, - sched.attr.sched_deadline, - sched.attr.sched_period); + sched_attr->sched_nice, + sched_attr->sched_priority, + sched_attr->sched_runtime, + sched_attr->sched_deadline, + sched_attr->sched_period); return 0; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/7] Minor tests tweaks pt. 2
Hello. This time, mostly sched_xetattr tweaks. Another notable changes are new sprintrc_grep function and additional shmget check. Eugene Syromyatnikov (7): tests: Split long lines in sched_xetattr test tests: Perform more strict structure allocation in sched_xetattr test tests: Add sprintrc_grep function tests: Additional shmget decoder checks tests: Change type of sched_nice field to signed in sched_xetattr test tests: Print size argument of sched_setattr as unsigned tests: Additional sched_getattr/sched_setattr decoder checks tests/ipc_shm.c | 20 + tests/sched_xetattr.c | 113 ++--- tests/sprintrc.c | 41 +++--- tests/tests.h |2 + 4 files changed, 136 insertions(+), 40 deletions(-) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 4/7] tests: Additional shmget decoder checks
* tests/ipc_shm.c: Additional checks for shmget syscall decoding. --- tests/ipc_shm.c | 20 1 file changed, 20 insertions(+) diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c index 54723e2..80a8f0f 100644 --- a/tests/ipc_shm.c +++ b/tests/ipc_shm.c @@ -27,11 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include +#include "xlat.h" +#include "xlat/shm_resource_flags.h" + static int id = -1; static void @@ -45,9 +49,25 @@ cleanup(void) int main(void) { + static const key_t bogus_key = (key_t)0xeca86420fdb97531LLU; + static const size_t bogus_size = 0xdec0ded1dec0ded2LLU; + static const int bogus_flags = 0xface1e55; + int rc; struct shmid_ds ds; + assert(shmget(bogus_key, bogus_size, bogus_flags) == -1); + printf("shmget\\(%#lx, %lu, %s%s%s%#x\\|%#04o\\) += %s\n", + (unsigned long)((sizeof(key_t) == sizeof(int)) ? + (unsigned)bogus_key : (unsigned long)bogus_key), + bogus_size, + IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "", + IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "", + SHM_HUGETLB & bogus_flags ? "SHM_HUGETLB\\|" : "", + bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | SHM_HUGETLB), + bogus_flags & 0777, + sprintrc_grep(-1)); + id = shmget(IPC_PRIVATE, 1, 0600); if (id < 0) perror_msg_and_skip("shmget"); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 7/7] tests: Additional sched_getattr/sched_setattr decoder checks
* tests/sched_xetattr.c: Additional checs for sched_getattr and sched_setattr decoding. --- tests/sched_xetattr.c | 43 +++ 1 file changed, 43 insertions(+) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index 9ff8c72..ce5c417 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -30,6 +30,7 @@ #if defined __NR_sched_getattr && defined __NR_sched_setattr +# include # include # include # include @@ -48,6 +49,21 @@ main(void) uint64_t sched_period; } *sched_attr = tail_alloc(sizeof(*sched_attr)); + assert(syscall(__NR_sched_getattr, 0xdeadface, NULL, 0, 0) == -1); + printf("sched_getattr\\(%d, NULL, 0, 0\\) += %s\n", + 0xdeadface, sprintrc_grep(-1)); + + assert(syscall(__NR_sched_getattr, -1, sched_attr, 0xbadfaced, + 0xc0defeed) == -1); + printf("sched_getattr\\(-1, %p, %u, %u\\) += %s\n", + sched_attr, 0xbadfaced, 0xc0defeed, sprintrc_grep(-1)); + + assert(syscall(__NR_sched_getattr, 0, sched_attr + 1, + sizeof(*sched_attr), 0) == -1); + printf("sched_getattr\\(0, %p, %u, 0\\) += %s\n", + sched_attr + 1, (unsigned)sizeof(*sched_attr), + sprintrc_grep(-1)); + if (syscall(__NR_sched_getattr, 0, sched_attr, sizeof(*sched_attr), 0)) perror_msg_and_skip("sched_getattr"); @@ -80,6 +96,33 @@ main(void) sched_attr->sched_deadline, sched_attr->sched_period); + sched_attr->size = 0x90807060; + sched_attr->sched_policy = 0xca7faced; + sched_attr->sched_flags = 0xbadc0ded1057da7aULL; + sched_attr->sched_nice = 0xafbfcfdf; + sched_attr->sched_priority = 0xb8c8d8e8; + sched_attr->sched_runtime = 0xbadcaffedeadf157ULL; + sched_attr->sched_deadline = 0xc0de70a57badac75ULL; + sched_attr->sched_period = 0xded1ca7edda7aca7ULL; + + assert(syscall(__NR_sched_setattr, 0xfacec0de, sched_attr, + 0xbeeff00d) == -1); + + printf("sched_setattr\\(%d, \\{size=%u, " + "sched_policy=%#x /\\* SCHED_\\?\\?\\? \\*/, " + "sched_flags=%#" PRIx64 " /\\* SCHED_FLAG_\\?\\?\\? \\*/, " + "sched_nice=%d, sched_priority=%u, sched_runtime=%" PRIu64 ", " + "sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, " + "%u\\) += %s\n", + 0xfacec0de, sched_attr->size, + sched_attr->sched_policy, + sched_attr->sched_flags, + sched_attr->sched_nice, + sched_attr->sched_priority, + sched_attr->sched_runtime, + sched_attr->sched_deadline, + sched_attr->sched_period, 0xbeeff00d, sprintrc_grep(-1)); + return 0; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 6/7] tests: Print size argument of sched_setattr as unsigned
Since it is how it is declared. * tests/sched_xetattr.c: Cast size of struct sched_attr to unsigned, update format specifier accordingly. --- tests/sched_xetattr.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index 2e0ce61..9ff8c72 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -54,7 +54,7 @@ main(void) printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " - "sched_period=%" PRIu64 "\\}, %zu, 0\\) += 0\n", + "sched_period=%" PRIu64 "\\}, %u, 0\\) += 0\n", sched_attr->size, sched_attr->sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0", sched_attr->sched_nice, @@ -62,7 +62,7 @@ main(void) sched_attr->sched_runtime, sched_attr->sched_deadline, sched_attr->sched_period, - sizeof(*sched_attr)); + (unsigned)sizeof(*sched_attr)); sched_attr->sched_flags |= 1; if (syscall(__NR_sched_setattr, 0, sched_attr, 0)) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 5/7] tests: Change type of sched_nice field to signed in sched_xetattr test
Kernel headers declare this field as s32, and strace prints it with %d specifier. * tests/sched_xetattr.c: Change type of sched_nice field of struct sched_attr to int32_t, update format specifiers accordingly. --- tests/sched_xetattr.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index e85f9bc..2e0ce61 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -41,7 +41,7 @@ main(void) uint32_t size; uint32_t sched_policy; uint64_t sched_flags; - uint32_t sched_nice; + int32_t sched_nice; uint32_t sched_priority; uint64_t sched_runtime; uint64_t sched_deadline; @@ -52,7 +52,7 @@ main(void) perror_msg_and_skip("sched_getattr"); printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " - "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " "sched_period=%" PRIu64 "\\}, %zu, 0\\) += 0\n", sched_attr->size, @@ -69,7 +69,7 @@ main(void) perror_msg_and_skip("sched_setattr"); printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " - "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " "sched_period=%" PRIu64 "\\}, 0\\) += 0\n", sched_attr->size, -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: [PATCH 2/2] tests: check decoding of readahead syscall
On Thu, Sep 1, 2016 at 9:39 AM, Dmitry V. Levin <l...@altlinux.org> wrote: > On Thu, Sep 01, 2016 at 02:43:30AM +0300, Eugene Syromyatnikov wrote: >> * tests/readahead.c: New file. >> * tests/readahead.test: New test. >> * tests/.gitignore: Add readahead. >> * tests/Makefile.am (check_PROGRAMS): Likewise. >> (DECODER_TESTS): Add readahead.test. >> --- >> Simple test for simple decoder. >> >> tests/.gitignore |1 + >> tests/Makefile.am|2 ++ >> tests/readahead.c| 63 >> ++ >> tests/readahead.test |6 + >> 4 files changed, 72 insertions(+) >> create mode 100644 tests/readahead.c >> create mode 100755 tests/readahead.test >> >> diff --git a/tests/.gitignore b/tests/.gitignore >> index 5c5d092..8c41bea 100644 >> --- a/tests/.gitignore >> +++ b/tests/.gitignore >> @@ -185,6 +185,7 @@ pselect6 >> ptrace >> pwritev >> read-write >> +readahead >> readdir >> readlink >> readlinkat >> diff --git a/tests/Makefile.am b/tests/Makefile.am >> index b879bf4..d7421fc 100644 >> --- a/tests/Makefile.am >> +++ b/tests/Makefile.am >> @@ -241,6 +241,7 @@ check_PROGRAMS = \ >> ptrace \ >> pwritev \ >> read-write \ >> + readahead \ >> readdir \ >> readlink \ >> readlinkat \ >> @@ -568,6 +569,7 @@ DECODER_TESTS = \ >> ptrace.test \ >> pwritev.test \ >> read-write.test \ >> + readahead.test \ >> readdir.test \ >> readlink.test \ >> readlinkat.test \ >> diff --git a/tests/readahead.c b/tests/readahead.c >> new file mode 100644 >> index 000..307dbff >> --- /dev/null >> +++ b/tests/readahead.c >> @@ -0,0 +1,63 @@ >> +#include "tests.h" >> +#include >> + >> +#ifdef __NR_readahead >> + >> +# include >> +# include >> + >> +static const int fds[] = { >> + -0x8000, >> + -100, >> + -1, >> + 0, >> + 1, >> + 2, >> + 0x7fff, >> +}; >> + >> +static const off64_t offsets[] = { >> + -0x8000LL, >> + -0x5060708090a0b0c0LL, >> + -1LL, >> + 0, >> + 1, >> + 0xbadfaced, >> + 0x7fffLL, >> +}; >> + >> +static const unsigned long counts[] = { >> + 0UL, >> + 0xdeadca75, >> + (unsigned long)0xface1e55beeff00dULL, >> + (unsigned long)0xULL, >> +}; >> + >> +int >> +main(void) >> +{ >> + unsigned i; >> + unsigned j; >> + unsigned k; >> + ssize_t rc; >> + >> + for (i = 0; i < ARRAY_SIZE(fds); i++) >> + for (j = 0; j < ARRAY_SIZE(offsets); j++) >> + for (k = 0; k < ARRAY_SIZE(counts); k++) { >> + rc = readahead(fds[i], offsets[j], counts[k]); >> + >> + printf("readahead(%d, %lld, %lu) = " >> + "%ld %s (%m)\n", fds[i], >> + (long long)offsets[j], counts[k], rc, >> + errno2name()); > > What if this syscall returned 0? Well, I assumed that stdin/stdout/stderr are not normal files (which is the case in test suite) and in this case readahead should return EINVAL. I can add support for this if needed. > > -- > ldv > > -- > > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel > -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: [PATCH] Makefile.am: use readlink as a fallback for realpath
On Thu, Sep 1, 2016 at 9:35 AM, Dmitry V. Levin <l...@altlinux.org> wrote: > On Thu, Sep 01, 2016 at 02:47:34AM +0300, Eugene Syromyatnikov wrote: >> Since realpath utility is fairly new in GNU coreutils, there could be >> possibility that it is not present in the system. Instead of checking >> its presence in configure script it probably makes sense to resort to >> calling readlink since it is (probably) more widespread. >> --- >> Makefile.am |3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/Makefile.am b/Makefile.am >> index 65f5c64..b77c2e1 100644 >> --- a/Makefile.am >> +++ b/Makefile.am >> @@ -256,7 +256,8 @@ endif >> @CODE_COVERAGE_RULES@ >> CODE_COVERAGE_BRANCH_COVERAGE = 1 >> CODE_COVERAGE_GENHTML_OPTIONS = $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) \ >> - --prefix $(shell realpath -Ls $(abs_top_srcdir)/..) >> + --prefix $(shell realpath -Ls $(abs_top_srcdir)/.. || \ >> + readlink -f $(abs_top_srcdir)/..) > > What about dirname(1)? Isn't it even more portable than readlink(1)? Yes, looks like it fits perfectly in this case. > > -- > ldv > > -- > > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel > -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 1/2] tests: Additional IPC checks
* tests/ipc_msg.c: Additional msgget (parameter format), msgctl (parameter format, decoding of struct msqid_ds in IPC_SET/IPC_STAT commands) checks. * tests/ipc_sem.c: Additional semget, semctl checks. * tests/ipc_shm.c: Additional shmctl checks. * tests/semop.c: Additional semop checks. Added checks for semtimedop. * tests/semop.test: Add explicit -e parameter in order to trace both semop and semtimedop. * tests/shmxt.c: Additional shmat/shmdt tests. --- tests/ipc_msg.c | 51 +- tests/ipc_sem.c | 27 +++ tests/ipc_shm.c | 23 +-- tests/semop.c| 65 ++ tests/semop.test |2 +- tests/shmxt.c| 11 + 6 files changed, 170 insertions(+), 9 deletions(-) diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c index 2fd7d4f..5bd6116 100644 --- a/tests/ipc_msg.c +++ b/tests/ipc_msg.c @@ -27,10 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include +#include + +#include "xlat.h" +#include "xlat/resource_flags.h" static int id = -1; @@ -48,18 +53,43 @@ main(void) int rc; struct msqid_ds ds; + static const key_t bogus_key = (key_t)0xeca86420fdb97531ULL; + static const int bogus_msgid = 0xfdb97531; + static const int bogus_cmd = 0xdeadbeef; + static void * const bogus_addr = (void *) -1L; + static const int bogus_flags = 0xface1e55 & ~IPC_CREAT; + + assert(msgget(bogus_key, bogus_flags) == -1); + printf("msgget\\(%#lx, %s%s%s%#x\\|%#04o\\) += %s\n", + (unsigned long)((sizeof(key_t) == sizeof(int)) ? + (unsigned)bogus_key : (unsigned long)bogus_key), + IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "", + IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "", + IPC_NOWAIT & bogus_flags ? "IPC_NOWAIT\\|" : "", + bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | IPC_NOWAIT), + bogus_flags & 0777, + sprintrc_grep(-1)); + id = msgget(IPC_PRIVATE, 0600); if (id < 0) perror_msg_and_skip("msgget"); printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id); atexit(cleanup); + assert(msgctl(bogus_msgid, bogus_cmd, NULL) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?%#x /\\* MSG_\\?\\?\\? \\*/, NULL\\) " + "+= %s\n", bogus_msgid, bogus_cmd, sprintrc_grep(-1)); + + assert(msgctl(bogus_msgid, IPC_SET, bogus_addr) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, %p\\) += %s\n", + bogus_msgid, bogus_addr, sprintrc_grep(-1)); + if (msgctl(id, IPC_STAT, )) perror_msg_and_skip("msgctl IPC_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, gid=%u, " - "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, msg_rtime=%u, " - "msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, " - "msg_lrpid=%u\\}\\) += 0\n", + printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, " + "msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, " + "msg_lspid=%u, msg_lrpid=%u\\}\\) += 0\n", id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, (unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key, (unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid, @@ -68,6 +98,13 @@ main(void) (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid, (unsigned) ds.msg_lrpid); + if (msgctl(id, IPC_SET, )) + perror_msg_and_skip("msgctl IPC_SET"); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o\\}, ...\\}\\) += 0\n", + id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, + (unsigned) ds.msg_perm.mode); + int max = msgctl(0, MSG_INFO, ); if (max < 0) perror_msg_and_skip("msgctl MSG_INFO"); @@ -81,9 +118,11 @@ main(void) */ if (-1 != rc || EINVAL != errno) perror_msg_and_skip("msgctl MSG_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += -1 EINVAL \\(%m\\)\n", id, ); + printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += " + "-1 EINVAL \\(%m\\)\n", id, ); } else { - printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n", id, , id); + printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n", + id, , id); } return 0; diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c index afe74d2..09f191d 100644 --- a/tests/ipc_sem.c +++ b/tests/ipc_sem.c @@ -27,11 +27,15 @@ */ #include "tests.h"
[PATCH 0/2] Additional checks for IPC tests
Hello. I've noticed that IPC tests do not check first parameter (IPC ID) enough which allowed incorrect format specifier usage. These patches augment tests with regard to aforementioned issue and correct illicit behaviour. Eugene Syromyatnikov (2): tests: Additional IPC checks Change type of the format specifier from "%lu" to "%d" for IPC ID ipc_msgctl.c |2 +- ipc_sem.c|8 +++ ipc_shm.c|2 +- ipc_shmctl.c |2 +- tests/ipc_msg.c | 51 +- tests/ipc_sem.c | 27 +++ tests/ipc_shm.c | 23 +-- tests/semop.c| 65 ++ tests/semop.test |2 +- tests/shmxt.c| 11 + 10 files changed, 177 insertions(+), 16 deletions(-) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/2] Change type of the format specifier from "%lu" to "%d" for IPC ID
* ipc_msgctl.c (SYS_FUNC(msgctl)): Convert format specifier of the first argument from "%lu" to "%d", cast argument to int. * ipc_sem.c (SYS_FUNC(semop)): Likewise. (SYS_FUNC(semtimedop)): Likewise. (SYS_FUNC(semget)): Likewise. * ipc_shm.c (SYS_FUNC(shmat)): Likewise. * ipc_shmctl.c (SYS_FUNC(shmctl)): Likewise. --- ipc_msgctl.c |2 +- ipc_sem.c|8 ipc_shm.c|2 +- ipc_shmctl.c |2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ipc_msgctl.c b/ipc_msgctl.c index 9be35ce..a7352cb 100644 --- a/ipc_msgctl.c +++ b/ipc_msgctl.c @@ -97,7 +97,7 @@ print_msqid_ds(struct tcb *tcp, const long addr, int cmd) SYS_FUNC(msgctl) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); tprints(", "); } else { diff --git a/ipc_sem.c b/ipc_sem.c index e6172ee..81a2ff7 100644 --- a/ipc_sem.c +++ b/ipc_sem.c @@ -71,7 +71,7 @@ tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count) SYS_FUNC(semop) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int)tcp->u_arg[0]); if (indirect_ipccall(tcp)) { tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); } else { @@ -82,7 +82,7 @@ SYS_FUNC(semop) SYS_FUNC(semtimedop) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); if (indirect_ipccall(tcp)) { tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); tprints(", "); @@ -105,7 +105,7 @@ SYS_FUNC(semget) tprintf("%#lx", tcp->u_arg[0]); else tprints("IPC_PRIVATE"); - tprintf(", %lu, ", tcp->u_arg[1]); + tprintf(", %d, ", (int) tcp->u_arg[1]); if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) tprints("|"); print_numeric_umode_t(tcp->u_arg[2] & 0777); @@ -114,7 +114,7 @@ SYS_FUNC(semget) SYS_FUNC(semctl) { - tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); + tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]); PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); tprints(", "); if (indirect_ipccall(tcp) diff --git a/ipc_shm.c b/ipc_shm.c index e8a8206..072c5e1 100644 --- a/ipc_shm.c +++ b/ipc_shm.c @@ -57,7 +57,7 @@ SYS_FUNC(shmget) SYS_FUNC(shmat) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); if (indirect_ipccall(tcp)) { printaddr(tcp->u_arg[3]); tprints(", "); diff --git a/ipc_shmctl.c b/ipc_shmctl.c index 7ea3672..12bb806 100644 --- a/ipc_shmctl.c +++ b/ipc_shmctl.c @@ -97,7 +97,7 @@ print_shmid_ds(struct tcb *tcp, const long addr, int cmd) SYS_FUNC(shmctl) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); tprints(", "); } else { -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 5/9] tests: Add sprintrc_grep function
sprintrc_grep function is sprintrc function equivalent suitable for tests where grep-base pattern matching is employed. * tests/sprintrc.c (enum sprintrc_fmt): New sprintrc format enumeration. (sprintrc_ex): New function, renamed from sprintrc with updates regarding support of different formats. (sprintrc): Calls sprintrc_ex with SPRINTRC_FMT_RAW. (sprintrc_grep): Calls sprintrc_ex with SPRINTRC_FMT_GREP. * tests/tests.h: sprintrc_grep declaration added. --- tests/sprintrc.c | 41 ++--- tests/tests.h|2 ++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/sprintrc.c b/tests/sprintrc.c index 5e27680..a573a27 100644 --- a/tests/sprintrc.c +++ b/tests/sprintrc.c @@ -28,25 +28,40 @@ #include "tests.h" #include +enum sprintrc_fmt { + SPRINTRC_FMT_RAW, + SPRINTRC_FMT_GREP, +}; + /** * Provides pointer to static string buffer with printed return code in format * used by strace - with errno and error message. * - * @param rc Return code. - * @return Pointer to (statically allocated) buffer containing decimal - * representation of return code and errno/error message in case @rc - * is equal to -1. + * @param rc Return code. + * @param fmt Output format. Currently, raw (used for diff matching) and grep + *(for extended POSIX regex-based pattern matching) formats are + *supported. + * @returnPointer to (statically allocated) buffer containing decimal + *representation of return code and errno/error message in case @rc + *is equal to -1. */ -const char * -sprintrc(long rc) +static inline const char * +sprintrc_ex(long rc, enum sprintrc_fmt fmt) { + static const char *formats[] = { + [SPRINTRC_FMT_RAW] = "-1 %s (%m)", + [SPRINTRC_FMT_GREP] = "-1 %s \\(%m\\)", + }; static char buf[4096]; + if (fmt >= ARRAY_SIZE(formats)) + perror_msg_and_fail("sprintrc_ex: incorrect format provided"); + if (rc == 0) return "0"; int ret = (rc == -1) - ? snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()) + ? snprintf(buf, sizeof(buf), formats[fmt], errno2name()) : snprintf(buf, sizeof(buf), "%ld", rc); if (ret < 0) @@ -57,3 +72,15 @@ sprintrc(long rc) return buf; } + +const char * +sprintrc(long rc) +{ + return sprintrc_ex(rc, SPRINTRC_FMT_RAW); +} + +const char * +sprintrc_grep(long rc) +{ + return sprintrc_ex(rc, SPRINTRC_FMT_GREP); +} diff --git a/tests/tests.h b/tests/tests.h index 3043f97..2599120 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -101,6 +101,8 @@ const char *signal2name(int); /* Print return code and, in case return code is -1, errno information. */ const char *sprintrc(long rc); +/* sprintrc variant suitable for usage as part of grep pattern. */ +const char *sprintrc_grep(long rc); struct xlat; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 3/9] tests: Split long lines in sched_xetattr test
--- tests/sched_xetattr.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index b437b04..b982cca 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -54,7 +54,10 @@ main(void) if (syscall(__NR_sched_getattr, 0, , sizeof(sched), 0)) perror_msg_and_skip("sched_getattr"); - printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, sched_flags=%s, sched_nice=%u, sched_priority=%u, sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, 256, 0\\) += 0\n", + printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " + "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " + "sched_period=%" PRIu64 "\\}, 256, 0\\) += 0\n", sched.attr.size, sched.attr.sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0", sched.attr.sched_nice, @@ -67,7 +70,10 @@ main(void) if (syscall(__NR_sched_setattr, 0, , 0)) perror_msg_and_skip("sched_setattr"); - printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, sched_flags=%s, sched_nice=%u, sched_priority=%u, sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, 0\\) += 0\n", + printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " + "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " + "sched_period=%" PRIu64 "\\}, 0\\) += 0\n", sched.attr.size, "SCHED_FLAG_RESET_ON_FORK", sched.attr.sched_nice, -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 0/9] Minor tests tweaks pt. 2 + Additional checks for IPC tests
Changes since v1: * Commits "tests: Additional IPC checks" and "tests: Additional shmget decoder checks" have been merged. * Added fix for key_t printing. * Commits in tests now after commits in sources. * Sane semcnt provided now in semop/semitimedop struct sembuf decoding checks. * Invalid addresses are now made more invalid in order to avoid accidental decoding. Eugene Syromyatnikov (9): Change type of the format specifier from "%lu" to "%d" for IPC ID Fix key_t argument printing in IPC *get calls tests: Split long lines in sched_xetattr test tests: Perform more strict structure allocation in sched_xetattr test tests: Add sprintrc_grep function tests: Change type of sched_nice field to signed in sched_xetattr test tests: Print size argument of sched_setattr as unsigned tests: Additional sched_getattr/sched_setattr decoder checks tests: Additional IPC checks ipc_msg.c |5 ++- ipc_msgctl.c |2 +- ipc_sem.c | 13 +++--- ipc_shm.c |7 +-- ipc_shmctl.c |2 +- tests/ipc_msg.c | 50 +++--- tests/ipc_sem.c | 29 + tests/ipc_shm.c | 37 tests/sched_xetattr.c | 113 ++--- tests/semop.c | 65 tests/semop.test |2 +- tests/shmxt.c | 11 + tests/sprintrc.c | 41 +++--- tests/tests.h |2 + 14 files changed, 319 insertions(+), 60 deletions(-) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 7/9] tests: Print size argument of sched_setattr as unsigned
Since it is how it is declared. * tests/sched_xetattr.c: Cast size of struct sched_attr to unsigned, update format specifier accordingly. --- tests/sched_xetattr.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index 2e0ce61..9ff8c72 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -54,7 +54,7 @@ main(void) printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " - "sched_period=%" PRIu64 "\\}, %zu, 0\\) += 0\n", + "sched_period=%" PRIu64 "\\}, %u, 0\\) += 0\n", sched_attr->size, sched_attr->sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0", sched_attr->sched_nice, @@ -62,7 +62,7 @@ main(void) sched_attr->sched_runtime, sched_attr->sched_deadline, sched_attr->sched_period, - sizeof(*sched_attr)); + (unsigned)sizeof(*sched_attr)); sched_attr->sched_flags |= 1; if (syscall(__NR_sched_setattr, 0, sched_attr, 0)) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 1/9] Change type of the format specifier from "%lu" to "%d" for IPC ID
* ipc_msgctl.c (SYS_FUNC(msgctl)): Convert format specifier of the first argument from "%lu" to "%d", cast argument to int. * ipc_sem.c (SYS_FUNC(semop)): Likewise. (SYS_FUNC(semtimedop)): Likewise. (SYS_FUNC(semget)): Likewise. * ipc_shm.c (SYS_FUNC(shmat)): Likewise. * ipc_shmctl.c (SYS_FUNC(shmctl)): Likewise. --- ipc_msgctl.c |2 +- ipc_sem.c|8 ipc_shm.c|2 +- ipc_shmctl.c |2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ipc_msgctl.c b/ipc_msgctl.c index 9be35ce..a7352cb 100644 --- a/ipc_msgctl.c +++ b/ipc_msgctl.c @@ -97,7 +97,7 @@ print_msqid_ds(struct tcb *tcp, const long addr, int cmd) SYS_FUNC(msgctl) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); tprints(", "); } else { diff --git a/ipc_sem.c b/ipc_sem.c index e6172ee..81a2ff7 100644 --- a/ipc_sem.c +++ b/ipc_sem.c @@ -71,7 +71,7 @@ tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count) SYS_FUNC(semop) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int)tcp->u_arg[0]); if (indirect_ipccall(tcp)) { tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); } else { @@ -82,7 +82,7 @@ SYS_FUNC(semop) SYS_FUNC(semtimedop) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); if (indirect_ipccall(tcp)) { tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); tprints(", "); @@ -105,7 +105,7 @@ SYS_FUNC(semget) tprintf("%#lx", tcp->u_arg[0]); else tprints("IPC_PRIVATE"); - tprintf(", %lu, ", tcp->u_arg[1]); + tprintf(", %d, ", (int) tcp->u_arg[1]); if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) tprints("|"); print_numeric_umode_t(tcp->u_arg[2] & 0777); @@ -114,7 +114,7 @@ SYS_FUNC(semget) SYS_FUNC(semctl) { - tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); + tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]); PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); tprints(", "); if (indirect_ipccall(tcp) diff --git a/ipc_shm.c b/ipc_shm.c index e8a8206..072c5e1 100644 --- a/ipc_shm.c +++ b/ipc_shm.c @@ -57,7 +57,7 @@ SYS_FUNC(shmget) SYS_FUNC(shmat) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); if (indirect_ipccall(tcp)) { printaddr(tcp->u_arg[3]); tprints(", "); diff --git a/ipc_shmctl.c b/ipc_shmctl.c index 7ea3672..12bb806 100644 --- a/ipc_shmctl.c +++ b/ipc_shmctl.c @@ -97,7 +97,7 @@ print_shmid_ds(struct tcb *tcp, const long addr, int cmd) SYS_FUNC(shmctl) { if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); + tprintf("%d, ", (int) tcp->u_arg[0]); PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); tprints(", "); } else { -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 2/9] Fix key_t argument printing in IPC *get calls
key_t is actually int. * ipc_msg.c (SYS_FUNC(msgget)): Change format specifier of the first argument to "%#x". * ipc_sem.c (SYS_FUNC(semget)): Likewise. * ipc_shm (SYS_FUNC(shmget)): Likewise. --- ipc_msg.c |5 +++-- ipc_sem.c |5 +++-- ipc_shm.c |5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ipc_msg.c b/ipc_msg.c index f04d14d..24bc336 100644 --- a/ipc_msg.c +++ b/ipc_msg.c @@ -44,8 +44,9 @@ SYS_FUNC(msgget) { - if (tcp->u_arg[0]) - tprintf("%#lx, ", tcp->u_arg[0]); + /* key_t is __kernel_key_t in kernel, which is typedef'ed to int*/ + if ((int) tcp->u_arg[0]) + tprintf("%#x, ", (int) tcp->u_arg[0]); else tprints("IPC_PRIVATE, "); if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) diff --git a/ipc_sem.c b/ipc_sem.c index 81a2ff7..0de0fe7 100644 --- a/ipc_sem.c +++ b/ipc_sem.c @@ -101,8 +101,9 @@ SYS_FUNC(semtimedop) SYS_FUNC(semget) { - if (tcp->u_arg[0]) - tprintf("%#lx", tcp->u_arg[0]); + /* key_t is __kernel_key_t in kernel, which is typedef'ed to int*/ + if ((int) tcp->u_arg[0]) + tprintf("%#x", (int) tcp->u_arg[0]); else tprints("IPC_PRIVATE"); tprintf(", %d, ", (int) tcp->u_arg[1]); diff --git a/ipc_shm.c b/ipc_shm.c index 072c5e1..ef2d0e9 100644 --- a/ipc_shm.c +++ b/ipc_shm.c @@ -43,8 +43,9 @@ SYS_FUNC(shmget) { - if (tcp->u_arg[0]) - tprintf("%#lx", tcp->u_arg[0]); + /* key_t is __kernel_key_t in kernel, which is typedef'ed to int*/ + if ((int) tcp->u_arg[0]) + tprintf("%#x", (int) tcp->u_arg[0]); else tprints("IPC_PRIVATE"); tprintf(", %lu, ", tcp->u_arg[1]); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 8/9] tests: Additional sched_getattr/sched_setattr decoder checks
* tests/sched_xetattr.c: Additional checs for sched_getattr and sched_setattr decoding. --- tests/sched_xetattr.c | 43 +++ 1 file changed, 43 insertions(+) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index 9ff8c72..ce5c417 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -30,6 +30,7 @@ #if defined __NR_sched_getattr && defined __NR_sched_setattr +# include # include # include # include @@ -48,6 +49,21 @@ main(void) uint64_t sched_period; } *sched_attr = tail_alloc(sizeof(*sched_attr)); + assert(syscall(__NR_sched_getattr, 0xdeadface, NULL, 0, 0) == -1); + printf("sched_getattr\\(%d, NULL, 0, 0\\) += %s\n", + 0xdeadface, sprintrc_grep(-1)); + + assert(syscall(__NR_sched_getattr, -1, sched_attr, 0xbadfaced, + 0xc0defeed) == -1); + printf("sched_getattr\\(-1, %p, %u, %u\\) += %s\n", + sched_attr, 0xbadfaced, 0xc0defeed, sprintrc_grep(-1)); + + assert(syscall(__NR_sched_getattr, 0, sched_attr + 1, + sizeof(*sched_attr), 0) == -1); + printf("sched_getattr\\(0, %p, %u, 0\\) += %s\n", + sched_attr + 1, (unsigned)sizeof(*sched_attr), + sprintrc_grep(-1)); + if (syscall(__NR_sched_getattr, 0, sched_attr, sizeof(*sched_attr), 0)) perror_msg_and_skip("sched_getattr"); @@ -80,6 +96,33 @@ main(void) sched_attr->sched_deadline, sched_attr->sched_period); + sched_attr->size = 0x90807060; + sched_attr->sched_policy = 0xca7faced; + sched_attr->sched_flags = 0xbadc0ded1057da7aULL; + sched_attr->sched_nice = 0xafbfcfdf; + sched_attr->sched_priority = 0xb8c8d8e8; + sched_attr->sched_runtime = 0xbadcaffedeadf157ULL; + sched_attr->sched_deadline = 0xc0de70a57badac75ULL; + sched_attr->sched_period = 0xded1ca7edda7aca7ULL; + + assert(syscall(__NR_sched_setattr, 0xfacec0de, sched_attr, + 0xbeeff00d) == -1); + + printf("sched_setattr\\(%d, \\{size=%u, " + "sched_policy=%#x /\\* SCHED_\\?\\?\\? \\*/, " + "sched_flags=%#" PRIx64 " /\\* SCHED_FLAG_\\?\\?\\? \\*/, " + "sched_nice=%d, sched_priority=%u, sched_runtime=%" PRIu64 ", " + "sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, " + "%u\\) += %s\n", + 0xfacec0de, sched_attr->size, + sched_attr->sched_policy, + sched_attr->sched_flags, + sched_attr->sched_nice, + sched_attr->sched_priority, + sched_attr->sched_runtime, + sched_attr->sched_deadline, + sched_attr->sched_period, 0xbeeff00d, sprintrc_grep(-1)); + return 0; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 9/9] tests: Additional IPC checks
* tests/ipc_msg.c: Additional msgget (parameter format), msgctl (parameter format, decoding of struct msqid_ds in IPC_SET/IPC_STAT commands) checks. * tests/ipc_sem.c: Additional semget, semctl checks. * tests/ipc_shm.c: Additional shmget, shmctl checks. * tests/semop.c: Additional semop checks. Added checks for semtimedop. * tests/semop.test: Add explicit -e parameter in order to trace both semop and semtimedop. * tests/shmxt.c: Additional shmat/shmdt tests. --- tests/ipc_msg.c | 50 - tests/ipc_sem.c | 29 tests/ipc_shm.c | 37 +++ tests/semop.c| 65 ++ tests/semop.test |2 +- tests/shmxt.c| 11 + 6 files changed, 187 insertions(+), 7 deletions(-) diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c index 2fd7d4f..7de1bf7 100644 --- a/tests/ipc_msg.c +++ b/tests/ipc_msg.c @@ -27,10 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include +#include + +#include "xlat.h" +#include "xlat/resource_flags.h" static int id = -1; @@ -48,18 +53,42 @@ main(void) int rc; struct msqid_ds ds; + static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; + static const int bogus_msgid = 0xfdb97531; + static const int bogus_cmd = 0xdeadbeef; + static void * const bogus_addr = (void *) -1L; + static const int bogus_flags = 0xface1e55 & ~IPC_CREAT; + + assert(msgget(bogus_key, bogus_flags) == -1); + printf("msgget\\(%#llx, %s%s%s%#x\\|%#04o\\) += %s\n", + zero_extend_signed_to_ull(bogus_key), + IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "", + IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "", + IPC_NOWAIT & bogus_flags ? "IPC_NOWAIT\\|" : "", + bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | IPC_NOWAIT), + bogus_flags & 0777, + sprintrc_grep(-1)); + id = msgget(IPC_PRIVATE, 0600); if (id < 0) perror_msg_and_skip("msgget"); printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id); atexit(cleanup); + assert(msgctl(bogus_msgid, bogus_cmd, NULL) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?%#x /\\* MSG_\\?\\?\\? \\*/, NULL\\) " + "+= %s\n", bogus_msgid, bogus_cmd, sprintrc_grep(-1)); + + assert(msgctl(bogus_msgid, IPC_SET, bogus_addr) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, %p\\) += %s\n", + bogus_msgid, bogus_addr, sprintrc_grep(-1)); + if (msgctl(id, IPC_STAT, )) perror_msg_and_skip("msgctl IPC_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, gid=%u, " - "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, msg_rtime=%u, " - "msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, " - "msg_lrpid=%u\\}\\) += 0\n", + printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, " + "msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, " + "msg_lspid=%u, msg_lrpid=%u\\}\\) += 0\n", id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, (unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key, (unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid, @@ -68,6 +97,13 @@ main(void) (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid, (unsigned) ds.msg_lrpid); + if (msgctl(id, IPC_SET, )) + perror_msg_and_skip("msgctl IPC_SET"); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o\\}, ...\\}\\) += 0\n", + id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, + (unsigned) ds.msg_perm.mode); + int max = msgctl(0, MSG_INFO, ); if (max < 0) perror_msg_and_skip("msgctl MSG_INFO"); @@ -81,9 +117,11 @@ main(void) */ if (-1 != rc || EINVAL != errno) perror_msg_and_skip("msgctl MSG_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += -1 EINVAL \\(%m\\)\n", id, ); + printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += " + "-1 EINVAL \\(%m\\)\n", id, ); } else { - printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n", id, , id); + printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n", + id, , id); } return 0; diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c index afe74d2..74d0fbd 100644 --- a/tests/ipc_sem.c +++ b/tests/ipc_sem.c @@ -27,11 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include
[PATCH v2 6/9] tests: Change type of sched_nice field to signed in sched_xetattr test
Kernel headers declare this field as s32, and strace prints it with %d specifier. * tests/sched_xetattr.c: Change type of sched_nice field of struct sched_attr to int32_t, update format specifiers accordingly. --- tests/sched_xetattr.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index e85f9bc..2e0ce61 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -41,7 +41,7 @@ main(void) uint32_t size; uint32_t sched_policy; uint64_t sched_flags; - uint32_t sched_nice; + int32_t sched_nice; uint32_t sched_priority; uint64_t sched_runtime; uint64_t sched_deadline; @@ -52,7 +52,7 @@ main(void) perror_msg_and_skip("sched_getattr"); printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " - "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " "sched_period=%" PRIu64 "\\}, %zu, 0\\) += 0\n", sched_attr->size, @@ -69,7 +69,7 @@ main(void) perror_msg_and_skip("sched_setattr"); printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, " - "sched_flags=%s, sched_nice=%u, sched_priority=%u, " + "sched_flags=%s, sched_nice=%d, sched_priority=%u, " "sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", " "sched_period=%" PRIu64 "\\}, 0\\) += 0\n", sched_attr->size, -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/9] Minor decoder fixes and various tests amendments
Hello. This is quite inconsistent collection of patches for various decoder test in attempt to make them more thorough. Eugene Syromyatnikov (9): tests: check decoding of perf_event_open syscall tests: Use sprintrc for return code output in sched_xetscheduler test tests: Additional decoder tests in sched_xetscheduler tests: Use sprintrc for return code output in sched_rr_get_interval test tests: Additional decoder tests in sched_rr_get_interval aio: Use printfd for fd printing tests: Use sprintrc for return code output in aio test tests: min_nr and nr arguments in io_getevents should be long tests: Some additional aio checks aio.c | 21 tests/.gitignore |1 + tests/Makefile.am |2 + tests/aio.c | 120 ++--- tests/perf_event_open.c | 83 tests/perf_event_open.test|6 +++ tests/sched_rr_get_interval.c | 22 ++-- tests/sched_xetscheduler.c| 23 +++- 8 files changed, 258 insertions(+), 20 deletions(-) create mode 100644 tests/perf_event_open.c create mode 100755 tests/perf_event_open.test -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 5/9] tests: Additional decoder tests in sched_rr_get_interval
Some additional syscall parser tests: * Incorrect timespec pointer. * Successful call. * tests/sched_rr_get_interval.c: Additional tests. --- tests/sched_rr_get_interval.c | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/sched_rr_get_interval.c b/tests/sched_rr_get_interval.c index 73e2d39..99943e7 100644 --- a/tests/sched_rr_get_interval.c +++ b/tests/sched_rr_get_interval.c @@ -3,6 +3,7 @@ #ifdef __NR_sched_rr_get_interval +# include # include # include # include @@ -11,8 +12,24 @@ int main(void) { struct timespec *const tp = tail_alloc(sizeof(struct timespec)); - long rc = syscall(__NR_sched_rr_get_interval, -1, tp); - printf("sched_rr_get_interval(-1, %p) = %s\n", sprintrc(rc)); + long rc; + + rc = syscall(__NR_sched_rr_get_interval, 0, NULL); + printf("sched_rr_get_interval(0, NULL) = %s\n", sprintrc(rc)); + + rc = syscall(__NR_sched_rr_get_interval, 0, tp + 1); + printf("sched_rr_get_interval(0, %p) = %s\n", tp + 1, sprintrc(rc)); + + rc = syscall(__NR_sched_rr_get_interval, -1, tp); + printf("sched_rr_get_interval(-1, %p) = %s\n", tp, sprintrc(rc)); + + rc = syscall(__NR_sched_rr_get_interval, 0, tp); + if (rc == 0) + printf("sched_rr_get_interval(0, {%jd, %jd}) = 0\n", + (intmax_t)tp->tv_sec, (intmax_t)tp->tv_nsec); + else + printf("sched_rr_get_interval(-1, %p) = %s\n", tp, + sprintrc(rc)); puts("+++ exited with 0 +++"); return 0; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 3/9] tests: Additional decoder tests in sched_xetscheduler
Some additional syscall parser tests: * Incorrect (negative) PID in sched_getscheduler, sched_setscheduler * Incorrect address of sched_param structure. * Incorrect policy value. * tests/sched_xetscheduler.c: additional tests. --- tests/sched_xetscheduler.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tests/sched_xetscheduler.c b/tests/sched_xetscheduler.c index ffb3307..7faee8c 100644 --- a/tests/sched_xetscheduler.c +++ b/tests/sched_xetscheduler.c @@ -46,7 +46,26 @@ main(void) printf("sched_getscheduler(0) = %ld (%s)\n", rc, scheduler); + rc = syscall(__NR_sched_getscheduler, -1); + printf("sched_getscheduler(-1) = %s\n", sprintrc(rc)); + param->sched_priority = -1; + + rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, NULL); + printf("sched_setscheduler(0, SCHED_FIFO, NULL) = %s\n", sprintrc(rc)); + + rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param + 1); + printf("sched_setscheduler(0, SCHED_FIFO, %p) = %s\n", param + 1, + sprintrc(rc)); + + rc = syscall(__NR_sched_setscheduler, 0, 0xfaceda7a, param); + printf("sched_setscheduler(0, %#x /* SCHED_??? */, [%d]) = %s\n", + 0xfaceda7a, param->sched_priority, sprintrc(rc)); + + rc = syscall(__NR_sched_setscheduler, -1, SCHED_FIFO, param); + printf("sched_setscheduler(-1, SCHED_FIFO, [%d]) = %s\n", + param->sched_priority, sprintrc(rc)); + rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param); printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %s\n", param->sched_priority, sprintrc(rc)); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 4/9] tests: Use sprintrc for return code output in sched_rr_get_interval test
* tests/sched_rr_get_interval.c: Use sprintrc for return code output. --- tests/sched_rr_get_interval.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/sched_rr_get_interval.c b/tests/sched_rr_get_interval.c index 8501346..73e2d39 100644 --- a/tests/sched_rr_get_interval.c +++ b/tests/sched_rr_get_interval.c @@ -12,8 +12,7 @@ main(void) { struct timespec *const tp = tail_alloc(sizeof(struct timespec)); long rc = syscall(__NR_sched_rr_get_interval, -1, tp); - printf("sched_rr_get_interval(-1, %p) = %ld %s (%m)\n", - tp, rc, errno2name()); + printf("sched_rr_get_interval(-1, %p) = %s\n", sprintrc(rc)); puts("+++ exited with 0 +++"); return 0; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 1/9] tests: check decoding of perf_event_open syscall
* tests/perf_event_open.c: New file. * tests/perf_event_open.test: New test. * tests/.gitignore: Add perf_event_open. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add perf_event_open.test. --- tests/.gitignore |1 + tests/Makefile.am |2 ++ tests/perf_event_open.c| 83 tests/perf_event_open.test |6 4 files changed, 92 insertions(+) create mode 100644 tests/perf_event_open.c create mode 100755 tests/perf_event_open.test diff --git a/tests/.gitignore b/tests/.gitignore index 8c41bea..84a795d 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -170,6 +170,7 @@ open openat pause pc +perf_event_open personality pipe poll diff --git a/tests/Makefile.am b/tests/Makefile.am index 0b3b818..3e3d073 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -227,6 +227,7 @@ check_PROGRAMS = \ openat \ pause \ pc \ + perf_event_open \ personality \ pipe \ poll \ @@ -555,6 +556,7 @@ DECODER_TESTS = \ open.test \ openat.test \ pause.test \ + perf_event_open.test \ personality.test \ pipe.test \ poll.test \ diff --git a/tests/perf_event_open.c b/tests/perf_event_open.c new file mode 100644 index 000..afdd71d --- /dev/null +++ b/tests/perf_event_open.c @@ -0,0 +1,83 @@ +#include "tests.h" +#include + +#ifdef __NR_perf_event_open + +# include +# include +# include + +# include +# include + +#if ULONG_MAX > UINT_MAX +#define LONG_STR_PREFIX "" +#else +#define LONG_STR_PREFIX "" +#endif + +static const char *printaddr(void *ptr) +{ + static char buf[sizeof("0x") + sizeof(void *) * 2]; + + if (ptr == NULL) + return "NULL"; + + snprintf(buf, sizeof(buf), "%#lx", (unsigned long)ptr); + + return buf; +} + +int +main(void) +{ + struct perf_event_attr *attr = tail_alloc(sizeof(*attr)); + + attr->type = PERF_TYPE_HARDWARE; + attr->size = sizeof(*attr); + + struct { + struct perf_event_attr *attr; + pid_t pid; + int cpu; + int group_fd; + unsigned long flags; + const char *flags_str; + } args[] = { + { NULL, 0xfacef00d, 0xbadabba7, -1, + (unsigned long)0xLLU, + "PERF_FLAG_FD_NO_GROUP|PERF_FLAG_FD_OUTPUT|" + "PERF_FLAG_PID_CGROUP|PERF_FLAG_FD_CLOEXEC|" + "0x" LONG_STR_PREFIX "fff0" + }, + { attr + 1, 0, 0, 0, + 0, "0" }, + { attr, -1, -1, 1, + PERF_FLAG_FD_CLOEXEC, "PERF_FLAG_FD_CLOEXEC" }, + { attr - 1, -100, 100,0xface1e55, + PERF_FLAG_FD_NO_GROUP | PERF_FLAG_FD_OUTPUT | + PERF_FLAG_PID_CGROUP | PERF_FLAG_FD_CLOEXEC, + "PERF_FLAG_FD_NO_GROUP|PERF_FLAG_FD_OUTPUT|" + "PERF_FLAG_PID_CGROUP|PERF_FLAG_FD_CLOEXEC" }, + }; + size_t i; + int rc; + + for (i = 0; i < ARRAY_SIZE(args); i++) { + rc = syscall(__NR_perf_event_open, args[i].attr, args[i].pid, + args[i].cpu, args[i].group_fd, args[i].flags); + printf("perf_event_open(%s, %d, %d, %d, %s) = %s\n", + printaddr(args[i].attr), args[i].pid, args[i].cpu, + args[i].group_fd, args[i].flags_str, sprintrc(rc)); + } + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_perf_event_open") + +#endif + diff --git a/tests/perf_event_open.test b/tests/perf_event_open.test new file mode 100755 index 000..af3860a --- /dev/null +++ b/tests/perf_event_open.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check perf_event_open syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a1 -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 9/9] tests: Some additional aio checks
* aio.c: Additional checks added. --- tests/aio.c | 108 +++ 1 file changed, 108 insertions(+) diff --git a/tests/aio.c b/tests/aio.c index 8c5bfa7..00de5ae 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -111,6 +111,33 @@ main(void) }; const struct iocb *cbv = tail_memdup(proto_cbv, sizeof(proto_cbv)); + /* For additional decoder testing */ + const struct iocb proto_cbv2[] = { + { + .aio_data = 0xbadfacedc0ffeeed, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 0xf00d, + .aio_reqprio = 0xbeef, + .aio_fildes = 0xdefaced1, + .aio_buf = 0, + }, + { + .aio_data = 0xbadfacedc0ffeeed, + .aio_key = 0xdefaced0, + .aio_lio_opcode = 1, + .aio_reqprio = 0xbeef, + .aio_fildes = 0xdefaced1, + .aio_buf = 0, + .aio_nbytes = 0x1020304050607080, + .aio_offset = 0xdeadda7abadc0ded, +# ifdef IOCB_FLAG_RESFD + .aio_flags = 0xfacef157, + .aio_resfd = 0xded1ca7e, +# endif + }, + }; + const struct iocb *cbv2 = tail_memdup(proto_cbv2, sizeof(proto_cbv2)); + const struct iocb proto_cbc = { .aio_data = 0xdeadbeefbadc0ded, .aio_reqprio = 99, @@ -128,6 +155,11 @@ main(void) }; const long *cbvs = tail_memdup(proto_cbvs, sizeof(proto_cbvs)); + const long proto_cbvs2[] = { + (long) [0], (long) [1], + }; + const long *cbvs2 = tail_memdup(proto_cbvs2, sizeof(proto_cbvs2)); + unsigned long *ctx = tail_alloc(sizeof(unsigned long)); *ctx = 0; @@ -142,10 +174,26 @@ main(void) if (open("/dev/zero", O_RDONLY)) perror_msg_and_skip("open: %s", "/dev/zero"); + assert(syscall(__NR_io_setup, 0xdeadbeef, NULL) == -1); + printf("io_setup(%u, NULL) = %s\n", 0xdeadbeef, sprintrc(-1)); + + assert(syscall(__NR_io_setup, lnr, ctx + 1) == -1); + printf("io_setup(%u, %p) = %s\n", nr, ctx + 1, sprintrc(-1)); + if (syscall(__NR_io_setup, lnr, ctx)) perror_msg_and_skip("io_setup"); printf("io_setup(%u, [%lu]) = 0\n", nr, *ctx); + assert(syscall(__NR_io_submit, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, NULL) == -1); + printf("io_submit(%lu, %ld, NULL) = %s\n", + (aio_context_t) 0xface1e55deadbeef, (long) 0xca7faceddeadf00d, + sprintrc(-1)); + + assert(syscall(__NR_io_submit, *ctx, nr, cbs + nr) == -1); + printf("io_submit(%lu, %u, %p) = %s\n", + *ctx, nr, cbs + nr, sprintrc(-1)); + assert(syscall(__NR_io_submit, *ctx, -1L, cbs) == -1); printf("io_submit(%lu, -1, %p) = %s\n", *ctx, cbs, sprintrc(-1)); @@ -165,6 +213,22 @@ main(void) sizeof_data1, (long long) cb[1].aio_offset, nr); + assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, ev + 1, + NULL) == -1); + printf("io_getevents(%lu, %ld, %ld, %p, NULL) = %s\n", + (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, + ev + 1, sprintrc(-1)); + + assert(syscall(__NR_io_getevents, (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, NULL, + ts + 1) == -1); + printf("io_getevents(%lu, %ld, %ld, NULL, %p) = %s\n", + (aio_context_t) 0xface1e55deadbeef, + (long) 0xca7faceddeadf00d, (long) 0xba5e1e505ca571e0, + ts + 1, sprintrc(-1)); + assert(syscall(__NR_io_getevents, *ctx, nr, nr + 1, ev, ts) == (long) nr); printf("io_getevents(%lu, %ld, %ld, [" "{data=%#llx, obj=%p, res=%u, res2=0}, " @@ -175,11 +239,50 @@ main(void) (unsigned long long) cb[1].aio_data, [1], sizeof_data1, nr); + assert(syscall(__NR_io_cancel, *ctx, NULL, NULL) == -1); + printf("io_cancel(%lu, NULL, NULL) = %s\n", *ctx, sprintrc(-1)); + + assert(syscall(__NR_io_cancel, *ctx, cbc + 1, ev) == -1); + printf("io_cancel(%lu, %p, %p) = %s\n", *ctx, cbc + 1, ev, + sprintrc(-1)); + assert(syscall(__NR_io_cancel, *ctx, cbc, ev) == -1); printf("io_cancel(%lu, {data=%#llx, pread, reqprio=99, fildes=-42}, %p) " "= %s\n", *ctx, (unsigned long long) cbc->aio_data, ev, sprintrc(-1)); + assert(syscall(__NR_io_submit, (unsigned long)0xfacef157beeff00dULL, +
[PATCH 7/9] tests: Use sprintrc for return code output in aio test
* tests/aio.c: Use sprintrc for return code output. --- tests/aio.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/aio.c b/tests/aio.c index a6a3b9c..5a023cf 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -147,8 +147,8 @@ main(void) printf("io_setup(%u, [%lu]) = 0\n", nr, *ctx); assert(syscall(__NR_io_submit, *ctx, -1L, cbs) == -1); - printf("io_submit(%lu, -1, %p) = -1 %s (%m)\n", - *ctx, cbs, errno2name()); + printf("io_submit(%lu, -1, %p) = %s\n", + *ctx, cbs, sprintrc(-1)); if (syscall(__NR_io_submit, *ctx, nr, cbs) != (long) nr) perror_msg_and_skip("io_submit"); @@ -177,8 +177,8 @@ main(void) assert(syscall(__NR_io_cancel, *ctx, cbc, ev) == -1); printf("io_cancel(%lu, {data=%#llx, pread, reqprio=99, fildes=-42}, %p) " - "= -1 %s (%m)\n", - *ctx, (unsigned long long) cbc->aio_data, ev, errno2name()); + "= %s\n", + *ctx, (unsigned long long) cbc->aio_data, ev, sprintrc(-1)); if (syscall(__NR_io_submit, *ctx, nr, cbvs) != (long) nr) perror_msg_and_skip("io_submit"); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 8/9] tests: min_nr and nr arguments in io_getevents should be long
* aio.c (main): change output format for min_nr and nr arguments in io_getevents check to %ld, cast arguments to long. --- tests/aio.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/aio.c b/tests/aio.c index 5a023cf..8c5bfa7 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -166,11 +166,11 @@ main(void) nr); assert(syscall(__NR_io_getevents, *ctx, nr, nr + 1, ev, ts) == (long) nr); - printf("io_getevents(%lu, %u, %u, [" + printf("io_getevents(%lu, %ld, %ld, [" "{data=%#llx, obj=%p, res=%u, res2=0}, " "{data=%#llx, obj=%p, res=%u, res2=0}" "], {0, 123456789}) = %u\n", - *ctx, nr, nr + 1, + *ctx, (long) nr, (long) (nr + 1), (unsigned long long) cb[0].aio_data, [0], sizeof_data0, (unsigned long long) cb[1].aio_data, [1], sizeof_data1, nr); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/9] tests: Use sprintrc for return code output in sched_xetscheduler test
* tests/sched_xetscheduler.c: Use sprintrc for return code output. --- tests/sched_xetscheduler.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sched_xetscheduler.c b/tests/sched_xetscheduler.c index d3b7759..ffb3307 100644 --- a/tests/sched_xetscheduler.c +++ b/tests/sched_xetscheduler.c @@ -48,8 +48,8 @@ main(void) param->sched_priority = -1; rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param); - printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %ld %s (%m)\n", - param->sched_priority, rc, errno2name()); + printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %s\n", + param->sched_priority, sprintrc(rc)); puts("+++ exited with 0 +++"); return 0; -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v3] tests: check decoding of readahead syscall
* tests/readahead.c: New file. * tests/readahead.test: New test. * tests/.gitignore: Add readahead. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add readahead.test. --- Changes since v2: * Added workaround for an old glibc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=5208) which is still present in RHEL 5. tests/.gitignore |1 + tests/Makefile.am|2 ++ tests/readahead.c| 89 ++ tests/readahead.test |6 4 files changed, 98 insertions(+) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test diff --git a/tests/.gitignore b/tests/.gitignore index 5c5d092..8c41bea 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -185,6 +185,7 @@ pselect6 ptrace pwritev read-write +readahead readdir readlink readlinkat diff --git a/tests/Makefile.am b/tests/Makefile.am index 2cf9674..0b3b818 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -242,6 +242,7 @@ check_PROGRAMS = \ ptrace \ pwritev \ read-write \ + readahead \ readdir \ readlink \ readlinkat \ @@ -569,6 +570,7 @@ DECODER_TESTS = \ ptrace.test \ pwritev.test \ read-write.test \ + readahead.test \ readdir.test \ readlink.test \ readlinkat.test \ diff --git a/tests/readahead.c b/tests/readahead.c new file mode 100644 index 000..6f50e38 --- /dev/null +++ b/tests/readahead.c @@ -0,0 +1,89 @@ +#include "tests.h" +#include + +#ifdef __NR_readahead + +# include +# include +# include + +# if !defined(STRACE_READAHEAD_USE_SYSCALL) +# if defined(__GNU_LIBRARY__) +/* Check for glibc readahead off64_t argument passing bug, + * see https://sourceware.org/bugzilla/show_bug.cgi?id=5208 */ +# if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ + (__GLIBC__ * 1000 + __GLIBC_MINOR__ > 2007) +#define STRACE_READAHEAD_USE_SYSCALL 0 +# else +#define STRACE_READAHEAD_USE_SYSCALL 1 +# endif +# else /* !defined(__GNU_LIBRARY__) */ +# define STRACE_READAHEAD_USE_SYSCALL 0 +# endif /* defined(__GNU_LIBRARY__) */ +# endif /* !defined(READAHED_USE_SYSCALL) */ + +static const int fds[] = { + -0x8000, + -100, + -1, + 0, + 1, + 2, + 0x7fff, +}; + +static const off64_t offsets[] = { + -0x8000LL, + -0x5060708090a0b0c0LL, + -1LL, +0, +1, +0xbadfaced, +0x7fffLL, +}; + +static const unsigned long counts[] = { + 0UL, + 0xdeadca75, + (unsigned long)0xface1e55beeff00dULL, + (unsigned long)0xULL, +}; + +static inline ssize_t +do_readahead(int fd, off64_t offset, size_t count) +{ +#if STRACE_READAHEAD_USE_SYSCALL + return syscall(__NR_readahead, fd, offset, count); +#else + return readahead(fd, offset, count); +#endif +} + +int +main(void) +{ + unsigned i; + unsigned j; + unsigned k; + ssize_t rc; + + for (i = 0; i < ARRAY_SIZE(fds); i++) + for (j = 0; j < ARRAY_SIZE(offsets); j++) + for (k = 0; k < ARRAY_SIZE(counts); k++) { + rc = do_readahead(fds[i], offsets[j], + counts[k]); + + printf("readahead(%d, %lld, %lu) = %s\n", + fds[i], (long long)offsets[j], + counts[k], sprintrc(rc)); + } + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_readahead") + +#endif diff --git a/tests/readahead.test b/tests/readahead.test new file mode 100755 index 000..397c690 --- /dev/null +++ b/tests/readahead.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check readahead syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a1 -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: [PATCH 4/8] Add xlat values for FUTEX_WAIT commands with FUTEX_CLOCK_REALTIME bit set
On Mon, Aug 29, 2016 at 5:45 PM, Dmitry V. Levin <l...@altlinux.org> wrote: > On Mon, Aug 29, 2016 at 06:12:55PM +0300, Eugene Syromyatnikov wrote: >> The support for these has been added in commit g337f130, before Linux 4.5. > > commit g337f130? Is it a septendecimal number? Sorry, I've overlooked when copy-pasted from git describe output. Correct commit ID is 337f13046ff03717a9e99675284a817527440a49, or 337f130 for short. > >> * xlat/futexops.in: add FUTEX_WAIT|FUTEX_CLOCK_REALTIME and >> FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME records. >> --- >> xlat/futexops.in |2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/xlat/futexops.in b/xlat/futexops.in >> index 3372673..3e589ab 100644 >> --- a/xlat/futexops.in >> +++ b/xlat/futexops.in >> @@ -24,6 +24,8 @@ FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | >> FUTEX_PRIVATE_FLAG) >> FUTEX_WAKE_BITSET_PRIVATE(FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG) >> FUTEX_WAIT_REQUEUE_PI_PRIVATE(FUTEX_WAIT_REQUEUE_PI | >> FUTEX_PRIVATE_FLAG) >> FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG) >> +FUTEX_WAIT|FUTEX_CLOCK_REALTIME >> +FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME >> FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME >> FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME >> FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME > > Looks good. > > > -- > ldv > > -- > > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel > -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 0/7] Some futex parser tweaks and futex test
This patchset contains some initial proposal for the futex syscall test along with some syscall parser formatting tweaks that appeared sensible to me during the test's realisation. Changes since v1: * Change regarding skipping val2 in REQUEUE commands was erroneous (I've overlooked when checked utilised arguments in kernel sources), so it is removed from the series. Futex test has been updated accordingly. * Futex test: val and va2 pointers renamed to uaddr and uaddr2, accordingly. * Futex test: ARG0..ARG3 renamed to ARG3..ARG6 in order to resemble numeration used in comments. * Futex test: instances of direct usage of magic constants replaced with appropriate macro usage (VAL/VAL_PR) * Futex test: some typo fixes, etc. * Other patches haven't been changed. Eugene Syromyatnikov (7): Fix FUTEX_WAKE_OP compare function mask futex: Add handling of FUTEX_FD command futex: Some refinement to unknown command argument formatting Add xlat values for FUTEX_WAIT commands with FUTEX_CLOCK_REALTIME bit set futex: Use alternate form for val3 presented in hex futex: Avoid printing val when it is not used by the command tests: Add test for the futex syscall futex.c | 28 ++- tests/Makefile.am |2 + tests/futex.c | 663 + tests/futex.test |8 + xlat/futexops.in |2 + 5 files changed, 696 insertions(+), 7 deletions(-) create mode 100644 tests/futex.c create mode 100755 tests/futex.test -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 3/7] futex: Some refinement to unknown command argument formatting
Several changes have been performed: * alternate form is used for timeout value since it is pointer half of the time. And half of the time it is not, which can be confusing without number base prefix. * uaddr is pointer across all existing operations, so it's rather expected that it would be the same in possible future operations. * val3 numeric base is also different in different commands, so it's better to use alternate form for it too. * futex.c (SYS_FUNC(futex)): update formatting in unknown command case. --- futex.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/futex.c b/futex.c index 44b90e0..6bd739f 100644 --- a/futex.c +++ b/futex.c @@ -107,7 +107,10 @@ SYS_FUNC(futex) case FUTEX_TRYLOCK_PI: break; default: - tprintf(", %lx, %lx, %x", timeout, uaddr2, val3); + tprintf(", %#lx", timeout); + tprints(", "); + printaddr(uaddr2); + tprintf(", %#x", val3); break; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 4/7] Add xlat values for FUTEX_WAIT commands with FUTEX_CLOCK_REALTIME bit set
The support for these has been added in commit 337f130, before Linux 4.5. * xlat/futexops.in: add FUTEX_WAIT|FUTEX_CLOCK_REALTIME and FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME records. --- xlat/futexops.in |2 ++ 1 file changed, 2 insertions(+) diff --git a/xlat/futexops.in b/xlat/futexops.in index 3372673..3e589ab 100644 --- a/xlat/futexops.in +++ b/xlat/futexops.in @@ -24,6 +24,8 @@ FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG) FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG) FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG) FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG) +FUTEX_WAIT|FUTEX_CLOCK_REALTIME +FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 2/7] futex: Add handling of FUTEX_FD command
Since FUTEX_FD is known (and most likely reserved for the future use), albeit obsolete, it has some expected argument format, so it's probably wise to employ it. * futex.c (SYS_FUNC(futex)): add handling of FUTEX_FD command. --- futex.c |1 + 1 file changed, 1 insertion(+) diff --git a/futex.c b/futex.c index 9268216..44b90e0 100644 --- a/futex.c +++ b/futex.c @@ -101,6 +101,7 @@ SYS_FUNC(futex) tprints(", "); printaddr(uaddr2); break; + case FUTEX_FD: case FUTEX_WAKE: case FUTEX_UNLOCK_PI: case FUTEX_TRYLOCK_PI: -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 6/7] futex: Avoid printing val when it is not used by the command
Analogous to timeout argument omitting in FUTEX_WAKE_BITSET command. * futex.c (SYS_FUNC(futex)): Remove common val argument print call, add it into specific command cases (all except FUTEX_LOCK_PI, FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI). --- futex.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/futex.c b/futex.c index 1418c89..9410b2a 100644 --- a/futex.c +++ b/futex.c @@ -59,32 +59,40 @@ SYS_FUNC(futex) printaddr(uaddr); tprints(", "); printxval(futexops, op, "FUTEX_???"); - tprintf(", %u", val); switch (cmd) { case FUTEX_WAIT: + tprintf(", %u", val); + tprints(", "); + print_timespec(tcp, timeout); + break; case FUTEX_LOCK_PI: tprints(", "); print_timespec(tcp, timeout); break; case FUTEX_WAIT_BITSET: + tprintf(", %u", val); tprints(", "); print_timespec(tcp, timeout); tprintf(", %#x", val3); break; case FUTEX_WAKE_BITSET: + tprintf(", %u", val); tprintf(", %#x", val3); break; case FUTEX_REQUEUE: + tprintf(", %u", val); tprintf(", %u, ", val2); printaddr(uaddr2); break; case FUTEX_CMP_REQUEUE: case FUTEX_CMP_REQUEUE_PI: + tprintf(", %u", val); tprintf(", %u, ", val2); printaddr(uaddr2); tprintf(", %u", val3); break; case FUTEX_WAKE_OP: + tprintf(", %u", val); tprintf(", %u, ", val2); printaddr(uaddr2); tprints(", {"); @@ -96,6 +104,7 @@ SYS_FUNC(futex) tprintf(", %u}", val3 & 0xfff); break; case FUTEX_WAIT_REQUEUE_PI: + tprintf(", %u", val); tprints(", "); print_timespec(tcp, timeout); tprints(", "); @@ -103,10 +112,13 @@ SYS_FUNC(futex) break; case FUTEX_FD: case FUTEX_WAKE: + tprintf(", %u", val); + break; case FUTEX_UNLOCK_PI: case FUTEX_TRYLOCK_PI: break; default: + tprintf(", %u", val); tprintf(", %#lx", timeout); tprints(", "); printaddr(uaddr2); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v2 5/7] futex: Use alternate form for val3 presented in hex
In order to distinguish it from the cases where it is printed in decimal. * futex.c (SYS_FUNC(futex)): use alternate form for the val3 argument. --- futex.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/futex.c b/futex.c index 6bd739f..1418c89 100644 --- a/futex.c +++ b/futex.c @@ -69,10 +69,10 @@ SYS_FUNC(futex) case FUTEX_WAIT_BITSET: tprints(", "); print_timespec(tcp, timeout); - tprintf(", %x", val3); + tprintf(", %#x", val3); break; case FUTEX_WAKE_BITSET: - tprintf(", %x", val3); + tprintf(", %#x", val3); break; case FUTEX_REQUEUE: tprintf(", %u, ", val2); -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/5] tests: Refactor of retstr from futex.c into a library function and updated readahead test
Hello. In accordance with Dmitry's suggestion, readahead test now supports the case when call returns 0. In order to do so, I decided to move function for printing return code from the futex test to libtests. The update of count argument format specifier in readahed syscall is out of scope of this patch set, since looks like it is fine as is. Eugene Syromyatnikov (5): tests/futex: Rename retstr to sprintrc tests/futex: Increase static sprintrc buffer size tests/futex: Add support for return codes other than 0 and -1 to sprintrc tests: Move return code printing into a separate file tests: check decoding of readahead syscall tests/.gitignore |1 + tests/Makefile.am|3 ++ tests/futex.c| 99 ++ tests/readahead.c| 62 +++ tests/readahead.test |6 +++ tests/sprintrc.c | 36 ++ tests/tests.h|3 ++ 7 files changed, 155 insertions(+), 55 deletions(-) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test create mode 100644 tests/sprintrc.c -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/5] tests/futex: Increase static sprintrc buffer size
* tests/futex.c (sprintrc) : Value increased from 256 to 4095. --- tests/futex.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/futex.c b/tests/futex.c index dca191e..edb5c9d 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -145,7 +145,7 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) const char *sprintrc(int rc) { - enum { RES_BUF_SIZE = 256 }; + enum { RES_BUF_SIZE = 4095 }; static char buf[RES_BUF_SIZE]; if (rc == 0) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 1/5] tests/futex: Rename retstr to sprintrc
* tests/futex.c (retstr): Rename to sprintrc, (main): Update all retstr calls to sprintrc. --- tests/futex.c | 88 + 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/tests/futex.c b/tests/futex.c index dfdf68d..dca191e 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -143,7 +143,7 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) printf(") = -1 ENOSYS (%m)\n"); } -const char *retstr(int rc) +const char *sprintrc(int rc) { enum { RES_BUF_SIZE = 256 }; static char buf[RES_BUF_SIZE]; @@ -204,34 +204,34 @@ main(int argc, char *argv[]) (rc == -1) && (errno == EFAULT)); printf("futex(NULL, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", VAL_PR, (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, - retstr(rc)); + sprintrc(rc)); /* uaddr is faulty */ CHECK_FUTEX(uaddr + 1, FUTEX_WAIT, VAL, tmout, uaddr2, VAL3, (rc == -1) && (errno == EFAULT)); printf("futex(%p, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", uaddr + 1, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* timeout is faulty */ CHECK_FUTEX(uaddr, FUTEX_WAIT, VAL, tmout + 1, uaddr2, VAL3, (rc == -1) && (errno == EFAULT)); printf("futex(%p, FUTEX_WAIT, %u, %p) = %s\n", - uaddr, 0xfacefeed, tmout + 1, retstr(rc)); + uaddr, 0xfacefeed, tmout + 1, sprintrc(rc)); /* uaddr is not as provided; uaddr2 is faulty but ignored */ CHECK_FUTEX(uaddr, FUTEX_WAIT, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT, %u, {%jd, %jd}) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* uaddr is not as provided; uaddr2 is faulty but ignored */ CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_WAIT, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_PRIVATE, %u, {%jd, %jd}) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_nsec, sprintrc(rc)); /* Next 2 tests are with CLOCKRT bit set */ @@ -241,14 +241,16 @@ main(int argc, char *argv[]) VAL, tmout, uaddr2, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT|FUTEX_CLOCK_REALTIME, %u, " "{%jd, %jd}) = %s\n", uaddr, VAL_PR, - (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, + sprintrc(rc)); CHECK_FUTEX_ENOSYS(uaddr, FUTEX_CLOCK_REALTIME | FUTEX_PRIVATE_FLAG | FUTEX_WAIT , VAL, tmout, uaddr2, 0, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_PRIVATE|FUTEX_CLOCK_REALTIME, %u, " "{%jd, %jd}) = %s\n", uaddr, VAL_PR, - (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, retstr(rc)); + (intmax_t)tmout->tv_sec, (intmax_t)tmout->tv_nsec, + sprintrc(rc)); /* FUTEX_WAIT_BITSET - FUTEX_WAIT which provides additional bitmask * which should be matched at least in one bit with @@ -266,20 +268,20 @@ main(int argc, char *argv[]) VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_BITSET, %u, {%jd, %jd}, %#x) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, VAL3_PR, retstr(rc)); + (intmax_t)tmout->tv_nsec, VAL3_PR, sprintrc(rc)); /* val3 of 0 is invalid */ CHECK_FUTEX_ENOSYS(uaddr, FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1, 0, (rc == -1) && (errno == EINVAL)); printf("futex(%p, FUTEX_WAIT_BITSET, %u, {%jd, %jd}, %#x) = %s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, 0, retstr(rc)); + (intmax_t)tmout->tv_nsec, 0, sprintrc(rc)); CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_WAIT_BITSET, VAL, tmout, uaddr2 + 1, VAL3, (rc == -1) && (errno == EAGAIN)); printf("futex(%p, FUTEX_WAIT_BITSET_PRIVATE, %u, {%jd, %jd}, %#x) = " "%s\n", uaddr, VAL_PR, (intmax_t)tmout->tv_sec, - (intmax_t)tmout->tv_nsec, VAL3_PR, retstr(rc)); + (intmax_t)tmout->tv_nsec, VAL3_PR, sprintrc(rc)); /* Next 3 tests are with CLOCKRT bit set */ @@ -288,7 +290,7 @@ main(int argc, char *argv[]) printf("futex(%p,
[PATCH 5/5] tests: check decoding of readahead syscall
* tests/readahead.c: New file. * tests/readahead.test: New test. * tests/.gitignore: Add readahead. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add readahead.test. --- tests/.gitignore |1 + tests/Makefile.am|2 ++ tests/readahead.c| 62 ++ tests/readahead.test |6 + 4 files changed, 71 insertions(+) create mode 100644 tests/readahead.c create mode 100755 tests/readahead.test diff --git a/tests/.gitignore b/tests/.gitignore index 5c5d092..8c41bea 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -185,6 +185,7 @@ pselect6 ptrace pwritev read-write +readahead readdir readlink readlinkat diff --git a/tests/Makefile.am b/tests/Makefile.am index 2cf9674..0b3b818 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -242,6 +242,7 @@ check_PROGRAMS = \ ptrace \ pwritev \ read-write \ + readahead \ readdir \ readlink \ readlinkat \ @@ -569,6 +570,7 @@ DECODER_TESTS = \ ptrace.test \ pwritev.test \ read-write.test \ + readahead.test \ readdir.test \ readlink.test \ readlinkat.test \ diff --git a/tests/readahead.c b/tests/readahead.c new file mode 100644 index 000..e58fcac --- /dev/null +++ b/tests/readahead.c @@ -0,0 +1,62 @@ +#include "tests.h" +#include + +#ifdef __NR_readahead + +# include +# include + +static const int fds[] = { + -0x8000, + -100, + -1, + 0, + 1, + 2, + 0x7fff, +}; + +static const off64_t offsets[] = { + -0x8000LL, + -0x5060708090a0b0c0LL, + -1LL, +0, +1, +0xbadfaced, +0x7fffLL, +}; + +static const unsigned long counts[] = { + 0UL, + 0xdeadca75, + (unsigned long)0xface1e55beeff00dULL, + (unsigned long)0xULL, +}; + +int +main(void) +{ + unsigned i; + unsigned j; + unsigned k; + ssize_t rc; + + for (i = 0; i < ARRAY_SIZE(fds); i++) + for (j = 0; j < ARRAY_SIZE(offsets); j++) + for (k = 0; k < ARRAY_SIZE(counts); k++) { + rc = readahead(fds[i], offsets[j], counts[k]); + + printf("readahead(%d, %lld, %lu) = %s\n", + fds[i], (long long)offsets[j], + counts[k], sprintrc(rc)); + } + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_readahead") + +#endif diff --git a/tests/readahead.test b/tests/readahead.test new file mode 100755 index 000..397c690 --- /dev/null +++ b/tests/readahead.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check readahead syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a1 -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 3/5] tests/futex: Add support for return codes other than 0 and -1 to sprintrc
* tests/futex.c (sprintrc): Print the actual return code provided, not just "0". --- tests/futex.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/futex.c b/tests/futex.c index edb5c9d..fb7833c 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -147,11 +147,22 @@ const char *sprintrc(int rc) { enum { RES_BUF_SIZE = 4095 }; static char buf[RES_BUF_SIZE]; + int saved_errno = errno; + int ret; + /* Common case, making it quick and error-free */ if (rc == 0) return "0"; - snprintf(buf, sizeof(buf), "-1 %s (%m)", errno2name()); + ret = snprintf(buf, sizeof(buf), "%d", rc); + + if (ret < 0) + perror_msg_and_fail("snprintf"); + if ((rc != -1) || ((size_t)ret >= sizeof(buf))) + return buf; + + errno = saved_errno; + snprintf(buf + ret, sizeof(buf) - ret, " %s (%m)", errno2name()); return buf; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 4/5] tests: Move return code printing into a separate file
* tests/tests.h: Add sprintrc declaration. * tests/futex.c (sprintrc): Remove. * tests/sprintrc.c: New file. * tests/Makefile.am (libtests_a_SOURCES): Add sprintrc.c. --- tests/Makefile.am |1 + tests/futex.c | 24 tests/sprintrc.c | 36 tests/tests.h |3 +++ 4 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 tests/sprintrc.c diff --git a/tests/Makefile.am b/tests/Makefile.am index b879bf4..2cf9674 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -54,6 +54,7 @@ libtests_a_SOURCES = \ printflags.c \ printxval.c \ signal2name.c \ + sprintrc.c \ tail_alloc.c \ tests.h \ tprintf.c \ diff --git a/tests/futex.c b/tests/futex.c index fb7833c..63669d2 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -143,30 +143,6 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) printf(") = -1 ENOSYS (%m)\n"); } -const char *sprintrc(int rc) -{ - enum { RES_BUF_SIZE = 4095 }; - static char buf[RES_BUF_SIZE]; - int saved_errno = errno; - int ret; - - /* Common case, making it quick and error-free */ - if (rc == 0) - return "0"; - - ret = snprintf(buf, sizeof(buf), "%d", rc); - - if (ret < 0) - perror_msg_and_fail("snprintf"); - if ((rc != -1) || ((size_t)ret >= sizeof(buf))) - return buf; - - errno = saved_errno; - snprintf(buf + ret, sizeof(buf) - ret, " %s (%m)", errno2name()); - - return buf; -} - # define CHECK_INVALID_CLOCKRT(op, ...) \ do { \ invalid_op(uaddr, FUTEX_CLOCK_REALTIME | (op), __VA_ARGS__); \ diff --git a/tests/sprintrc.c b/tests/sprintrc.c new file mode 100644 index 000..3c05f08 --- /dev/null +++ b/tests/sprintrc.c @@ -0,0 +1,36 @@ +#include + +#include "tests.h" + +/** + * Provides pointer to static string buffer with printed return code in format + * used by strace - with errno and error message. + * + * @param rc Return code. + * @return Pointer to (statically allocated) buffer containing decimal + * representation of return code and errno/error message in case @rc + * is equal to -1. + */ +const char *sprintrc(int rc) +{ + enum { RES_BUF_SIZE = 4095 }; + static char buf[RES_BUF_SIZE]; + int saved_errno = errno; + int ret; + + /* Common case, making it quick and error-free */ + if (rc == 0) + return "0"; + + ret = snprintf(buf, sizeof(buf), "%d", rc); + + if (ret < 0) + perror_msg_and_fail("snprintf"); + if ((rc != -1) || ((size_t)ret >= sizeof(buf))) + return buf; + + errno = saved_errno; + snprintf(buf + ret, sizeof(buf) - ret, " %s (%m)", errno2name()); + + return buf; +} diff --git a/tests/tests.h b/tests/tests.h index 81abe82..ae99c45 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -99,6 +99,9 @@ const char *errno2name(void); /* Translate signal number to its name. */ const char *signal2name(int); +/* Print return code and, in case return code is -1, errno information. */ +const char *sprintrc(int rc); + struct xlat; /* Print flags in symbolic form according to xlat table. */ -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH] futex: Remove inclusion which is not used
configure script doesn't perform check for linux/futex.h presence, so HAVE_LINUX_FUTEX_H is always undefined and inclusion of system header is never performed. Moreover, this header had an incorrect definition of FUTEX_WAIT_BITSET_PRIVATE/FUTEX_WAKE_BITSET_PRIVATE in the past: from commit v2.6.24-6320-gcd68998 (where these definitions had been initially introduced) up to v2.6.31-7082-gf8d1e54 (where they have be finally fixed) these macros has been incorrectly defined via FUTEX_WAIT_BITS/FUTEX_WAKE_BITS (not FUTEX_WAIT_BITSET/FUTEX_WAKE_BITSET) and these incorrect definitions made their way in some distributions still in use. * futex.c: Remove conditional inclusion: HAVE_LINUX_FUTEX_H is never defined and this is dead code, effectively. --- futex.c |4 1 file changed, 4 deletions(-) diff --git a/futex.c b/futex.c index 9410b2a..d1b5a42 100644 --- a/futex.c +++ b/futex.c @@ -30,10 +30,6 @@ #include "defs.h" -#ifdef HAVE_LINUX_FUTEX_H -# include -#endif - #ifndef FUTEX_PRIVATE_FLAG # define FUTEX_PRIVATE_FLAG 128 #endif -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH] Refactor common sa_handler printing code
* xlat/sa_handler_values.in: New file. * signal.c: Include "xlat/sa_handler_values.h". (get_sa_handler_str, print_sa_handler): New functions. (SYS_FUNC(sigsetmask), SYS_FUNC(signal), decode_new_sigaction): Use them. --- signal.c | 64 - xlat/sa_handler_values.in |4 +++ 2 files changed, 27 insertions(+), 41 deletions(-) create mode 100644 xlat/sa_handler_values.in diff --git a/signal.c b/signal.c index 5b530cf..b796b10 100644 --- a/signal.c +++ b/signal.c @@ -70,6 +70,7 @@ # endif #endif +#include "xlat/sa_handler_values.h" #include "xlat/sigact_flags.h" #include "xlat/sigprocmaskcmds.h" @@ -113,6 +114,23 @@ * Use (NSIG / 8) as a size instead. */ +static const char * +get_sa_handler_str(unsigned long handler) +{ + return xlookup(sa_handler_values, handler); +} + +static void +print_sa_handler(unsigned long handler) +{ + const char *sa_handler_str = get_sa_handler_str(handler); + + if (sa_handler_str) + tprints(sa_handler_str); + else + printaddr(handler); +} + const char * signame(const int sig) { @@ -320,14 +338,7 @@ decode_old_sigaction(struct tcb *tcp, long addr) * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ tprints("{"); - if ((long)sa.__sa_handler == (long)SIG_ERR) - tprints("SIG_ERR"); - else if ((long)sa.__sa_handler == (long)SIG_DFL) - tprints("SIG_DFL"); - else if ((long)sa.__sa_handler == (long)SIG_IGN) - tprints("SIG_IGN"); - else - printaddr((long) sa.__sa_handler); + print_sa_handler((unsigned long)sa.__sa_handler); tprints(", "); #ifdef MIPS tprintsigmask_addr("", sa.sa_mask); @@ -360,32 +371,10 @@ SYS_FUNC(signal) if (entering(tcp)) { printsignal(tcp->u_arg[0]); tprints(", "); - switch (tcp->u_arg[1]) { - case (long) SIG_ERR: - tprints("SIG_ERR"); - break; - case (long) SIG_DFL: - tprints("SIG_DFL"); - break; - case (long) SIG_IGN: - tprints("SIG_IGN"); - break; - default: - printaddr(tcp->u_arg[1]); - } + print_sa_handler(tcp->u_arg[1]); return 0; - } - else if (!syserror(tcp)) { - switch (tcp->u_rval) { - case (long) SIG_ERR: - tcp->auxstr = "SIG_ERR"; break; - case (long) SIG_DFL: - tcp->auxstr = "SIG_DFL"; break; - case (long) SIG_IGN: - tcp->auxstr = "SIG_IGN"; break; - default: - tcp->auxstr = NULL; - } + } else if (!syserror(tcp)) { + tcp->auxstr = get_sa_handler_str(tcp->u_rval); return RVAL_HEX | RVAL_STR; } return 0; @@ -560,14 +549,7 @@ decode_new_sigaction(struct tcb *tcp, long addr) * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ tprints("{"); - if ((long)sa.__sa_handler == (long)SIG_ERR) - tprints("SIG_ERR"); - else if ((long)sa.__sa_handler == (long)SIG_DFL) - tprints("SIG_DFL"); - else if ((long)sa.__sa_handler == (long)SIG_IGN) - tprints("SIG_IGN"); - else - printaddr((unsigned long) sa.__sa_handler); + print_sa_handler((unsigned long)sa.__sa_handler); tprints(", "); /* * Sigset size is in tcp->u_arg[4] (SPARC) diff --git a/xlat/sa_handler_values.in b/xlat/sa_handler_values.in new file mode 100644 index 000..e907611 --- /dev/null +++ b/xlat/sa_handler_values.in @@ -0,0 +1,4 @@ +#val_type unsigned long +SIG_ERR +SIG_DFL +SIG_IGN -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v4] tests: Additional IPC checks
* tests/ipc_msg.c: Additional msgget (parameter format), msgctl (parameter format, decoding of struct msqid_ds in IPC_SET/IPC_STAT commands) checks. * tests/ipc_sem.c: Additional semget, semctl checks. * tests/ipc_shm.c: Additional shmget, shmctl checks. * tests/semop.c: Additional semop checks. Added checks for semtimedop. * tests/semop.test: Add explicit -e parameter in order to trace both semop and semtimedop. * tests/shmxt.c: Additional shmat/shmdt tests. --- Changes since v3: * Assertions eliminated. * BROKEN_GLIBC macro renamed to SKIP_TEST_BOGUS_ADDR, commits merged. * Proper order of static and local variables (which was broken after yet another rebase) enforced. * tests/shmxt: explicit values converted to constants. tests/ipc_msg.c | 66 ++ tests/ipc_sem.c | 28 +++ tests/ipc_shm.c | 52 ++ tests/semop.c| 65 + tests/semop.test |2 +- tests/shmxt.c| 15 + 6 files changed, 219 insertions(+), 9 deletions(-) diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c index b6b3c99..97f0c80 100644 --- a/tests/ipc_msg.c +++ b/tests/ipc_msg.c @@ -31,6 +31,28 @@ #include #include #include +#include + +#include "xlat.h" +#include "xlat/resource_flags.h" + +/* + * Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data provided in + * third argument of msgctl call (in case of IPC_SET cmd) which led to + * segmentation fault. + */ +#if !(defined SKIP_TEST_BOGUS_ADDR) +# if defined __GLIBC__ && defined POWERPC && defined POWERPC64 +# if !(defined __GLIBC_MINOR__) || \ +((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23) +# define SKIP_TEST_BOGUS_ADDR 1 +# endif +# endif /* __GLIBC__ && _powerpc__ && __ppc64__ */ +#endif /* !SKIP_TEST_BOGUS_ADDR */ + +#ifndef SKIP_TEST_BOGUS_ADDR +# define SKIP_TEST_BOGUS_ADDR 0 +#endif static int id = -1; @@ -47,21 +69,50 @@ main(void) { static const key_t private_key = (key_t) (0xULL | IPC_PRIVATE); + + static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; + static const int bogus_msgid = 0xfdb97531; + static const int bogus_cmd = 0xdeadbeef; +#if !SKIP_TEST_BOGUS_ADDR + static void * const bogus_addr = (void *) -1L; +#endif + static const int bogus_flags = 0xface1e55 & ~IPC_CREAT; + int rc; struct msqid_ds ds; + rc = msgget(bogus_key, bogus_flags); + printf("msgget\\(%#llx, %s%s%s%#x\\|%#04o\\) += %s\n", + zero_extend_signed_to_ull(bogus_key), + IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "", + IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "", + IPC_NOWAIT & bogus_flags ? "IPC_NOWAIT\\|" : "", + bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | IPC_NOWAIT), + bogus_flags & 0777, + sprintrc_grep(rc)); + id = msgget(private_key, 0600); if (id < 0) perror_msg_and_skip("msgget"); printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id); atexit(cleanup); + rc = msgctl(bogus_msgid, bogus_cmd, NULL); + printf("msgctl\\(%d, (IPC_64\\|)?%#x /\\* MSG_\\?\\?\\? \\*/, NULL\\) " + "+= %s\n", bogus_msgid, bogus_cmd, sprintrc_grep(rc)); + +#if !SKIP_TEST_BOGUS_ADDR + rc = msgctl(bogus_msgid, IPC_SET, bogus_addr); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, %p\\) += %s\n", + bogus_msgid, bogus_addr, sprintrc_grep(rc)); +#endif + if (msgctl(id, IPC_STAT, )) perror_msg_and_skip("msgctl IPC_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, gid=%u, " - "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, msg_rtime=%u, " - "msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, " - "msg_lrpid=%u\\}\\) += 0\n", + printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, " + "msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, " + "msg_lspid=%u, msg_lrpid=%u\\}\\) += 0\n", id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, (unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key, (unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid, @@ -70,6 +121,13 @@ main(void) (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid, (unsigned) ds.msg_lrpid); + if (msgctl(id, IPC_SET, )) + perror_msg_and_skip("msgctl IPC_SET"); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o\\}, ...\\}\\) += 0\n", + id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, +
[PATCH v3 0/2] Aditional checks for IPC tests
Changes since v2: * Workaround for musl which sets size argument in shmget call to SIZE_MAX if it is greater than PTRDIFF_MAX. * Fix pattern for indirect semctl call. * Added workaround for broken msgctl call with faulty pointer in third argument on PPC64. Eugene Syromyatnikov (2): tests: Additional IPC checks tests: Workaroud for buggy glibc in ipc_msg test on ppc64 tests/ipc_msg.c | 66 ++ tests/ipc_sem.c | 29 tests/ipc_shm.c | 44 tests/semop.c| 65 + tests/semop.test |2 +- tests/shmxt.c| 11 + 6 files changed, 212 insertions(+), 5 deletions(-) -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH v3 1/2] tests: Additional IPC checks
* tests/ipc_msg.c: Additional msgget (parameter format), msgctl (parameter format, decoding of struct msqid_ds in IPC_SET/IPC_STAT commands) checks. * tests/ipc_sem.c: Additional semget, semctl checks. * tests/ipc_shm.c: Additional shmget, shmctl checks. * tests/semop.c: Additional semop checks. Added checks for semtimedop. * tests/semop.test: Add explicit -e parameter in order to trace both semop and semtimedop. * tests/shmxt.c: Additional shmat/shmdt tests. --- tests/ipc_msg.c | 44 tests/ipc_sem.c | 29 tests/ipc_shm.c | 44 tests/semop.c| 65 ++ tests/semop.test |2 +- tests/shmxt.c| 11 + 6 files changed, 190 insertions(+), 5 deletions(-) diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c index b6b3c99..af0c377 100644 --- a/tests/ipc_msg.c +++ b/tests/ipc_msg.c @@ -27,10 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include +#include + +#include "xlat.h" +#include "xlat/resource_flags.h" static int id = -1; @@ -50,18 +55,42 @@ main(void) int rc; struct msqid_ds ds; + static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; + static const int bogus_msgid = 0xfdb97531; + static const int bogus_cmd = 0xdeadbeef; + static void * const bogus_addr = (void *) -1L; + static const int bogus_flags = 0xface1e55 & ~IPC_CREAT; + + assert(msgget(bogus_key, bogus_flags) == -1); + printf("msgget\\(%#llx, %s%s%s%#x\\|%#04o\\) += %s\n", + zero_extend_signed_to_ull(bogus_key), + IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "", + IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "", + IPC_NOWAIT & bogus_flags ? "IPC_NOWAIT\\|" : "", + bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | IPC_NOWAIT), + bogus_flags & 0777, + sprintrc_grep(-1)); + id = msgget(private_key, 0600); if (id < 0) perror_msg_and_skip("msgget"); printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id); atexit(cleanup); + assert(msgctl(bogus_msgid, bogus_cmd, NULL) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?%#x /\\* MSG_\\?\\?\\? \\*/, NULL\\) " + "+= %s\n", bogus_msgid, bogus_cmd, sprintrc_grep(-1)); + + assert(msgctl(bogus_msgid, IPC_SET, bogus_addr) == -1); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, %p\\) += %s\n", + bogus_msgid, bogus_addr, sprintrc_grep(-1)); + if (msgctl(id, IPC_STAT, )) perror_msg_and_skip("msgctl IPC_STAT"); - printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, gid=%u, " - "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, msg_rtime=%u, " - "msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, " - "msg_lrpid=%u\\}\\) += 0\n", + printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, " + "msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, " + "msg_lspid=%u, msg_lrpid=%u\\}\\) += 0\n", id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, (unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key, (unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid, @@ -70,6 +99,13 @@ main(void) (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid, (unsigned) ds.msg_lrpid); + if (msgctl(id, IPC_SET, )) + perror_msg_and_skip("msgctl IPC_SET"); + printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, \\{msg_perm=\\{uid=%u, " + "gid=%u, mode=%#o\\}, ...\\}\\) += 0\n", + id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid, + (unsigned) ds.msg_perm.mode); + rc = msgctl(0, MSG_INFO, ); printf("msgctl\\(0, (IPC_64\\|)?MSG_INFO, %p\\) += %s\n", , sprintrc_grep(rc)); diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c index 01445e5..5ae3eb1 100644 --- a/tests/ipc_sem.c +++ b/tests/ipc_sem.c @@ -27,11 +27,15 @@ */ #include "tests.h" +#include #include #include #include #include +#include "xlat.h" +#include "xlat/resource_flags.h" + union semun { int val;/* Value for SETVAL */ struct semid_ds *buf;/* Buffer for IPC_STAT, IPC_SET */ @@ -55,17 +59,42 @@ main(void) { static const key_t private_key = (key_t) (0xULL | IPC_PRIVATE); + static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL; + static const int bogus_semid = 0xfdb97531; + static const int bogus_semnum = 0xeca86420; + static const int bogus_size = 0xdec0ded1; + static const int bogus_flags = 0xface1e55; +
Re: [PATCH v3 2/2] tests: Workaroud for buggy glibc in ipc_msg test on ppc64
On Tue, Sep 13, 2016 at 7:32 AM, Andreas Schwab <sch...@suse.de> wrote: > On Sep 13 2016, Eugene Syromyatnikov > <evgsyr-re5jqeeqqe8avxtiumw...@public.gmane.org> wrote: > >> glibc before 2.23 (glibc-2.22-122-gbe48165? to be more precise) tried to >> access >> data pointed by third argument of msgctl call on 64-bit PowerPC which led to >> segmentataion fault (instead of EFAULT from kernel). > > Which is a perfectly valid thing to do, as passing an invalid pointer to > msgctl (the libc function) invokes undefined behaviour. If you want to > test the kernel behaviour you need to talk to the kernel directly. Well, http://man7.org/linux/man-pages/man2/msgctl.2.html documents this case as EFAULT (and I assume it documents glibc wrapper since it usually does so and kernel interface is architecture-dependent). > Andreas. > > -- > Andreas Schwab, SUSE Labs, sch...@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 > "And now for something completely different." > > -- > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 5/8] keyctl: Print errno name in KEYCTL_REJECT in case it is available
* keyctl.c (keyctl_reject_key): Get errno string via err_name and print it if it is not NULL. --- keyctl.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/keyctl.c b/keyctl.c index c9081b7..1fb1da5 100644 --- a/keyctl.c +++ b/keyctl.c @@ -175,8 +175,16 @@ static void keyctl_reject_key(struct tcb *tcp, key_serial_t id1, unsigned timeout, unsigned error, key_serial_t id2) { + const char *err_str = err_name(error); + print_keyring_serial_number(id1); - tprintf(", %u, %u, ", timeout, error); + tprintf(", %u, ", timeout); + + if (err_str) + tprintf("%s, ", err_str); + else + tprintf("%u, ", error); + print_keyring_serial_number(id2); } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 8/8] tests: Add add_key, keyctl, request_key tests
* tests/Makefile.am (DECODER_TESTS): Add add_key.test, keyctl.test, request_key.test. (check_PROGRAMS): Add add_key, keyctl, request_key. * tests/.gitignore: Likewise. * tests/add_key.c: New file. * tests/add_key.test: Likewise. * tests/keyctl.c: Likewise. * tests/keyctl.test: Likewise. * tests/request_key.c: Likewise. * tests/request_key.test: Likewise. --- tests/.gitignore |3 + tests/Makefile.am |6 + tests/add_key.c| 128 + tests/add_key.test |6 + tests/keyctl.c | 713 tests/keyctl.test |6 + tests/request_key.c| 124 + tests/request_key.test |6 + 8 files changed, 992 insertions(+) create mode 100644 tests/add_key.c create mode 100755 tests/add_key.test create mode 100644 tests/keyctl.c create mode 100755 tests/keyctl.test create mode 100644 tests/request_key.c create mode 100755 tests/request_key.test diff --git a/tests/.gitignore b/tests/.gitignore index 9ee036b..5b33416 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -10,6 +10,7 @@ accept accept4 access acct +addkey adjtimex aio alarm @@ -117,6 +118,7 @@ ipc_msg ipc_msgbuf ipc_sem ipc_shm +keyctl kill ksysent ksysent.h @@ -208,6 +210,7 @@ remap_file_pages rename renameat renameat2 +request_key restart_syscall rmdir rt_sigpending diff --git a/tests/Makefile.am b/tests/Makefile.am index 86672fc..0c24969 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -69,6 +69,7 @@ check_PROGRAMS = \ accept4 \ access \ acct \ + add_key \ adjtimex \ aio \ alarm \ @@ -176,6 +177,7 @@ check_PROGRAMS = \ ipc_msgbuf \ ipc_sem \ ipc_shm \ + keyctl \ kill \ ksysent \ lchown \ @@ -265,6 +267,7 @@ check_PROGRAMS = \ rename \ renameat \ renameat2 \ + request_key \ restart_syscall \ rmdir \ rt_sigpending \ @@ -414,6 +417,7 @@ DECODER_TESTS = \ accept4.test \ access.test \ acct.test \ + add_key.test \ adjtimex.test \ aio.test \ alarm.test \ @@ -518,6 +522,7 @@ DECODER_TESTS = \ ipc_msgbuf.test \ ipc_sem.test \ ipc_shm.test \ + keyctl.test \ kill.test \ lchown.test \ lchown32.test \ @@ -601,6 +606,7 @@ DECODER_TESTS = \ rename.test \ renameat.test \ renameat2.test \ + request_key.test \ rmdir.test \ rt_sigpending.test \ rt_sigprocmask.test \ diff --git a/tests/add_key.c b/tests/add_key.c new file mode 100644 index 000..0773823 --- /dev/null +++ b/tests/add_key.c @@ -0,0 +1,128 @@ +#include "tests.h" + +#include + +#ifdef __NR_add_key + +# include +# include +# include + +void +print_val_str(const void *ptr, const char *str) +{ + if (str) + printf("%s, ", str); + else + printf("%p, ", ptr); +} + +void +do_add_key(const char *type, const char *type_str, const char *desc, + const char *desc_str, const char *payload, const char *payload_str, + size_t plen, int32_t keyring, const char *keyring_str) +{ + long rc; + + rc = syscall(__NR_add_key, type, desc, payload, plen, keyring); + printf("add_key("); + print_val_str(type, type_str); + print_val_str(desc, desc_str); + print_val_str(payload, payload_str); + printf("%zu, ", plen); + if (keyring_str) + printf("%s", keyring_str); + else + printf("%d", keyring); + printf(") = %s\n", sprintrc(rc)); +} + +# define _STR(_arg) #_arg +# define ARG_STR(_arg) (_arg), #_arg + +int +main(void) +{ + static const char unterminated1[] = { '\1', '\2', '\3', '\4', '\5' }; + static const char unterminated2[] = { '\6', '\7', '\10', '\11', '\12' }; + static const char unterminated3[] = + { '\16', '\17', '\20', '\21', '\22' }; + + char *bogus_type = tail_memdup(unterminated1, sizeof(unterminated1)); + char *bogus_desc = tail_memdup(unterminated2, sizeof(unterminated2)); + char *bogus_payload = tail_memdup(unterminated3, sizeof(unterminated3)); + + unsigned i; + unsigned j; + unsigned k; + unsigned l; + + struct { + const char *type; + const char *str; + } types[] = { + { ARG_STR(NULL) }, + { (const char *) 0xfee1fbadULL, NULL }, + { bogus_type, NULL }, + { ARG_STR("\20\21\22\23\24") }, + { ARG_STR("user") }, + }; + + struct { + const char *desc; + const char *str; + } descs[] = { + { ARG_STR(NULL) }, + { (const char *) 0xf00dfca7ULL, NULL }, + { bogus_desc, NULL }, + { ARG_STR("\25\26\27\30\31") }, + {
[PATCH 6/8] keyctl: Add support for KEYCTL_DH_COMPUTE
* keyctl.c (struct keyctl_dh_params): New structure. (print_dh_params): New function. (keyctl_dh_compute): New function. (SYS_FUNC(keyctl)): Add support for KEYCTL_DH_COMPUTE cmd value. --- keyctl.c | 46 ++ 1 file changed, 46 insertions(+) diff --git a/keyctl.c b/keyctl.c index 1fb1da5..0a9953e 100644 --- a/keyctl.c +++ b/keyctl.c @@ -31,6 +31,12 @@ typedef int32_t key_serial_t; #include "xlat/key_spec.h" +struct keyctl_dh_params { + int32_t private; + int32_t prime; + int32_t base; +}; + static void print_keyring_serial_number(key_serial_t id) { @@ -213,6 +219,41 @@ keyctl_setperm_key(struct tcb *tcp, key_serial_t id, uint32_t perm) printflags(key_perms, perm, "KEY_???"); } +static void +print_dh_params(struct tcb *tcp, long addr) +{ + struct keyctl_dh_params params; + + if (umove_or_printaddr(tcp, addr, )) + return; + + tprints("{private="); + print_keyring_serial_number(params.private); + tprints(", prime="); + print_keyring_serial_number(params.prime); + tprints(", base="); + print_keyring_serial_number(params.base); + tprints("}"); +} + +static void +keyctl_dh_compute(struct tcb *tcp, long params, long buf, long len) +{ + if (entering(tcp)) { + print_dh_params(tcp, params); + tprints(", "); + } else { + if (syserror(tcp)) + printaddr(buf); + else { + long rval = tcp->u_rval > len ? + len : (tcp->u_rval ? -1 : 0); + printstr(tcp, buf, rval); + } + tprintf(", %lu", len); + } +} + #include "xlat/key_reqkeys.h" #include "xlat/keyctl_commands.h" @@ -314,6 +355,11 @@ SYS_FUNC(keyctl) keyctl_get_persistent(tcp, tcp->u_arg[1], tcp->u_arg[2]); break; + case KEYCTL_DH_COMPUTE: + keyctl_dh_compute(tcp, tcp->u_arg[1], tcp->u_arg[2], + tcp->u_arg[3]); + return 0; + default: tprintf("%#llx, %#llx, %#llx, %#llx", getarg_ull(tcp, 1), getarg_ull(tcp, 2), -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 1/8] keyctl: Use printuid for printing UID/GID
UID/GID are unsigned except special -1 value (which is also special in context of specific keyctl commands), so special printing function should be used. * keyctl.c (keyctl_chown_key): Use printuid instead of printf with "%d" conversion for printing UID/GID. (keyctl_get_persistent): Likewise. --- keyctl.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/keyctl.c b/keyctl.c index 456649e..ecb3e79 100644 --- a/keyctl.c +++ b/keyctl.c @@ -136,7 +136,8 @@ static void keyctl_chown_key(struct tcb *tcp, key_serial_t id, int user, int group) { print_keyring_serial_number(id); - tprintf(", %d, %d", user, group); + printuid(", ", user); + printuid(", ", group); } static void @@ -189,7 +190,8 @@ keyctl_set_timeout(struct tcb *tcp, key_serial_t id, unsigned timeout) static void keyctl_get_persistent(struct tcb *tcp, int uid, key_serial_t id) { - tprintf("%d, ", uid); + printuid("", uid); + tprintf(", "); print_keyring_serial_number(id); } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 0/8] keyctl tests
Hello. This patchset provides minor updates to decoders in keyctl.c along with tests for add_key, keyctl, and request_key syscall decoders. Eugene Syromyatnikov (8): keyctl: Use printuid for printing UID/GID keyctl: Use getarg_ull for printing generic arguments keyctl: Do not print comma for KEYCTL_SESSION_TO_PARENT command Add function for getting errno string. keyctl: Print errno name in KEYCTL_REJECT in case it is available keyctl: Add support for KEYCTL_DH_COMPUTE io: Handle data_size of -1 as unlimited data in print_iovec tests: Add add_key, keyctl, request_key tests defs.h |1 + io.c |6 +- keyctl.c | 76 +- syscall.c |9 + tests/.gitignore |3 + tests/Makefile.am |6 + tests/add_key.c| 128 + tests/add_key.test |6 + tests/keyctl.c | 713 tests/keyctl.test |6 + tests/request_key.c| 124 + tests/request_key.test |6 + 12 files changed, 1075 insertions(+), 9 deletions(-) create mode 100644 tests/add_key.c create mode 100755 tests/add_key.test create mode 100644 tests/keyctl.c create mode 100755 tests/keyctl.test create mode 100644 tests/request_key.c create mode 100755 tests/request_key.test -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 7/8] io: Handle data_size of -1 as unlimited data in print_iovec
Otherwise it can be depleted and print_iovec starts printing empty strings. * io.c (print_iovec): Interpret c->data_size of -1 as unlimited data and do not decrease it in this case. --- io.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/io.c b/io.c index 907f9d2..eb17524 100644 --- a/io.c +++ b/io.c @@ -85,13 +85,15 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) case IOV_DECODE_STR: if (len > c->data_size) len = c->data_size; - c->data_size -= len; + if (c->data_size != (unsigned long)-1L) + c->data_size -= len; printstr(tcp, iov[0], len); break; case IOV_DECODE_NETLINK: if (len > c->data_size) len = c->data_size; - c->data_size -= len; + if (c->data_size != (unsigned long)-1L) + c->data_size -= len; decode_netlink(tcp, iov[0], iov[1]); break; default: -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 2/8] keyctl: Use getarg_ull for printing generic arguments
Otherwise it is erroneous on x32, for example. * keyctl.c (SYS_FUNC(keyctl)): Use "%#llx" conversion specifier and getarg_ull for fallback argument printing. --- keyctl.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyctl.c b/keyctl.c index ecb3e79..a0bbbd0 100644 --- a/keyctl.c +++ b/keyctl.c @@ -301,9 +301,9 @@ SYS_FUNC(keyctl) break; default: - tprintf("%#lx, %#lx, %#lx, %#lx", - tcp->u_arg[1], tcp->u_arg[2], - tcp->u_arg[3], tcp->u_arg[4]); + tprintf("%#llx, %#llx, %#llx, %#llx", + getarg_ull(tcp, 1), getarg_ull(tcp, 2), + getarg_ull(tcp, 3), getarg_ull(tcp, 4)); break; } -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 4/8] Add function for getting errno string.
* syscall.c (err_name): New function. * defs.h: Add declaration of err_name(). --- defs.h|1 + syscall.c |9 + 2 files changed, 10 insertions(+) diff --git a/defs.h b/defs.h index ffea23f..1e2363b 100644 --- a/defs.h +++ b/defs.h @@ -457,6 +457,7 @@ extern void clear_regs(void); extern void get_regs(pid_t pid); extern int get_scno(struct tcb *tcp); extern const char *syscall_name(long scno); +const char *err_name(unsigned err); extern bool is_erestart(struct tcb *); extern void temporarily_clear_syserror(struct tcb *); diff --git a/syscall.c b/syscall.c index f649a90..ee2d8cc 100644 --- a/syscall.c +++ b/syscall.c @@ -765,6 +765,15 @@ syscall_name(long scno) } } +const char * +err_name(unsigned err) +{ + if ((err < nerrnos) && errnoent[err]) + return errnoent[err]; + + return NULL; +} + static long get_regs_error; void -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 3/8] keyctl: Do not print comma for KEYCTL_SESSION_TO_PARENT command
Since this command doesn't have any additional arguments, the comma does not needed. Since this is the only command which lacks additional arguments, it's better to add special case for it rather than add printing of comma to all other commands. * keyctl.c (SYS_FUNC(keyctl)): Add check for command not being KEYCTL_SESSION_TO_PARENT when printing comma dividing cmd argument from the rest. --- keyctl.c |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keyctl.c b/keyctl.c index a0bbbd0..c9081b7 100644 --- a/keyctl.c +++ b/keyctl.c @@ -214,7 +214,13 @@ SYS_FUNC(keyctl) if (entering(tcp)) { printxval(keyctl_commands, cmd, "KEYCTL_???"); - tprints(", "); + + /* +* For now, KEYCTL_SESSION_TO_PARENT is the only cmd without +* arguments. +*/ + if (cmd != KEYCTL_SESSION_TO_PARENT) + tprints(", "); } switch (cmd) { -- 1.7.10.4 -- ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: strace 4.14 released
On Wed, Oct 5, 2016 at 9:08 AM, Andreas Schwabwrote: > I'm seeing this testsuite failure: > > https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:Factory/strace/s/s390x > > FAIL: count > === > > Pattern of expected output: *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep > Actual output: > % time seconds usecs/call callserrors syscall > -- --- --- - - > 99.971.286494 1286494 1 nanosleep > 0.010.000102 102 1 execve > 0.010.77 13 6 mmap > 0.000.40 13 3 mprotect > 0.000.26 13 2 open > 0.000.22 11 2 close > 0.000.22 11 2 fstat > 0.000.14 14 1 munmap > 0.000.13 13 1 1 access > 0.000.12 12 1 read > 0.000.12 12 1 brk > -- --- --- - - > 100.001.28683421 1 total > count.test: failed test: ../strace -cw ./sleep 1 output mismatch Well, this is sort of intentional and means that nanosleep is not precise enough (due to various reasons). Dmitry described his view on the matter: "The test checks, in particular, whether "strace -c" shows a reasonable value in "seconds" column, by invoking nanosleep with 1 second argument. On very slow systems, that syscall may take arbitrary amount of time. I wouldn't like to relax the regexp as it would make the test result less reliable." — https://sourceforge.net/p/strace/mailman/message/35250158/ May be you have any ideas regarding possibilities of fixing the environment in order to get nanosleep? Or is it confirmed issue on zSeries? > > Andreas. > > -- > Andreas Schwab, SUSE Labs, sch...@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 > "And now for something completely different." > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: strace 4.14 released
On Wed, Oct 5, 2016 at 9:35 AM, Andreas Schwab <sch...@suse.de> wrote: > On Okt 05 2016, Eugene Syromyatnikov > <evgsyr-re5jqeeqqe8avxtiumw...@public.gmane.org> wrote: > >> May be you have any ideas regarding possibilities of fixing the >> environment in order to get nanosleep? > > What do you mean with "in order to get nanosleep"? In order to get nanosleep with usable precision, sorry. > Andreas. > > -- > Andreas Schwab, SUSE Labs, sch...@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 > "And now for something completely different." > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: strace 4.14 released
On Wed, Oct 5, 2016 at 9:56 AM, Andreas Schwab <sch...@suse.de> wrote: > On Okt 05 2016, Eugene Syromyatnikov > <evgsyr-re5jqeeqqe8avxtiumw...@public.gmane.org> wrote: > >> On Wed, Oct 5, 2016 at 9:35 AM, Andreas Schwab >> <schwab-l3a5bk7w...@public.gmane.org> wrote: >>> On Okt 05 2016, Eugene Syromyatnikov >>> <evgsyr-re5jqeeqqe8avxtiumwx3w-xmd5yjdbdmrexy1tmh2...@public.gmane.org> >>> wrote: >>> >>>> May be you have any ideas regarding possibilities of fixing the >>>> environment in order to get nanosleep? >>> >>> What do you mean with "in order to get nanosleep"? >> In order to get nanosleep with usable precision, sorry. > > What is a "usable precision"? The only guarantee is that it isn't > shorter. Sure, but the test is aimed at checking whether strace's time accounting (-c option) works correctly and such a significant offset (more than 20%, on a single nanosleep call waiting for 1 second) may mean that something going wrong. Frankly speaking, i haven't seen such a big skew on x86_64 systems with recent kernels even with rather intensive I/O and quite high LA (and it never occurred on a multitude of OBS builds i ran on x86_64, ppc and arm), so i assumed, taking into account previous report, that it might be something more persistent and complex than just high system load. > Andreas. > > -- > Andreas Schwab, SUSE Labs, sch...@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 > "And now for something completely different." > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: basic questions to strace
On Fri, Oct 7, 2016 at 4:08 PM, Lentes, Bernd <bernd.len...@helmholtz-muenchen.de> wrote: > > > - On Oct 7, 2016, at 3:59 PM, Eugene Syromyatnikov evg...@gmail.com wrote: > > >>> Starting a process give me this error in the log: >>> traps: nsrexecd[12162] general protection ip:7f085e4cb960 sp:7f085a4e9278 >>> error:0 in libpthread-2.23.so[7f085e4b9000+18000] >>> It seems that the kernel is stopping the process because of ... what with a >>> signal. >> For debugging segmentation faults, i'd recommend installing debuginfo >> packages, >> enabling core file saving and then checking them out with gdb, usually it >> allows >> pinpointing problem rather quickly. > > Is that a segmentation fault ? Well, I assume so by "general protection" message from your excerpt, which is printed when there is unhandled SIGSEGV, iirc. > >> Clone is rather comprehensive syscall by means that it is used for several >> different tasks. Which arguments are used depends on flags provided, and >> strace >> prints only arguments actually used (for brevity, i suppose). Syscall >> arguments >> parsing for clone call is done as follows (clone.c in strace source): >> > > Ah. So clone is called with all arguments but strace shows just the relevant ? > Does strace have this behaviour also with other system calls ? Yes. futex, fcntl, prctl, quotact, keyctl, ptrace are examples of such syscalls. >>> What means the return code 13025 ? I didn't find anything about it in the >>> net. >>> Is there s.th. where i can get further information ? >> On success, clone returns ID of the child process to the parent. You can >> check >> it out in the "RETURN VALUE" section of the manual. >> > > Sorry, i didn't read completely. Because the return code was != 0, i thought > it's an error code. Some syscalls return positive values in case of success, mostly the ones which provide fd as a result, but there are other examples of such behaviour. Only negative value indicates an error (in all cases i'm aware of, at least). >>> I installed the kernel sources and searched for a file like clone.h or >>> clone.c, >>> but didn't find anything. >> Please check out kernel/fork.c file in kernel tree, it contains >> SYSCALL_DEFINE[56](clone, ...), which calls _do_fork(). >> > > I installed the debian-kerbel via apt. > But it didn't install it completely, just downloaded a tar which i need to > extract manually. > Why do i have a package management ? There is linux-source package available in Debian. You can also do apt-get source linux-image and obtain deb-src which would also contain kernel sources. > > Bernd > > > Helmholtz Zentrum Muenchen > Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH) > Ingolstaedter Landstr. 1 > 85764 Neuherberg > www.helmholtz-muenchen.de > Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe > Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Dr. Alfons Enhsen > Registergericht: Amtsgericht Muenchen HRB 6466 > USt-IdNr: DE 129521671 > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Strace-devel mailing list > Strace-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/strace-devel -- Eugene "eSyr" Syromyatnikov mailto:evg...@gmail.com xmpp:eSyr@jabber.{ru|org} -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
Re: basic questions to strace
On Fri, Oct 7, 2016 at 1:16 PM, Lentes, Berndwrote: > Hi, > > i'm a system administrator, not a developer. I use strace sometimes for > debugging problems, and i like it very much. Nice tool. > I have some principal questions and hope this is the right place to ask. If > not please inform me and maybe give me a hint > where a more aprropriate place would be. > > From what i understand until now is that processes normally don't invoke > system calls directly, they contact libraries which do it for them. > > Starting a process give me this error in the log: > traps: nsrexecd[12162] general protection ip:7f085e4cb960 sp:7f085a4e9278 > error:0 in libpthread-2.23.so[7f085e4b9000+18000] > It seems that the kernel is stopping the process because of ... what with a > signal. For debugging segmentation faults, i'd recommend installing debuginfo packages, enabling core file saving and then checking them out with gdb, usually it allows pinpointing problem rather quickly. > I observed the process /usr/sbin/nsrexecd with strace. > Here seems to be the problem: > > open("/dev/null", O_RDWR) = 3 > close(3)= 0 > clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, > child_tidptr=0x7fac73d019d0) = 13025 > rt_sigaction(SIGTERM, {0x4275e0, [HUP INT USR1 USR2 PIPE ALRM TERM CHLD XCPU > XFSZ], SA_RESTORER, 0x7fac72ce83d0}, NULL, 8) = 0 > rt_sigaction(SIGCHLD, {0x4275e0, [HUP INT USR1 USR2 PIPE ALRM TERM CHLD XCPU > XFSZ], SA_RESTORER, 0x7fac72ce83d0}, NULL, 8) = 0 > select(0, NULL, NULL, NULL, {300, 0}) = ? ERESTARTNOHAND (To be restarted > if no handler) Calling select with zero nfds and NULL fd sets is rather strange. > --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=13025, si_uid=0} --- > rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call) > exit_group(0) = ? > +++ exited with 0 +++ > > clone is a syscall for creating a child process, right ? > > man 2 clone says: > >/* Prototype for the glibc wrapper function */ > >#include > >int clone(int (*fn)(void *), void *child_stack, > int flags, void *arg, ... > /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ ); > >/* Prototype for the raw system call */ > >long clone(unsigned long flags, void *child_stack, > void *ptid, void *ctid, > struct pt_regs *regs); > > > What i don't understand: > The syscall is called with three arguments, right ? But the wrapper function > expects ... how many arguments ? What means ... ? Does it expect 7 arguments ? > And the syscall itself has 5 arguments, but it is called just with three. > Does that work ? Which ones are the these which are used ? The first three ? > The last three ? Clone is rather comprehensive syscall by means that it is used for several different tasks. Which arguments are used depends on flags provided, and strace prints only arguments actually used (for brevity, i suppose). Syscall arguments parsing for clone call is done as follows (clone.c in strace source): const char *sep = "|"; unsigned long flags = tcp->u_arg[ARG_FLAGS]; tprints("child_stack="); printaddr(tcp->u_arg[ARG_STACK]); tprints(", "); #ifdef ARG_STACKSIZE if (ARG_STACKSIZE != -1) tprintf("stack_size=%#lx, ", tcp->u_arg[ARG_STACKSIZE]); #endif tprints("flags="); if (!printflags(clone_flags, flags &~ CSIGNAL, NULL)) sep = ""; if ((flags & CSIGNAL) != 0) tprintf("%s%s", sep, signame(flags & CSIGNAL)); if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0) return 0; if (flags & CLONE_PARENT_SETTID) { tprints(", parent_tidptr="); printaddr(tcp->u_arg[ARG_PTID]); } if (flags & CLONE_SETTLS) { #if defined I386 || defined X86_64 || defined X32 # ifndef I386 if (current_personality == 1) # endif { tprints(", tls="); print_user_desc(tcp, tcp->u_arg[ARG_TLS]); } # ifndef I386 else # endif #endif /* I386 || X86_64 || X32 */ { tprints(", tls="); printaddr(tcp->u_arg[ARG_TLS]); } } if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID)) { tprints(", child_tidptr="); printaddr(tcp->u_arg[ARG_CTID]); } As you can see, parent_tidptr, child_tidptr and tls arguments are printed only in case appropriate flags are provided (they are used for thread creation, mostly). > What means the return code 13025 ? I didn't find anything about it in the > net. Is there s.th.
[PATCH 11/21] dm: Compare entering field values with exiting ones
--- dm.c | 74 -- tests/ioctl_dm.c | 26 +++ 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/dm.c b/dm.c index f23a65d..b6fb11d 100644 --- a/dm.c +++ b/dm.c @@ -282,28 +282,62 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra, static int dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) { - struct dm_ioctl ioc; + struct dm_ioctl *ioc; + struct dm_ioctl *entering_ioc = NULL; + bool ioc_changed = false; char *extra = NULL; uint32_t extra_size = 0; - if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), ) < 0) + ioc = malloc(sizeof(* ioc)); + if (!ioc) return 0; + + if (umoven(tcp, arg, sizeof(*ioc) - sizeof(ioc->data), ioc) < 0) { + free(ioc); + return 0; + } + if (entering(tcp)) + set_tcb_priv_data(tcp, ioc, free); + else { + entering_ioc = get_tcb_priv_data(tcp); + + /* +* retrieve_status, __dev_status called only in case of success, +* so it looks like there's no need to check open_count, +* event_nr, target_count, dev fields for change (they are +* printed only in case of absence of errors). +*/ + if (!entering_ioc || + (ioc->version[0] != entering_ioc->version[0]) || + (ioc->version[1] != entering_ioc->version[1]) || + (ioc->version[2] != entering_ioc->version[2]) || + (ioc->data_size != entering_ioc->data_size) || + (ioc->data_start != entering_ioc->data_start) || + (ioc->flags != entering_ioc->flags)) + ioc_changed = true; + } + + if (exiting(tcp) && syserror(tcp) && !ioc_changed) { + free(ioc); + return 1; + } + tprintf("%s{version=%d.%d.%d", entering(tcp) ? ", " : " => ", - ioc.version[0], ioc.version[1], ioc.version[2]); + ioc->version[0], ioc->version[1], ioc->version[2]); /* * if we use a different version of ABI, do not attempt to decode * ioctl fields */ - if (ioc.version[0] != DM_VERSION_MAJOR) { + if (ioc->version[0] != DM_VERSION_MAJOR) { tprints(", /* Unsupported device mapper ABI version */ ..."); goto skip; } - if (ioc.data_size > sizeof(ioc)) { - extra = malloc(ioc.data_size); + if (ioc->data_size > sizeof(ioc)) { + extra = malloc(ioc->data_size); if (extra) { - extra_size = ioc.data_size; + extra_size = ioc->data_size; if (umoven(tcp, arg, extra_size, extra) < 0) { free(extra); extra = NULL; @@ -311,9 +345,9 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) } } } - dm_decode_device(code, ); - dm_decode_values(tcp, code, ); - dm_decode_flags(); + dm_decode_device(code, ioc); + dm_decode_values(tcp, code, ioc); + dm_decode_flags(ioc); if (abbrev(tcp)) tprints(", ..."); else @@ -322,42 +356,42 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) case DM_TABLE_STATUS: if (entering(tcp) || syserror(tcp)) break; - dm_decode_dm_target_spec(tcp, , extra, extra_size); + dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); break; case DM_TABLE_LOAD: if (!entering(tcp)) break; - dm_decode_dm_target_spec(tcp, , extra, extra_size); + dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); break; case DM_TABLE_DEPS: if (entering(tcp) || syserror(tcp)) break; - dm_decode_dm_target_deps(, extra, extra_size); + dm_decode_dm_target_deps(ioc, extra, extra_size); break; case DM_LIST_DEVICES: if (entering(tcp) || syserror(tcp)) break; - dm_decode_dm_name_list(, extra, extra_size); + dm_decode_dm_name_list(ioc, extra, extra_size); break; case DM_LIST_VERSIONS: if (entering(tcp) || syserror(tcp)) break; - dm_decode_dm_target_versions(,
[PATCH 12/21] dm: Add inttypes.h, include reorder
Build failed otherwise on RHEL 5. --- dm.c |3 ++- tests/ioctl_dm.c |1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index b6fb11d..a11196f 100644 --- a/dm.c +++ b/dm.c @@ -2,8 +2,9 @@ #ifdef HAVE_LINUX_DM_IOCTL_H -# include +# include # include +# include # if DM_VERSION_MAJOR == 4 diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index 31f474c..94dbe93 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -1,4 +1,5 @@ #include "tests.h" +#include #include #include #include -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 09/21] dm: Remove char * cast
--- dm.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm.c b/dm.c index adfa97e..3ee74c3 100644 --- a/dm.c +++ b/dm.c @@ -286,7 +286,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) char *extra = NULL; uint32_t extra_size = 0; - if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), (char *) ) < 0) + if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), ) < 0) return 0; tprintf(", {version=%d.%d.%d", ioc.version[0], ioc.version[1], ioc.version[2]); -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 06/21] dm: Some future-proofing by means of compile-time DM_VERSION_MAJOR check
* dm.c: Add check whether DM_VERSION_MAJOR equals to 4, provide empty dm_ioctl if check fails. --- dm.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index ebdfc44..79bb7c7 100644 --- a/dm.c +++ b/dm.c @@ -5,6 +5,8 @@ # include # include +# if DM_VERSION_MAJOR == 4 + static void dm_decode_device(const unsigned int code, const struct dm_ioctl *ioc) { @@ -375,4 +377,13 @@ dm_ioctl(struct tcb *tcp, const unsigned int code, long arg) } } -#endif +# else /* !(DM_VERSION_MAJOR == 4) */ + +int +dm_ioctl(struct tcb *tcp, const unsigned int code, long arg) +{ + return 0; +} + +# endif /* DM_VERSION_MAJOR == 4 */ +#endif /* HAVE_LINUX_DM_IOCTL_H */ -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 05/21] xlat: Add values for dm_flags
Otherwise build fails on some old distros which lack DM_DATA_OUT_FLAG and other flags (excerpt from RHEL 5 build log): [ 66s] dm.c: In function 'dm_known_ioctl': [ 66s] dm.c:311: error: 'DM_DATA_OUT_FLAG' undeclared (first use in this function) [ 66s] dm.c:311: error: (Each undeclared identifier is reported only once [ 66s] dm.c:311: error: for each function it appears in.) Curiously, EXISTS flags had been present in v1 of DM interface, but was removed in v4. * xlat/dm_flags.in: Add values for DM_*_FLAG constants (obtained from ). --- xlat/dm_flags.in | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/xlat/dm_flags.in b/xlat/dm_flags.in index 1e7132b..fa734c8 100644 --- a/xlat/dm_flags.in +++ b/xlat/dm_flags.in @@ -1,19 +1,19 @@ -DM_READONLY_FLAG -DM_SUSPEND_FLAG +DM_READONLY_FLAG (1 << 0) +DM_SUSPEND_FLAG (1 << 1) /* Defined in lvm2/libdm/ioctl/libdm-iface.c */ -DM_EXISTS_FLAG 0x0004 -DM_PERSISTENT_DEV_FLAG -DM_STATUS_TABLE_FLAG -DM_ACTIVE_PRESENT_FLAG -DM_INACTIVE_PRESENT_FLAG -DM_BUFFER_FULL_FLAG -DM_SKIP_BDGET_FLAG -DM_SKIP_LOCKFS_FLAG -DM_NOFLUSH_FLAG -DM_QUERY_INACTIVE_TABLE_FLAG -DM_UEVENT_GENERATED_FLAG -DM_UUID_FLAG -DM_SECURE_DATA_FLAG -DM_DATA_OUT_FLAG -DM_DEFERRED_REMOVE -DM_INTERNAL_SUSPEND_FLAG +DM_EXISTS_FLAG (1 << 2) +DM_PERSISTENT_DEV_FLAG (1 << 3) +DM_STATUS_TABLE_FLAG (1 << 4) +DM_ACTIVE_PRESENT_FLAG (1 << 5) +DM_INACTIVE_PRESENT_FLAG (1 << 6) +DM_BUFFER_FULL_FLAG (1 << 8) +DM_SKIP_BDGET_FLAG (1 << 9) +DM_SKIP_LOCKFS_FLAG (1 << 10) +DM_NOFLUSH_FLAG (1 << 11) +DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) +DM_UEVENT_GENERATED_FLAG (1 << 13) +DM_UUID_FLAG (1 << 14) +DM_SECURE_DATA_FLAG (1 << 15) +DM_DATA_OUT_FLAG (1 << 16) +DM_DEFERRED_REMOVE (1 << 17) +DM_INTERNAL_SUSPEND_FLAG (1 << 18) -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 07/21] dm: Add definitions for ioctl commands not implemented initially
dm.c [!DM_LIST_VERSIONS] (DM_LIST_VERSIONS): New definition. [!DM_TARGET_MSG] (DM_TARGET_MSG): Likewise. [!DM_DEV_SET_GEOMETRY] (DM_DEV_SET_GEOMETRY): Likewise. --- dm.c | 13 + 1 file changed, 13 insertions(+) diff --git a/dm.c b/dm.c index 79bb7c7..66b615d 100644 --- a/dm.c +++ b/dm.c @@ -7,6 +7,19 @@ # if DM_VERSION_MAJOR == 4 +/* Definitions for command which have been added later */ + +# ifndef DM_LIST_VERSIONS +# define DM_LIST_VERSIONS_IOWR(DM_IOCTL, 0xd, struct dm_ioctl) +# endif +# ifndef DM_TARGET_MSG +# define DM_TARGET_MSG _IOWR(DM_IOCTL, 0xe, struct dm_ioctl) +# endif +# ifndef DM_DEV_SET_GEOMETRY +# define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, 0xf, struct dm_ioctl) +# endif + + static void dm_decode_device(const unsigned int code, const struct dm_ioctl *ioc) { -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 13/21] dm: Move printing of dm_ioctl fields before allocation of extra data
--- dm.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dm.c b/dm.c index a11196f..73a9b57 100644 --- a/dm.c +++ b/dm.c @@ -335,6 +335,10 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } + dm_decode_device(code, ioc); + dm_decode_values(tcp, code, ioc); + dm_decode_flags(ioc); + if (ioc->data_size > sizeof(ioc)) { extra = malloc(ioc->data_size); if (extra) { @@ -346,9 +350,6 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) } } } - dm_decode_device(code, ioc); - dm_decode_values(tcp, code, ioc); - dm_decode_flags(ioc); if (abbrev(tcp)) tprints(", ..."); else -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 15/21] dm: Additional data_size/data_start checks
--- dm.c |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index 814d7d2..289bc0d 100644 --- a/dm.c +++ b/dm.c @@ -293,7 +293,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) if (!ioc) return 0; - if (umoven(tcp, arg, sizeof(*ioc) - sizeof(ioc->data), ioc) < 0) { + if ((umoven(tcp, arg, sizeof(*ioc) - sizeof(ioc->data), ioc) < 0) || + (ioc->data_size < offsetof(struct dm_ioctl, data_size))) { free(ioc); return 0; } @@ -335,6 +336,11 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } + if (ioc->data_size < (sizeof(*ioc) - sizeof(ioc->data))) { + tprints(", /* Incorrect data_size */ ..."); + goto skip; + } + dm_decode_device(code, ioc); dm_decode_values(tcp, code, ioc); dm_decode_flags(ioc); -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 10/21] dm: use => instead of , for splitting output structure from input
--- dm.c |4 ++-- tests/ioctl_dm.c | 12 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dm.c b/dm.c index 3ee74c3..f23a65d 100644 --- a/dm.c +++ b/dm.c @@ -288,8 +288,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), ) < 0) return 0; - tprintf(", {version=%d.%d.%d", ioc.version[0], ioc.version[1], - ioc.version[2]); + tprintf("%s{version=%d.%d.%d", entering(tcp) ? ", " : " => ", + ioc.version[0], ioc.version[1], ioc.version[2]); /* * if we use a different version of ABI, do not attempt to decode diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index ba484ee..3c43913 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -42,7 +42,7 @@ main(void) ioctl(-1, DM_VERSION, ); printf("ioctl(-1, DM_VERSION, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0}, " + "uuid=\"uuu\", flags=0} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); @@ -58,7 +58,7 @@ main(void) printf("ioctl(-1, DM_TABLE_LOAD, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", target_count=1, flags=0, {sector_start=16, " - "length=32, target_type=\"tgt\", string=\"tparams\"}}, " + "length=32, target_type=\"tgt\", string=\"tparams\"}} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); @@ -69,7 +69,7 @@ main(void) ioctl(-1, DM_TARGET_MSG, ); printf("ioctl(-1, DM_TARGET_MSG, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0, {sector=4660, message=\"tmsg\"}}, " + "uuid=\"uuu\", flags=0, {sector=4660, message=\"tmsg\"}} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); @@ -78,7 +78,7 @@ main(void) ioctl(-1, DM_DEV_SET_GEOMETRY, ); printf("ioctl(-1, DM_DEV_SET_GEOMETRY, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0, string=\"10 20 30 40\"}, " + "uuid=\"uuu\", flags=0, string=\"10 20 30 40\"} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); @@ -87,7 +87,7 @@ main(void) ioctl(-1, DM_DEV_RENAME, ); printf("ioctl(-1, DM_DEV_RENAME, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", event_nr=0, flags=0, string=\"new-name\"}, " + "uuid=\"uuu\", event_nr=0, flags=0, string=\"new-name\"} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); @@ -98,7 +98,7 @@ main(void) "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", target_count=4294967295, flags=0, " "{sector_start=0, length=0, target_type=\"\", string=\"\"}, " - "/* misplaced struct dm_target_spec */ ...}, " + "/* misplaced struct dm_target_spec */ ...} => " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 17/21] dm: Add data_size and data_offset fields to output
--- dm.c |4 +++- tests/ioctl_dm.c | 41 - 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/dm.c b/dm.c index 5c908c9..caffc55 100644 --- a/dm.c +++ b/dm.c @@ -327,7 +327,6 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) tprintf("%s{version=%d.%d.%d", entering(tcp) ? ", " : " => ", ioc->version[0], ioc->version[1], ioc->version[2]); - /* * if we use a different version of ABI, do not attempt to decode * ioctl fields @@ -337,6 +336,9 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } + tprintf(", data_size=%u, data_start=%u", + ioc->data_size, ioc->data_start); + if (ioc->data_size < (sizeof(*ioc) - sizeof(ioc->data))) { tprints(", /* Incorrect data_size */ ..."); goto skip; diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index 94dbe93..6967ca2 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -42,8 +42,9 @@ main(void) s.ioc.data_start = 0; ioctl(-1, DM_VERSION, ); printf("ioctl(-1, DM_VERSION, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); + "{version=4.1.2, data_size=%zu, data_start=0, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0}) = " + "-1 EBADF (%m)\n", sizeof(s.ioc)); init_s(); s.ioc.target_count = 1; @@ -55,10 +56,11 @@ main(void) strcpy(s.u.ts.target_params, "tparams"); ioctl(-1, DM_TABLE_LOAD, ); printf("ioctl(-1, DM_TABLE_LOAD, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", target_count=1, flags=0, {sector_start=16, " + "{version=4.1.2, data_size=%u, data_start=%u, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", " + "target_count=1, flags=0, {sector_start=16, " "length=32, target_type=\"tgt\", string=\"tparams\"}}) = " - "-1 EBADF (%m)\n"); + "-1 EBADF (%m)\n", s.ioc.data_size, s.ioc.data_start); init_s(); s.u.tm.target_msg.sector = 0x1234; @@ -66,34 +68,39 @@ main(void) "tmsg"); ioctl(-1, DM_TARGET_MSG, ); printf("ioctl(-1, DM_TARGET_MSG, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0, {sector=4660, message=\"tmsg\"}}) = " - "-1 EBADF (%m)\n"); + "{version=4.1.2, data_size=%u, data_start=%u, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0, " + "{sector=4660, message=\"tmsg\"}}) = -1 EBADF (%m)\n", + s.ioc.data_size, s.ioc.data_start); init_s(); strcpy(s.u.string, "10 20 30 40"); ioctl(-1, DM_DEV_SET_GEOMETRY, ); printf("ioctl(-1, DM_DEV_SET_GEOMETRY, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", flags=0, string=\"10 20 30 40\"}) = " - "-1 EBADF (%m)\n"); + "{version=4.1.2, data_size=%u, data_start=%u, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0, " + "string=\"10 20 30 40\"}) = -1 EBADF (%m)\n", + s.ioc.data_size, s.ioc.data_start); init_s(); strcpy(s.u.string, "new-name"); ioctl(-1, DM_DEV_RENAME, ); printf("ioctl(-1, DM_DEV_RENAME, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", event_nr=0, flags=0, string=\"new-name\"}) = " - "-1 EBADF (%m)\n"); + "{version=4.1.2, data_size=%u, data_start=%u, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", event_nr=0, " + "flags=0, string=\"new-name\"}) = -1 EBADF (%m)\n", + s.ioc.data_size, s.ioc.data_start); init_s(); s.ioc.target_count = -1U; ioctl(-1, DM_TABLE_LOAD, ); printf("ioctl(-1, DM_TABLE_LOAD, " - "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " - "uuid=\"uuu\", target_count=4294967295, flags=0, " + "{version=4.1.2, data_size=%u, data_start=%u, " + "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", " + "target_count=4294967295, flags=0, " "{sector_start=0, length=0, target_type=\"\", string=\"\"}, " - "/* misplaced struct dm_target_spec */ ...}) = -1 EBADF (%m)\n"); + "/* misplaced struct dm_target_spec */ ...}) = -1 EBADF (%m)\n", + s.ioc.data_size, s.ioc.data_start); puts("+++ exited with 0 +++"); return 0; -- 1.7.10.4 -- Check out the vibrant tech community on one of the
[PATCH 14/21] dm: replace abbrev branching with goto
--- dm.c | 78 ++ 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/dm.c b/dm.c index 73a9b57..814d7d2 100644 --- a/dm.c +++ b/dm.c @@ -350,52 +350,54 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) } } } - if (abbrev(tcp)) + + if (abbrev(tcp)) { tprints(", ..."); - else - switch (code) { - case DM_DEV_WAIT: - case DM_TABLE_STATUS: - if (entering(tcp) || syserror(tcp)) - break; - dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); - break; - case DM_TABLE_LOAD: - if (!entering(tcp)) - break; - dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); + goto skip; + } + + switch (code) { + case DM_DEV_WAIT: + case DM_TABLE_STATUS: + if (entering(tcp) || syserror(tcp)) break; - case DM_TABLE_DEPS: - if (entering(tcp) || syserror(tcp)) - break; - dm_decode_dm_target_deps(ioc, extra, extra_size); + dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); + break; + case DM_TABLE_LOAD: + if (!entering(tcp)) break; - case DM_LIST_DEVICES: - if (entering(tcp) || syserror(tcp)) - break; - dm_decode_dm_name_list(ioc, extra, extra_size); + dm_decode_dm_target_spec(tcp, ioc, extra, extra_size); + break; + case DM_TABLE_DEPS: + if (entering(tcp) || syserror(tcp)) break; - case DM_LIST_VERSIONS: - if (entering(tcp) || syserror(tcp)) - break; - dm_decode_dm_target_versions(ioc, extra, extra_size); + dm_decode_dm_target_deps(ioc, extra, extra_size); + break; + case DM_LIST_DEVICES: + if (entering(tcp) || syserror(tcp)) break; - case DM_TARGET_MSG: - if (entering(tcp)) { - dm_decode_dm_target_msg(ioc, extra, - extra_size); - } else if (!syserror(tcp) && - ioc->flags & DM_DATA_OUT_FLAG) { - dm_decode_string(ioc, extra, extra_size); - } + dm_decode_dm_name_list(ioc, extra, extra_size); + break; + case DM_LIST_VERSIONS: + if (entering(tcp) || syserror(tcp)) break; - case DM_DEV_RENAME: - case DM_DEV_SET_GEOMETRY: - if (!entering(tcp)) - break; + dm_decode_dm_target_versions(ioc, extra, extra_size); + break; + case DM_TARGET_MSG: + if (entering(tcp)) { + dm_decode_dm_target_msg(ioc, extra, + extra_size); + } else if (!syserror(tcp) && ioc->flags & DM_DATA_OUT_FLAG) { dm_decode_string(ioc, extra, extra_size); - break; } + break; + case DM_DEV_RENAME: + case DM_DEV_SET_GEOMETRY: + if (!entering(tcp)) + break; + dm_decode_string(ioc, extra, extra_size); + break; + } skip: tprints("}"); -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 16/21] dm: Add comment regarding intended fall-through in switch statement
--- dm.c |1 + 1 file changed, 1 insertion(+) diff --git a/dm.c b/dm.c index 289bc0d..5c908c9 100644 --- a/dm.c +++ b/dm.c @@ -60,6 +60,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_DEV_SUSPEND: if (ioc->flags & DM_SUSPEND_FLAG) break; + /* Fall through */ case DM_DEV_RENAME: case DM_DEV_REMOVE: case DM_DEV_WAIT: -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 02/21] dm: whitespace fixes
--- dm.c | 87 +++--- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/dm.c b/dm.c index 33a3972..d81983d 100644 --- a/dm.c +++ b/dm.c @@ -2,8 +2,8 @@ #ifdef HAVE_LINUX_DM_IOCTL_H -#include -#include +# include +# include static void dm_decode_device(const unsigned int code, const struct dm_ioctl *ioc) @@ -38,7 +38,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, if (entering(tcp)) { switch (code) { case DM_TABLE_LOAD: - tprintf(", target_count=%"PRIu32"", + tprintf(", target_count=%" PRIu32, ioc->target_count); break; case DM_DEV_SUSPEND: @@ -47,7 +47,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_DEV_RENAME: case DM_DEV_REMOVE: case DM_DEV_WAIT: - tprintf(", event_nr=%"PRIu32"", + tprintf(", event_nr=%" PRIu32, ioc->event_nr); break; } @@ -63,11 +63,11 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_TABLE_DEPS: case DM_TABLE_STATUS: case DM_TARGET_MSG: - tprintf(", target_count=%"PRIu32"", + tprintf(", target_count=%" PRIu32, ioc->target_count); - tprintf(", open_count=%"PRIu32"", + tprintf(", open_count=%" PRIu32, ioc->open_count); - tprintf(", event_nr=%"PRIu32"", + tprintf(", event_nr=%" PRIu32, ioc->event_nr); break; } @@ -89,21 +89,23 @@ dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, { uint32_t i; uint32_t offset = ioc->data_start; + for (i = 0; i < ioc->target_count; i++) { - if (offset + (uint32_t)sizeof(struct dm_target_spec) >= offset && - offset + (uint32_t)sizeof(struct dm_target_spec) < extra_size) { + if (offset + (uint32_t) sizeof(struct dm_target_spec) >= offset && + offset + (uint32_t) sizeof(struct dm_target_spec) < extra_size) { uint32_t new_offset; const struct dm_target_spec *s = - (const struct dm_target_spec *)(extra + offset); - tprintf(", {sector_start=%"PRIu64", length=%"PRIu64"", - (uint64_t)s->sector_start, (uint64_t)s->length); + (const struct dm_target_spec *) (extra + offset); + tprintf(", {sector_start=%" PRIu64 ", length=%" PRIu64, + (uint64_t) s->sector_start, + (uint64_t) s->length); if (!entering(tcp)) - tprintf(", status=%"PRId32"", s->status); + tprintf(", status=%" PRId32, s->status); tprints(", target_type="); print_quoted_string(s->target_type, DM_MAX_TYPE_NAME, QUOTE_0_TERMINATED); tprints(", string="); - print_quoted_string((const char *)(s + 1), extra_size - + print_quoted_string((const char *) (s + 1), extra_size - (offset + sizeof(struct dm_target_spec)), QUOTE_0_TERMINATED); @@ -112,7 +114,8 @@ dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, new_offset = offset + s->next; else new_offset = ioc->data_start + s->next; - if (new_offset <= offset + (uint32_t)sizeof(struct dm_target_spec)) + if (new_offset <= offset + + (uint32_t) sizeof(struct dm_target_spec)) goto misplaced; offset = new_offset; } else { @@ -128,13 +131,15 @@ dm_decode_dm_target_deps(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; - if (offset + (uint32_t)offsetof(struct dm_target_deps, dev) >= offset && - offset + (uint32_t)offsetof(struct dm_target_deps, dev) <= extra_size) { + if (offset + (uint32_t) offsetof(struct dm_target_deps, dev) >= offset && + offset + (uint32_t) offsetof(struct dm_target_deps, dev) <= extra_size)
[PATCH 03/21] tests: Working around bounds check
When building with -Wp,-D_FORTIFY_SOURCE=2, dompiler produces the following warning: In file included from /usr/include/string.h:638:0, from ioctl_dm.c:4: In function ‘strcpy’, inlined from ‘main’ at ioctl_dm.c:57:8: /usr/include/bits/string3.h:104:3: warning: call to __builtin___strcpy_chk will always overflow destination buffer [enabled by default] return __builtin___strcpy_chk (__dest, __src, __bos (__dest)); ^ And later it aborts: [ 200s] FAIL: ioctl_dm [ 200s] == [ 200s] [ 200s] + ../strace -V [ 200s] + TIMEOUT='timeout -s 9 60' [ 200s] + timeout -s 9 60 true [ 200s] + exec timeout -s 9 60 ./ioctl_dm.test [ 200s] + run_prog [ 200s] + '[' 0 -eq 0 ']' [ 200s] + set -- ./ioctl_dm [ 200s] + args=./ioctl_dm [ 200s] + ./ioctl_dm [ 200s] *** buffer overflow detected ***: ./ioctl_dm terminated [ 200s] === Backtrace: = [ 200s] /lib64/libc.so.6(__fortify_fail+0x37)[0x7fbc8fa1acb7] [ 200s] /lib64/libc.so.6(+0x10be80)[0x7fbc8fa18e80] [ 200s] ./ioctl_dm[0x400616] [ 200s] /lib64/libc.so.6(__libc_start_main+0xf5)[0x7fbc8f92eaf5] [ 200s] ./ioctl_dm[0x400739] [ 200s] === Memory map: [ 200s] 0040-00401000 r-xp 08:00 84792 /home/abuild/rpmbuild/BUILD/strace-4.13.0.260.af086/tests/ioctl_dm [ 200s] 00601000-00602000 r--p 1000 08:00 84792 /home/abuild/rpmbuild/BUILD/strace-4.13.0.260.af086/tests/ioctl_dm [ 200s] 00602000-00603000 rw-p 2000 08:00 84792 /home/abuild/rpmbuild/BUILD/strace-4.13.0.260.af086/tests/ioctl_dm [ 200s] 02244000-02265000 rw-p 00:00 0 [heap] [ 200s] 7fbc8f6f5000-7fbc8f70a000 r-xp 08:00 131341 /usr/lib64/libgcc_s-4.8.2-20140120.so.1 [ 200s] 7fbc8f70a000-7fbc8f909000 ---p 00015000 08:00 131341 /usr/lib64/libgcc_s-4.8.2-20140120.so.1 [ 200s] 7fbc8f909000-7fbc8f90a000 r--p 00014000 08:00 131341 /usr/lib64/libgcc_s-4.8.2-20140120.so.1 [ 200s] 7fbc8f90a000-7fbc8f90b000 rw-p 00015000 08:00 131341 /usr/lib64/libgcc_s-4.8.2-20140120.so.1 [ 200s] 7fbc8f90d000-7fbc8fac3000 r-xp 08:00 131350 /usr/lib64/libc-2.17.so [ 200s] 7fbc8fac3000-7fbc8fcc3000 ---p 001b6000 08:00 131350 /usr/lib64/libc-2.17.so [ 200s] 7fbc8fcc3000-7fbc8fcc7000 r--p 001b6000 08:00 131350 /usr/lib64/libc-2.17.so [ 200s] 7fbc8fcc7000-7fbc8fcc9000 rw-p 001ba000 08:00 131350 /usr/lib64/libc-2.17.so [ 200s] 7fbc8fcc9000-7fbc8fcce000 rw-p 00:00 0 [ 200s] 7fbc8fcd5000-7fbc8fcf6000 r-xp 08:00 131343 /usr/lib64/ld-2.17.so [ 200s] 7fbc8fef1000-7fbc8fef5000 rw-p 00:00 0 [ 200s] 7fbc8fef5000-7fbc8fef6000 r--p 0002 08:00 131343 /usr/lib64/ld-2.17.so [ 200s] 7fbc8fef6000-7fbc8fef7000 rw-p 00021000 08:00 131343 /usr/lib64/ld-2.17.so [ 200s] 7fbc8fef7000-7fbc8fef9000 rw-p 00:00 0 [ 200s] 7ffe9b7e3000-7ffe9b806000 rw-p 00:00 0 [stack] [ 200s] 7ffe9b84d000-7ffe9b84f000 r--p 00:00 0 [vvar] [ 200s] 7ffe9b84f000-7ffe9b851000 r-xp 00:00 0 [vdso] [ 200s] ff60-ff601000 r-xp 00:00 0 [vsyscall] [ 200s] ./init.sh: line 53: 15162 Aborted "$@" [ 200s] + rc=134 [ 200s] + '[' 134 -eq 77 ']' [ 200s] + fail_ './ioctl_dm failed with code 134' [ 200s] + warn_ 'ioctl_dm.test: failed test: ./ioctl_dm failed with code 134' [ 200s] + printf '%s\n' 'ioctl_dm.test: failed test: ./ioctl_dm failed with code 134' [ 200s] ioctl_dm.test: failed test: ./ioctl_dm failed with code 134 [ 200s] + exit 1 It is due the fact that message field is 0-element array. Worked around by copying to string field with appropriate offset. --- tests/ioctl_dm.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index a5945ae..cb6dd97 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -64,7 +64,8 @@ main(void) init_s(); s.u.tm.target_msg.sector = 0x1234; - strcpy(s.u.tm.target_msg.message, "tmsg"); + strcpy(s.u.string + offsetof(struct dm_target_msg, message), + "tmsg"); ioctl(-1, DM_TARGET_MSG, ); printf("ioctl(-1, DM_TARGET_MSG, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net
[PATCH 04/21] dm: Minor output tweaks
Trying to make it more C-like and in line with common practices regarding structure printing. --- dm.c | 21 + tests/ioctl_dm.c |2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dm.c b/dm.c index d81983d..ebdfc44 100644 --- a/dm.c +++ b/dm.c @@ -120,7 +120,7 @@ dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, offset = new_offset; } else { misplaced: - tprints(", misplaced struct dm_target_spec"); + tprints(", /* misplaced struct dm_target_spec */ ..."); break; } } @@ -150,7 +150,7 @@ dm_decode_dm_target_deps(const struct dm_ioctl *ioc, const char *extra, tprints("}"); } else { misplaced: - tprints(", misplaced struct dm_target_deps"); + tprints(", /* misplaced struct dm_target_deps */ ..."); } } @@ -182,7 +182,7 @@ dm_decode_dm_name_list(const struct dm_ioctl *ioc, const char *extra, offset = offset + s->next; } else { misplaced: - tprints(", misplaced struct dm_name_list"); + tprints(", /* misplaced struct dm_name_list */ ..."); break; } } @@ -216,7 +216,8 @@ dm_decode_dm_target_versions(const struct dm_ioctl *ioc, const char *extra, offset = offset + s->next; } else { misplaced: - tprints(", misplaced struct dm_target_versions"); + tprints(", /* misplaced struct dm_target_versions */ " + "..."); break; } } @@ -240,7 +241,7 @@ dm_decode_dm_target_msg(const struct dm_ioctl *ioc, const char *extra, QUOTE_0_TERMINATED); tprints("}"); } else { - tprints(", misplaced struct dm_target_msg"); + tprints(", /* misplaced struct dm_target_msg */"); } } @@ -255,7 +256,7 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra, print_quoted_string(extra + offset, extra_size - offset, QUOTE_0_TERMINATED); } else { - tprints(", misplaced string"); + tprints(", /* misplaced string */"); } } @@ -275,8 +276,10 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) * if we use a different version of ABI, do not attempt to decode * ioctl fields */ - if (ioc.version[0] != DM_VERSION_MAJOR) + if (ioc.version[0] != DM_VERSION_MAJOR) { + tprints(", /* Unsupported device mapper ABI version */ ..."); goto skip; + } if (ioc.data_size > sizeof(ioc)) { extra = malloc(ioc.data_size); @@ -292,7 +295,9 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) dm_decode_device(code, ); dm_decode_values(tcp, code, ); dm_decode_flags(); - if (!abbrev(tcp)) + if (abbrev(tcp)) + tprints(", ..."); + else switch (code) { case DM_DEV_WAIT: case DM_TABLE_STATUS: diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index cb6dd97..ba484ee 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -98,7 +98,7 @@ main(void) "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", target_count=4294967295, flags=0, " "{sector_start=0, length=0, target_type=\"\", string=\"\"}, " - "misplaced struct dm_target_spec}, " + "/* misplaced struct dm_target_spec */ ...}, " "{version=4.1.2, dev=makedev(18, 52), name=\"nnn\", " "uuid=\"uuu\", flags=0}) = -1 EBADF (%m)\n"); -- 1.7.10.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel
[PATCH 21/21] dm: rewrite structure decoding
Rewrite structure decoding in attempt to make it more in line with how structures and arrays are decoded in strace. * Replace single structure retrieval with on-demand retrieval. It allows limiting amount of memory being allocated (suppose ioctl with data_size = -1) * Check for abbrev in structure decoders itself. It allows distinguishing cases when we want to decode some additional data from cases when we are not. --- dm.c | 363 +++--- 1 file changed, 217 insertions(+), 146 deletions(-) diff --git a/dm.c b/dm.c index ff9e8ad..d846233 100644 --- a/dm.c +++ b/dm.c @@ -101,165 +101,254 @@ dm_decode_flags(const struct dm_ioctl *ioc) } static void -dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, -const char *extra, uint32_t extra_size) +dm_decode_dm_target_spec(struct tcb *tcp, unsigned long addr, +const struct dm_ioctl *ioc) { static const uint32_t target_spec_size = sizeof(struct dm_target_spec); uint32_t i; uint32_t offset = ioc->data_start; + if (abbrev(tcp)) { + if (ioc->target_count) + tprints(", ..."); + + return; + } + for (i = 0; i < ioc->target_count; i++) { - if (offset + target_spec_size >= offset && - offset + target_spec_size < extra_size) { - uint32_t new_offset; - const struct dm_target_spec *s = - (const struct dm_target_spec *) (extra + offset); - tprintf(", {sector_start=%" PRIu64 ", length=%" PRIu64, - (uint64_t) s->sector_start, - (uint64_t) s->length); - if (!entering(tcp)) - tprintf(", status=%" PRId32, s->status); - tprints(", target_type="); - print_quoted_string(s->target_type, DM_MAX_TYPE_NAME, - QUOTE_0_TERMINATED); - tprints(", string="); - print_quoted_string((const char *) (s + 1), extra_size - - (offset + target_spec_size), - QUOTE_0_TERMINATED); - tprintf("}"); - if (entering(tcp)) - new_offset = offset + s->next; - else - new_offset = ioc->data_start + s->next; - if (new_offset <= offset + target_spec_size) - goto misplaced; - offset = new_offset; - } else { -misplaced: - tprints(", /* misplaced struct dm_target_spec */ ..."); + struct dm_target_spec s; + uint32_t new_offset; + + if ((offset + target_spec_size) <= offset || + (offset + target_spec_size) > ioc->data_size) + goto misplaced; + + tprints(", "); + + if (i >= max_strlen) { + tprints("..."); break; } + + if (umove_or_printaddr(tcp, addr + offset, )) + break; + + tprintf("{sector_start=%" PRI__u64 ", length=%" PRI__u64, + s.sector_start, s.length); + + if (!entering(tcp)) + tprintf(", status=%" PRId32, s.status); + + tprints(", target_type="); + print_quoted_string(s.target_type, DM_MAX_TYPE_NAME, + QUOTE_0_TERMINATED); + + tprints(", string="); + printstr_ex(tcp, addr + offset + target_spec_size, +ioc->data_size - (offset + target_spec_size), +QUOTE_0_TERMINATED); + tprintf("}"); + + if (entering(tcp)) + new_offset = offset + s.next; + else + new_offset = ioc->data_start + s.next; + + if (new_offset <= offset + target_spec_size) + goto misplaced; + + offset = new_offset; } + + return; + +misplaced: + tprints(", /* misplaced struct dm_target_spec */ ..."); +} + +bool +dm_print_dev(struct tcb *tcp, void *dev_ptr, size_t dev_size, void *dummy) +{ + uint64_t *dev = (uint64_t *) dev_ptr; + + tprintf("makedev(%u, %u)", major(*dev), minor(*dev)); + + return 1; } static void -dm_decode_dm_target_deps(const struct dm_ioctl *ioc, const char *extra, -uint32_t extra_size) +dm_decode_dm_target_deps(struct tcb *tcp, unsigned long addr, +const struct