On Thu, Aug 18, 2011 at 12:47:38PM +0200, Denys Vlasenko wrote: > On Thu, 2011-08-18 at 12:23 +0200, Denys Vlasenko wrote: > > I noticed that tcp->u_args[MAX_ARGS] array is way larger than > > I'd expect: for all arches except HPPA it has 32 (!) elements. > > > > I looked at the code and so far I spotted only one abuser of > > this fact: sys_sigreturn. On several arches, it saves sigset_t > > into tcp->u_args[1...N] on entry and prints it on exit, a-la > > > > memcpy(&tcp->u_arg[1], &sc.oldmask[0], sizeof(sigset_t)) > > > > The problem here is that in glibc sigset_t is insanely large: > > 128 bytes, and using sizeof(sigset_t) in memcpy will overrun > > &tcp->u_args[1] even with MAX_ARGS == 32: > > On 32 bits, sizeof(tcp->u_args) == 32*4 == 128 bytes! > > We may already have a bug there! > > > > I propose to change the code to save NSIG / 8 bytes only. > > NSIG can't ever be > 256, and in practice is <= 129, > > thus NSIG / 8 is <= 16 bytes == 4 32-bit words, > > and MAX_ARGS == 5 should be enough for saving signal masks.
I agree. > > The proposed patch is below. > > > > Alternative solution is to make sys_sigreturn print mask > > on entry, not on exit. What is the reson it doesn't do that now? Can sys_sigreturn be interrupted somehow? [...] > --- strace.5/defs.h 2011-08-18 11:57:30.512416447 +0200 > +++ strace.6/defs.h 2011-08-18 11:46:56.349540479 +0200 > @@ -64,7 +64,7 @@ > #define DEFAULT_ACOLUMN 40 /* default alignment column for results > */ > #endif > #ifndef MAX_ARGS > -# ifdef HPPA > +# if defined HPPA || defined X86_64 || defined I386 > # define MAX_ARGS 6 /* maximum number of args to a syscall */ > # else > /* Way too big. Switch your arch to saner size after you tested that it > works */ What about other architectures? Is there any with MAX_ARGS > 6? Can we assume MAX_ARGS == 6 on linux? -- ldv
pgp7F11nhbVrm.pgp
Description: PGP signature
------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
