On Sun, Mar 01, 2015 at 02:56:41AM -0500, Mike Frysinger wrote: > but uid is not as easy because __NR_getuid might operate on 32bits in which > case > you'd corrupt vars on the stack. you could work around it by doing: > --- a/tests/uid.c > +++ b/tests/uid.c > @@ -16,15 +16,19 @@ main(void) > && defined(__NR_setresuid) \ > && defined(__NR_chown) \ > && defined(__NR_getgroups) > - int r, e, s; > + /* The kernel API might be 16bit or 32bit */ > + union { > + int u32; > + short u16; > + } r, e, s; > int size; > int *list = 0; > > - e = syscall(__NR_getuid); > - assert(syscall(__NR_setuid, e) == 0); > - assert(syscall(__NR_getresuid, &r, &e, &s) == 0); > + e.u16 = syscall(__NR_getuid); > + assert(syscall(__NR_setuid, e.u16) == 0); > + assert(syscall(__NR_getresuid, &r.u16, &e.u16, &s.u16) == 0); > assert(syscall(__NR_setreuid, -1, -1L) == 0); > - assert(syscall(__NR_setresuid, -1, e, -1L) == 0); > + assert(syscall(__NR_setresuid, -1, e.u16, -1L) == 0); > assert(syscall(__NR_chown, ".", -1, -1L) == 0); > assert((size = syscall(__NR_getgroups, 0, list)) >= 0); > assert(list = calloc(size + 1, sizeof(*list))); > > this will fail if your uid is actually larger than 16bits and you're on an > arch > that only has 32bit syscalls. but maybe that case is unusual enough to not > care > about ? or at least, that is testable: > int uid = syscall(__NR_getuid); > if (uid >= (short)-1) > return 77;
Can we fix all these issues by ignoring getresuid results in subsequent calls? --- a/tests/uid.c +++ b/tests/uid.c @@ -16,15 +16,16 @@ main(void) && defined(__NR_setresuid) \ && defined(__NR_chown) \ && defined(__NR_getgroups) + int uid; int r, e, s; int size; int *list = 0; - e = syscall(__NR_getuid); - assert(syscall(__NR_setuid, e) == 0); + uid = syscall(__NR_getuid); + assert(syscall(__NR_setuid, uid) == 0); assert(syscall(__NR_getresuid, &r, &e, &s) == 0); assert(syscall(__NR_setreuid, -1, -1L) == 0); - assert(syscall(__NR_setresuid, -1, e, -1L) == 0); + assert(syscall(__NR_setresuid, -1, uid, -1L) == 0); assert(syscall(__NR_chown, ".", -1, -1L) == 0); assert((size = syscall(__NR_getgroups, 0, list)) >= 0); assert(list = calloc(size + 1, sizeof(*list))); -- ldv
pgpFqzZzRZ2e1.pgp
Description: PGP signature
------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel