[LTP] [PATCH v2 2/2] Refactor getegid02 using new LTP API

Cyril Hrubis chrubis@suse.cz
Tue Oct 17 14:41:01 CEST 2023


Hi!
> This code is based on Cyril's suggestion in v1 [1]
> 	if (GID_SIZE_CHECK(st_egid))
> 		TST_EXP_EQ_LI(gid, st_egid);
> 	else
> 		tst_res(TPASS, "getegid() passed");
> 
> I wonder which system returns 16 bit gid?
> 
> man getgid(2) says that originally there was only 16 bit, than kernel 2.4 added
> support for 32 bit and the glibc getegid() wrapper transparently deal with this.
> 
> Because even I compile as 32 bit:
> 
> $ file getegid01_16
> getegid01_16: ELF 32-bit LSB pie executable, Intel 80386
> 
> I get comparison, thus 32 bit:
> $ ./getegid01_16
> ...
> getegid01.c:25: TPASS: gid == st_egid (1000)
> 
> What am I missing?

This obviously works since 1000 < 32767. As long as the GID fits 16bit
integer everything works fine with 16bit syscalls. The check returns if
the egid does fit and returns true if so.

When the GID does not fit, kernel returns overflow GID, i.e. for all
values bigger than 16 bit you get the same GID value that does not
correspond to the actual GID value at all.

So to make the check false, you have to set up the test user so that it
has GID > 16bit integer maximum value.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list