Skip to contentSkip to conversation

Fixes for old distros

PATCH New Petr Vorel 4 participants 12 messages Jan 17, 2020 – Jan 20, 2020

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover Fixes for old distros

Hi,

few fixes for old SLES we still support,
which I'd like to merge before release.

Kind regards,
Petr

Petr Vorel (3):
pidfd_send_signal: Build with _GNU_SOURCE tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h> lapi/syscalls: Add syncfs

 include/lapi/syscalls/arm.in                                    | 1 +
 include/lapi/syscalls/hppa.in                                   | 1 +
 include/lapi/syscalls/i386.in                                   | 1 +
 include/lapi/syscalls/ia64.in                                   | 1 +
 include/lapi/syscalls/powerpc.in                                | 1 +
 include/lapi/syscalls/powerpc64.in                              | 1 +
 include/lapi/syscalls/s390.in                                   | 1 +
 include/lapi/syscalls/s390x.in                                  | 1 +
 include/lapi/syscalls/sh.in                                     | 1 +
 include/lapi/syscalls/sparc.in                                  | 1 +
 include/lapi/syscalls/sparc64.in                                | 1 +
 include/lapi/syscalls/x86_64.in                                 | 1 +
 include/tst_device.h                                            | 2 +-
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal01.c     | 1 +
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal02.c     | 1 +
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c     | 1 +
 16 files changed, 16 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
author
#1 lore raw

PATCH 1/3 pidfd_send_signal: Build with _GNU_SOURCE

This adds missing O_CLOEXEC and O_DIRECTORY on old distros, where it's (in glibc) guarded under __USE_GNU.

This was needed on SLES 11 (glibc 2.11).

---
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal01.c      | 1 +
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal02.c      | 1 +
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c      | 1 +
 3 files changed, 3 insertions(+)
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal01.c +1 -0
index f03905894..b529551d2 100644
@@ -9,6 +9,7 @@
  * struct is passed.
  */
 
+#define _GNU_SOURCE
 #include <signal.h>
 #include <stdlib.h>
 #include "tst_safe_pthread.h"
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal02.c +1 -0
index c933ada84..74914523f 100644
@@ -21,6 +21,7 @@
  *    -> EPERM
  */
 
+#define _GNU_SOURCE
 #include <pwd.h>
 #include <signal.h>
 #include "tst_safe_pthread.h"
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c +1 -0
index 19d943d06..3420afbb9 100644
@@ -15,6 +15,7 @@
  * child using the pidfd of the first one.
  */
 
+#define _GNU_SOURCE
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
Signature · 1 line
2.24.1
author
#2 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

In reply to Petr Vorel

As a fallback for old distros which does not define __NR_syncfs (the dependency is in the library itself).

This was needed on SLES 11 (kernel 2.6.32).

Fixes 74aeb88c9 ("tst_device: use raw syscall in the tst_device.h")
---
 include/tst_device.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/tst_device.h +1 -1
index 3db5275c9..13d92ee54 100644
@@ -19,7 +19,7 @@
 #define TST_DEVICE_H__
 
 #include <unistd.h>
-#include <sys/syscall.h>
+#include "lapi/syscalls.h"
 
 struct tst_device {
 	const char *dev;
Signature · 1 line
2.24.1
author
#3 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

Hi,

Quoted 17 lines

As a fallback for old distros which does not define __NR_syncfs (the dependency is in the library itself).

This was needed on SLES 11 (kernel 2.6.32).

Fixes 74aeb88c9 ("tst_device: use raw syscall in the tst_device.h")
---
 include/tst_device.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/tst_device.h +0 -0
index 3db5275c9..13d92ee54 100644

include/tst_device.h line 22

Quoted 5 lines
include/tst_device.h +1 -1
@@ -19,7 +19,7 @@
 #define TST_DEVICE_H__
 
 #include <unistd.h>
-#include <sys/syscall.h>
+#include "lapi/syscalls.h"

Hm, maybe this fix wasn't a good idea.
It effectively uses lapi/syscalls.h everywhere instead of <sys/syscall.h>. Not sure if this is what we want.

Example of the error is #634 [1], which is caused by __NR_socketcall being -1 instead of not defined (socketcall is not defined on some archs, e.g. x86-64 and ARM). We can fix the condition, but it will lead to numerous not obvious errors, so I suggest to revert this (and thus get LTP broken on very old distros).

I'm sorry to break LTP just before release.

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/issues/634

#4 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

----- Original Message -----

Quoted 6 lines

include/tst_device.h line 22

Quoted 3 lines

#include <unistd.h>

include/tst_device.h +1 -1
-#include <sys/syscall.h>
+#include "lapi/syscalls.h"

Hm, maybe this fix wasn't a good idea.
It effectively uses lapi/syscalls.h everywhere instead of <sys/syscall.h>. Not sure if this is what we want.

We already include lapi/syscalls.h at several places, so I wouldn't expect this to be as bad.

Quoted 5 lines

Example of the error is #634 [1], which is caused by __NR_socketcall being -1 instead of not defined (socketcall is not defined on some archs, e.g. x86-64 and ARM).
We can fix the condition

Tests using tst_syscall or ltp_syscall should be fine, since those check for ENOSYS.

Quoted 4 lines

, but it will lead to numerous not obvious errors, so
I
suggest to revert this (and thus get LTP broken on very old distros).

Cyril, any thoughts?

author
#5 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

Hi,

Quoted 10 lines

----- Original Message -----

Quoted 6 lines

include/tst_device.h line 22

Quoted 3 lines

#include <unistd.h>

include/tst_device.h +1 -1
-#include <sys/syscall.h>
+#include "lapi/syscalls.h"

Hm, maybe this fix wasn't a good idea.
It effectively uses lapi/syscalls.h everywhere instead of <sys/syscall.h>. Not sure if this is what we want.

We already include lapi/syscalls.h at several places, so I wouldn't expect this to be as bad.

Yes, it's in many places, the same as lapi/syscalls.h:
git grep -l sys/syscall.h |wc -l
136

git grep -l lapi/syscalls.h |wc -l
206

But none of lapi/syscalls.h use is in the API headers (only in API C and tests)

Quoted 7 lines
Quoted 4 lines

Example of the error is #634 [1], which is caused by __NR_socketcall being -1 instead of not defined (socketcall is not defined on some archs, e.g. x86-64 and ARM).
We can fix the condition

Tests using tst_syscall or ltp_syscall should be fine, since those check for ENOSYS.

OK, if lapi/syscalls.h include is ok, using tst_syscall() in socketcall01.c is trivial fix. But I'd worry about these uses:

$ git grep -e '^#if.*\bSYS_' $(git grep -l sys/syscall.h)
testcases/kernel/containers/libclone/libclone.h:#ifndef SYS_unshare
testcases/kernel/containers/libclone/libclone.h:#ifdef __NR_unshare
testcases/kernel/containers/libclone/libclone.h:#ifndef __NR_unshare
testcases/kernel/fs/scsi/ltpscsi/llseek.c:#ifdef __NR_lseek
testcases/kernel/fs/scsi/ltpscsi/llseek.c:#ifndef __NR_llseek
testcases/kernel/hotplug/memory_hotplug/commands.c:#ifndef __NR_migrate_pages
testcases/kernel/mem/vma/vma03.c:#ifdef __NR_mmap2
testcases/kernel/security/tomoyo/include.h:#ifdef __NR_uselib
testcases/kernel/security/tomoyo/include.h:#ifdef __NR_pivot_root
testcases/kernel/syscalls/accept4/accept4_01.c:#if defined(SYS_ACCEPT4) /* the socketcall() number */
testcases/kernel/syscalls/readahead/readahead01.c:#if defined(__NR_readahead)
testcases/kernel/syscalls/set_robust_list/set_robust_list01.c:#ifdef __NR_set_robust_list
testcases/kernel/syscalls/set_robust_list/set_robust_list01.c:#ifdef __NR_set_robust_list
testcases/kernel/syscalls/set_robust_list/set_robust_list01.c:#ifdef __NR_set_robust_list
testcases/kernel/syscalls/set_robust_list/set_robust_list01.c:#ifdef __NR_set_robust_list
testcases/kernel/syscalls/setns/setns01.c:#if defined(__NR_setns)
testcases/kernel/syscalls/setns/setns02.c:#if defined(__NR_setns) && defined(CLONE_NEWIPC) && defined(CLONE_NEWUTS)
testcases/kernel/syscalls/socketcall/socketcall01.c:#ifdef __NR_socketcall
testcases/kernel/syscalls/socketcall/socketcall02.c:#ifdef __NR_socketcall
testcases/kernel/syscalls/socketcall/socketcall03.c:#ifdef __NR_socketcall
testcases/kernel/syscalls/socketcall/socketcall04.c:#ifdef __NR_socketcall
testcases/kernel/syscalls/timerfd/timerfd01.c:#ifdef __NR_timerfd_create
testcases/misc/crash/crash02.c:#if defined(__NR_vfork) && __NR_vfork
testcases/misc/crash/crash02.c:#if defined(__NR_clone) && __NR_clone

which IMHO fail unless transformed into tst_syscall/ltp_syscall().

That's why I'd apply my fix https://patchwork.ozlabs.org/patch/1225869/.

Kind regards,
Petr

#6 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

Quoted 1 line · Petr Vorel

But none of lapi/syscalls.h use is in the API headers (only in API C and tests)

And you could avoid #including lapi/syscalls.h in API headers by simply moving the implementation of tst_dev_sync() to lib/tst_device.c.

Why do you guys use static inline functions so much anyway? There are no technical reasons to do that except for default main().

Signature · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
author
#7 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

Hi,

Quoted 8 lines · Petr Vorel
Quoted 1 line

But none of lapi/syscalls.h use is in the API headers (only in API C and tests)

And you could avoid #including lapi/syscalls.h in API headers by simply moving the implementation of tst_dev_sync() to lib/tst_device.c.

Why do you guys use static inline functions so much anyway? There are no technical reasons to do that except for default main().

+1. I still think it's not good to include lapi/syscalls.h even it does not break anything. I'll send a patch which uses tst_syscall in socketcall01.c and second commit which moves tst_dev_sync() to lib/tst_device.c. It's up to you if agree on second one.

Kind regards,
Petr

#8 lore raw

PATCH 2/3 tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>

In reply to Jan Stancek

Hi!

Quoted 8 lines
Quoted 4 lines

Example of the error is #634 [1], which is caused by __NR_socketcall being -1 instead of not defined (socketcall is not defined on some archs, e.g. x86-64 and ARM).
We can fix the condition

Tests using tst_syscall or ltp_syscall should be fine, since those check for ENOSYS.

Quoted 6 lines
Quoted 4 lines

, but it will lead to numerous not obvious errors, so
I
suggest to revert this (and thus get LTP broken on very old distros).

Cyril, any thoughts?

I would say that doing #ifdef __NR_* in test source to disable it is wrong to begin with.

Doing 'git grep ifdef __NR' shows only socketcall, set_robust_list and timerfd tests.

The timerfd tests include lapi/syscalls.h already and uses ltp_syscall() so that shouldn't break. I guess we can safely remove the ifdef there as well.

The set_robust_list includes the old test.h so thi change to tst_device.h should not affect it either.

So as far as I can tell the only thing that breaks are the socketcall tests and I guess that the actual fix would be using tst_syscall() instead of syscall() and we can remove the ifdefs as well.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#9 lore raw

PATCH 3/3 lapi/syscalls: Add syncfs

In reply to Petr Vorel

for old distros, which don't define it. Added for all architectures (including very old ones), as the dependency is in the library itself.

This was needed on SLES 11 (kernel 2.6.32).

Fixes 74aeb88c9 ("tst_device: use raw syscall in the tst_device.h")
---
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sh.in        | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 12 files changed, 12 insertions(+)
include/lapi/syscalls/arm.in +1 -0
index 00e99f2b9..a6a594c2e 100644
@@ -334,6 +334,7 @@ accept4 (__NR_SYSCALL_BASE+366)
 fanotify_init (__NR_SYSCALL_BASE+367)
 fanotify_mark (__NR_SYSCALL_BASE+368)
 prlimit64 (__NR_SYSCALL_BASE+369)
+syncfs (__NR_SYSCALL_BASE+373)
 process_vm_readv (__NR_SYSCALL_BASE+376)
 process_vm_writev (__NR_SYSCALL_BASE+377)
 kcmp (__NR_SYSCALL_BASE+378)
include/lapi/syscalls/hppa.in +1 -0
index 4cdd109fb..d92f33f40 100644
@@ -16,6 +16,7 @@ faccessat (__NR_openat + 12)
 splice 291
 tee 293
 vmsplice 294
+syncfs 327
 process_vm_readv 330
 process_vm_writev 331
 memfd_create 340
include/lapi/syscalls/i386.in +1 -0
index 87ab46933..bad6e409f 100644
@@ -332,6 +332,7 @@ recvmmsg 337
 fanotify_init 338
 fanotify_mark 339
 prlimit64 340
+syncfs 344
 process_vm_readv 347
 process_vm_writev 348
 kcmp 349
include/lapi/syscalls/ia64.in +1 -0
index cf9f73e85..0e6ba54a8 100644
@@ -293,6 +293,7 @@ recvmmsg 1322
 fanotify_init 1323
 fanotify_mark 1324
 prlimit64 1325
+syncfs 1329
 process_vm_readv 1332
 process_vm_writev 1333
 renameat2 1338
include/lapi/syscalls/powerpc.in +1 -0
index 660165d7a..91467f326 100644
@@ -339,6 +339,7 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+syncfs 348
 process_vm_readv  351
 process_vm_writev 352
 kcmp 354
include/lapi/syscalls/powerpc64.in +1 -0
index 660165d7a..91467f326 100644
@@ -339,6 +339,7 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+syncfs 348
 process_vm_readv  351
 process_vm_writev 352
 kcmp 354
include/lapi/syscalls/s390.in +1 -0
index d3f7eb1f6..dcf0a7148 100644
@@ -323,6 +323,7 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+syncfs 338
 process_vm_readv 340
 process_vm_writev 341
 kcmp 343
include/lapi/syscalls/s390x.in +1 -0
index 7d632d1dc..2dce00f90 100644
@@ -322,6 +322,7 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+syncfs 338
 process_vm_readv 340
 process_vm_writev 341
 kcmp 343
include/lapi/syscalls/sh.in +1 -0
index 132492922..996ebc956 100644
@@ -360,6 +360,7 @@ accept4 366
 fanotify_init 367
 fanotify_mark 368
 prlimit64 369
+syncfs 373
 process_vm_readv 376
 process_vm_writev 377
 kcmp 378
include/lapi/syscalls/sparc.in +1 -0
index 94a672428..65902e00a 100644
@@ -330,6 +330,7 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+syncfs 335
 process_vm_readv 338
 process_vm_writev 339
 kcmp 341
include/lapi/syscalls/sparc64.in +1 -0
index d17dce5cd..d303622b4 100644
@@ -306,6 +306,7 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+syncfs 335
 process_vm_readv 338
 process_vm_writev 339
 kcmp 341
include/lapi/syscalls/x86_64.in +1 -0
index b1cbd4f2f..3e9e19ae6 100644
@@ -299,6 +299,7 @@ recvmmsg 299
 fanotify_init 300
 fanotify_mark 301
 prlimit64 302
+syncfs 306
 process_vm_readv 310
 process_vm_writev 311
 kcmp 312
Signature · 1 line
2.24.1
#10 lore raw

cover Fixes for old distros

In reply to Petr Vorel

----- Original Message -----

Quoted 4 lines

Hi,

few fixes for old SLES we still support,
which I'd like to merge before release.

Looks good to me.

author
#11 lore raw

cover Fixes for old distros

Hi Jan,

Quoted 4 lines
Quoted 2 lines

few fixes for old SLES we still support,
which I'd like to merge before release.

Looks good to me.

Thanks for your review, merged.

Kind regards,
Petr