Skip to contentSkip to conversation

Linux 5.6-rc1 kselftest build failures

DISCUSSION shuah 3 participants 6 messages Feb 12, 2020 – Feb 13, 2020 Kselftest

lore
Share & tools
lore

shuah

author maintainer
#0 lore raw

The following tests fail to build on x86_64

openat2:

tools/testing/selftests/openat2'
gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c helpers.c -o tools/testing/selftests/openat2/openat2_test
In file included from /usr/include/fcntl.h:301,
from helpers.c:9:
In function ‘openat’,
inlined from ‘touchat’ at helpers.c:49:11:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to ‘__openat_missing_mode’ declared with attribute error: openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments

  126 |    __openat_missing_mode ();
      |    ^~~~~~~~~~~~~~~~~~~~~~~~

timerns:

tools/testing/selftests/timens'
gcc -Wall -Werror -pthread -lrt -ldl timens.c -o tools/testing/selftests/timens/timens /usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
timens.c:(.text+0x65a): undefined reference to `timer_create'
collect2: error: ld returned 1 exit status

thanks,
-- Shuah

#1 lore raw
Quoted 12 lines · shuah

openat2:

tools/testing/selftests/openat2'
gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c helpers.c -o tools/testing/selftests/openat2/openat2_test
In file included from /usr/include/fcntl.h:301,
from helpers.c:9:
In function ‘openat’,
inlined from ‘touchat’ at helpers.c:49:11:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to ‘__openat_missing_mode’ declared with attribute error: openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments

Quoted 2 lines
  126 |    __openat_missing_mode ();
      |    ^~~~~~~~~~~~~~~~~~~~~~~~

Yeah, that's a brain-o -- it looks like you have a newer glibc than me which gives you a warning when you don't set the mode. The fix should be just the following:

--8<-----------------------------------------------------------------------
Subject: [PATCH] selftests: openat2: fix build error on newer glibc

It appears that newer glibcs check that openat(O_CREAT) was provided a fourth argument (rather than passing garbage), resulting in the following build error:

In file included from /usr/include/fcntl.h:301,
from helpers.c:9:
In function ‘openat’,
inlined from ‘touchat’ at helpers.c:49:11:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to ‘__openat_missing_mode’ declared with attribute error: openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments

    126 |    __openat_missing_mode ();
        |    ^~~~~~~~~~~~~~~~~~~~~~~~
---
 tools/testing/selftests/openat2/helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/openat2/helpers.c +1 -1
index e9a6557ab16f..5074681ffdc9 100644
@@ -46,7 +46,7 @@ int sys_renameat2(int olddirfd, const char *oldpath,
 
 int touchat(int dfd, const char *path)
 {
-	int fd = openat(dfd, path, O_CREAT);
+	int fd = openat(dfd, path, O_CREAT, 0700);
 	if (fd >= 0)
 		close(fd);
 	return fd;
Signature · 1 line
2.25.0
author maintainer
#2 lore raw
Quoted 16 lines · Aleksa Sarai
Quoted 12 lines · shuah

openat2:

tools/testing/selftests/openat2'
gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c helpers.c -o tools/testing/selftests/openat2/openat2_test
In file included from /usr/include/fcntl.h:301,
from helpers.c:9:
In function ‘openat’,
inlined from ‘touchat’ at helpers.c:49:11:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to ‘__openat_missing_mode’ declared with attribute error: openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments

Quoted 2 lines
   126 |    __openat_missing_mode ();
       |    ^~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines

Yeah, that's a brain-o -- it looks like you have a newer glibc than me which gives you a warning when you don't set the mode. The fix should be just the following:

Nice. Do you mind sending a proper patch, I can pull in.

thanks,
-- Shuah

#3 lore raw
Quoted 17 lines · shuah
Quoted 16 lines · Aleksa Sarai
Quoted 14 lines · shuah

openat2:

tools/testing/selftests/openat2'
gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c helpers.c -o tools/testing/selftests/openat2/openat2_test
In file included from /usr/include/fcntl.h:301,
from helpers.c:9:
In function ‘openat’,
inlined from ‘touchat’ at helpers.c:49:11:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to ‘__openat_missing_mode’ declared with attribute error: openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments

   126 |    __openat_missing_mode ();
       |    ^~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 4 lines

Yeah, that's a brain-o -- it looks like you have a newer glibc than me which gives you a warning when you don't set the mode. The fix should be just the following:

Nice. Do you mind sending a proper patch, I can pull in.

Done[1].

[1]: https://lore.kernel.org/linux-kselftest/[email protected]/

Signature · 4 lines
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
#4 lore raw
In reply to shuah

Hi Shuah,

Quoted 1 line · shuah

The following tests fail to build on x86_64

[..]

Quoted 8 lines

timerns:

tools/testing/selftests/timens'
gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o tools/testing/selftests/timens/timens
/usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
timens.c:(.text+0x65a): undefined reference to `timer_create'
collect2: error: ld returned 1 exit status

I've just send a patch to fix it:
https://lkml.kernel.org/r/[email protected]

Could you try it?

Also, it seems that the same thing affects futex/rtc/tcp_mmap/tcp_inq tests?

While looking into this, I see there are new auto-generated lkmdtm && pidfd tests, is it worth to add them to .gitignore?

Thanks,
Dmitry

author maintainer
#5 lore raw
Quoted 14 lines · Dmitry Safonov

Hi Shuah,

Quoted 1 line · shuah

The following tests fail to build on x86_64

[..]

Quoted 8 lines

timerns:

tools/testing/selftests/timens'
gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o tools/testing/selftests/timens/timens
/usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
timens.c:(.text+0x65a): undefined reference to `timer_create'
collect2: error: ld returned 1 exit status

Quoted 4 lines

I've just send a patch to fix it:
https://lkml.kernel.org/r/[email protected]

Could you try it?

Yup. Works, responsed to the patch thread.

Quoted 6 lines

Also, it seems that the same thing affects futex/rtc/tcp_mmap/tcp_inq tests?

While looking into this, I see there are new auto-generated lkmdtm && pidfd tests, is it worth to add them to .gitignore?

Thanks for finding. Yes please send a patch for this.

thanks,
-- Shuah