diff mbox series

[v1] setfsuid02_16: Fix uid -1 too large for testing 16-bit version

Message ID 20230309085454.735531-1-pifang@redhat.com
State Accepted
Headers show
Series [v1] setfsuid02_16: Fix uid -1 too large for testing 16-bit version | expand

Commit Message

Ping Fang March 9, 2023, 8:54 a.m. UTC
__kernel_old_uid_t is not defined as 16bit on s390, ppc64le
Then -1 will be translated into UINT_MAX fails the size check.
s390, ppc64le use definition in /usr/include/asm-generic/posix_types.h

typedef unsigned int    __kernel_uid_t;
...
typedef __kernel_uid_t  __kernel_old_uid_t;

x86_64, aarch64 use definition in /usr/include/asm/posix_types_64.h
typedef unsigned short __kernel_old_uid_t;

Signed-off-by: Ping Fang <pifang@redhat.com>
---
 testcases/kernel/syscalls/utils/compat_uid.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Li Wang March 13, 2023, 9 a.m. UTC | #1
Reviewed-by: Li Wang <liwang@redhat.com>
Petr Vorel March 13, 2023, 10:24 p.m. UTC | #2
Hi Ping,

> __kernel_old_uid_t is not defined as 16bit on s390, ppc64le

I suppose limitation on s390 is because __kernel_old_uid_t is guarded only for
kernel, right?

arch/s390/include/uapi/asm/posix_types.h
#ifdef __KERNEL__
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
#define __kernel_old_uid_t __kernel_old_uid_t
#endif

> Then -1 will be translated into UINT_MAX fails the size check.
> s390, ppc64le use definition in /usr/include/asm-generic/posix_types.h
BTW do you test LTP syscalls on s930 and ppc (32bit)?

Kind regards,
Petr
Ping Fang March 14, 2023, 1:43 a.m. UTC | #3
Hi Petr,

On Tue, Mar 14, 2023 at 6:32 AM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Ping,
>
> > __kernel_old_uid_t is not defined as 16bit on s390, ppc64le
>
> I suppose limitation on s390 is because __kernel_old_uid_t is guarded only
> for
> kernel, right?
>

Yes, userspace header will use definition in
/usr/include/asm-generic/posix_types.h
unsigned int break the size check.

>
> arch/s390/include/uapi/asm/posix_types.h
> #ifdef __KERNEL__
> typedef unsigned short __kernel_old_uid_t;
> typedef unsigned short __kernel_old_gid_t;
> #define __kernel_old_uid_t __kernel_old_uid_t
> #endif
>
> > Then -1 will be translated into UINT_MAX fails the size check.
> > s390, ppc64le use definition in /usr/include/asm-generic/posix_types.h
> BTW do you test LTP syscalls on s930 and ppc (32bit)?
>

I don't have these machines at hand.

>
> Kind regards,
> Petr
>
>
Petr Vorel March 14, 2023, 10:38 a.m. UTC | #4
Hi Ping,

> > > __kernel_old_uid_t is not defined as 16bit on s390, ppc64le

> > I suppose limitation on s390 is because __kernel_old_uid_t is guarded only
> > for
> > kernel, right?


> Yes, userspace header will use definition in
> /usr/include/asm-generic/posix_types.h
> unsigned int break the size check.

Thanks for additional info.


> > arch/s390/include/uapi/asm/posix_types.h
> > #ifdef __KERNEL__
> > typedef unsigned short __kernel_old_uid_t;
> > typedef unsigned short __kernel_old_gid_t;
> > #define __kernel_old_uid_t __kernel_old_uid_t
> > #endif

> > > Then -1 will be translated into UINT_MAX fails the size check.
> > > s390, ppc64le use definition in /usr/include/asm-generic/posix_types.h
> > BTW do you test LTP syscalls on s930 and ppc (32bit)?


> I don't have these machines at hand.
Ah, I see it's broken on 64bit (not many people have 32bit for s390 or ppc).

Merged, thank you!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/utils/compat_uid.h b/testcases/kernel/syscalls/utils/compat_uid.h
index 94e54f310..7a345a654 100644
--- a/testcases/kernel/syscalls/utils/compat_uid.h
+++ b/testcases/kernel/syscalls/utils/compat_uid.h
@@ -26,7 +26,7 @@ 
 #include "tst_common.h"
 
 #ifdef TST_USE_COMPAT16_SYSCALL
-typedef __kernel_old_uid_t UID_T;
+typedef unsigned short UID_T;
 int UID_SIZE_CHECK(uid_t uid)
 {
 	/* See high2lowuid in linux/highuid.h