Re: [LTP] [PATCH] syscalls/setgroups: fix implicit SETGROUPS parameter casting

chrubis
2013-08-26T11:30:16Z

Hi!
> I looked at arch/* from linux sources and prepared this table:
>
> Architecture | __NR_setgroups32 defined | __NR_setgroups defined | glibc
> for setgroups() invokes |
> alpha | | + |
> arm | + | + |
> avr32 | | + |
> blackfin | + | + |
> cris | + | + |
> frv | + | + |
> h8300 | + | + |
> ia64 | + | |
> m32r | + | |
> m68k | + | + |
> microblaze | + | + |
> mips | | + |
> mn10300 | + | + |
> parisc | | + |
> powerpc | | + | setgroups |
> s390 | + | + | setgroups32 |
> s390x | | + | setgroups |
> sh-32 | + | + | setgroups32 |
> sh-64 | + | + | setgroups32 |
> sparc32 | + | + | setgroups32 |
> sparc64 | | + | setgroups |
> i386 | + | + | setgroups32 |
> x86_64 | | + | setgroups |
> xtensa | | + |
>
> Sorry for formatting.
>
> It looks like that if __NR_setgroups32 is defined then this means that
> syscall pointed by __NR_setgroups is 16bit.
>
> So how do you think about this patch ?
>
> diff --git a/testcases/kernel/syscalls/setgroups/compat_16.h
> b/testcases/kernel/syscalls/setgroups/compat_16.h
> index 0de4e78..8f46da9 100644
> --- a/testcases/kernel/syscalls/setgroups/compat_16.h
> +++ b/testcases/kernel/syscalls/setgroups/compat_16.h
> @@ -32,9 +32,16 @@ extern void cleanup(void);
> #ifdef TST_USE_COMPAT16_SYSCALL
>
> long
> -SETGROUPS(size_t gidsetsize, GID_T *list)
> +SETGROUPS(size_t gidsetsize, GID_T *list16)
> {
> - return ltp_syscall(__NR_setgroups, gidsetsize, list);
> +# if (__NR_setgroups32 != __LTP__NR_INVALID_SYSCALL)
> + /* __NR_setgroups - 16-bit version of setgroups() syscall */
> + return ltp_syscall(__NR_setgroups, gidsetsize, list16);
> +# else
> + /* The platform has no 16-bit version of setgroups() syscall */
> + tst_brkm(TCONF, NULL,
> + "16-bit version of setgroups() is not supported on your
> arch");
> +# endif /* __NR_setgroups32 */

Looks good to me.

And we should fix the getgroups in the same header as well.

--
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!