linux-user: fix guards for the fsmount(2) syscall series
PATCH 1/1 linux-user: fix guards for the fsmount(2) syscall series
The fsopen(), fsconfig(), fsmount() and fspick() implementations are guarded by defined(NR_fsopen) rather than defined(__NR_fsopen). No such macro exists, so the guard is never true and the entire series compiles out. Guests calling any of the four get -ENOSYS, which for example makes systemd's credential setup fail with EXIT_CREDENTIALS for most units.
The strace bits for fsconfig() have the same typo.
--- linux-user/strace.c | 2 +- linux-user/strace.list | 2 +- linux-user/syscall.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
linux-user/strace.c +1 -1
@@ -4344,7 +4344,7 @@ print_statx(CPUArchState *cpu_env, const struct syscallname *name, }#endif -#if defined(TARGET_NR_fsconfig) && defined(NR_fsconfig) +#ifdef TARGET_NR_fsconfigstatic void print_fsconfig_cmd_name (int cmd) {
linux-user/strace.list +1 -1
@@ -1725,7 +1725,7 @@ #ifdef TARGET_NR_fsopen { TARGET_NR_fsopen, "fsopen", "%s(%s,%d)", NULL, NULL }, #endif -#if defined(TARGET_NR_fsconfig) && defined(NR_fsconfig) +#ifdef TARGET_NR_fsconfig { TARGET_NR_fsconfig, "fsconfig", NULL, print_fsconfig, NULL }, #endif #ifdef TARGET_NR_fsmount
linux-user/syscall.c +2 -2
@@ -9740,7 +9740,7 @@ _syscall5(int, sys_move_mount, int, __from_dfd, const char *, __from_pathname, int, __to_dfd, const char *, __to_pathname, unsigned int, flag) #endif -#if defined(TARGET_NR_fsopen) && defined(NR_fsopen) +#if defined(TARGET_NR_fsopen) && defined(__NR_fsopen) #define __NR_sys_fsopen __NR_fsopen_syscall2 (int ,sys_fsopen ,const char *,fs_name ,unsigned int ,flags );#define __NR_sys_fsconfig __NR_fsconfig
@@ -14485,7 +14485,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,return do_map_shadow_stack (cpu_env, arg1, arg2, arg3);#endif -#if defined(TARGET_NR_fsopen) && defined(NR_fsopen) +#if defined(TARGET_NR_fsopen) && defined(__NR_fsopen)case TARGET_NR_fsopen: { p =lock_user_string (arg1);
Signature · 1 line
2.54.0
Quoted 8 lines · Matt Turner
The
fsopen(),fsconfig(),fsmount()andfspick()implementations are guarded bydefined(NR_fsopen)rather thandefined(__NR_fsopen). No such macro exists, so the guard is never true and the entire series compiles out. Guests calling any of the four get-ENOSYS, which for example makes systemd's credential setup fail withEXIT_CREDENTIALSfor most units.The strace bits for
fsconfig()have the same typo.
Quoted 8 lines
Fixes 767c32fe6983 ("linux-user: implement fsmount(2) series of syscalls")Fixes 6e0aa9f6c731 ("linux-user/strace: add fsmount series of syscalls")Signed-off-by Matt Turner <[email protected]>--- linux-user/strace.c | 2 +- linux-user/strace.list | 2 +- linux-user/syscall.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
Matt, thanks for noticing and fixing!
I'll include it in the next linux-user pull request...
Helge
Quoted 22 lines · Matt Turner
The
fsopen(),fsconfig(),fsmount()andfspick()implementations are guarded bydefined(NR_fsopen)rather thandefined(__NR_fsopen). No such macro exists, so the guard is never true and the entire series compiles out. Guests calling any of the four get-ENOSYS, which for example makes systemd's credential setup fail withEXIT_CREDENTIALSfor most units.The strace bits for
fsconfig()have the same typo.Fixes 767c32fe6983 ("linux-user: implement fsmount(2) series of syscalls")Fixes 6e0aa9f6c731 ("linux-user/strace: add fsmount series of syscalls")Signed-off-by Matt Turner <[email protected]>--- linux-user/strace.c | 2 +- linux-user/strace.list | 2 +- linux-user/syscall.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)linux-user/strace.c +0
-0
linux-user/strace.c print_statx(CPUArchState *cpu_env, const struct syscallname *name, · line 4347
Quoted 5 lines
linux-user/strace.c +1
-1@@ -4344,7 +4344,7 @@ print_statx(CPUArchState *cpu_env, const struct syscallname *name, }#endif -#if defined(TARGET_NR_fsconfig) && defined(NR_fsconfig) +#ifdef TARGET_NR_fsconfig
Your patch is basically correct.
But I think instead of removing the (wrong) NR_fsconfig, we should instead depend on the (possibly existing) __NR_fsconfig.
Reason is, that if __NR_fsconfig doesn't exist on the host machine, the constants used in print_fsconfig() like FSCONFIG_SET_FLAG aren't known either, leading to build errors if we don't check against __NR_fsconfig.
I change the patch accordingly.
Helge
Quoted 38 lines
linux-user/strace.c +0
-0static void print_fsconfig_cmd_name (int cmd) {linux-user/strace.list +1
-1@@ -1725,7 +1725,7 @@ #ifdef TARGET_NR_fsopen { TARGET_NR_fsopen, "fsopen", "%s(%s,%d)", NULL, NULL }, #endif -#if defined(TARGET_NR_fsconfig) && defined(NR_fsconfig) +#ifdef TARGET_NR_fsconfig { TARGET_NR_fsconfig, "fsconfig", NULL, print_fsconfig, NULL }, #endif #ifdef TARGET_NR_fsmountlinux-user/syscall.c +2
-2@@ -9740,7 +9740,7 @@ _syscall5(int, sys_move_mount, int, __from_dfd, const char *, __from_pathname, int, __to_dfd, const char *, __to_pathname, unsigned int, flag) #endif -#if defined(TARGET_NR_fsopen) && defined(NR_fsopen) +#if defined(TARGET_NR_fsopen) && defined(__NR_fsopen) #define __NR_sys_fsopen __NR_fsopen_syscall2 (int ,sys_fsopen ,const char *,fs_name ,unsigned int ,flags );#define __NR_sys_fsconfig __NR_fsconfig@@ -14485,7 +14485,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,return do_map_shadow_stack (cpu_env, arg1, arg2, arg3);#endif -#if defined(TARGET_NR_fsopen) && defined(NR_fsopen) +#if defined(TARGET_NR_fsopen) && defined(__NR_fsopen)case TARGET_NR_fsopen: { p =lock_user_string (arg1);
Quoted 32 lines · Helge Deller
Quoted 22 lines · Matt Turner
The
fsopen(),fsconfig(),fsmount()andfspick()implementations are guarded bydefined(NR_fsopen)rather thandefined(__NR_fsopen). No such macro exists, so the guard is never true and the entire series compiles out. Guests calling any of the four get-ENOSYS, which for example makes systemd's credential setup fail withEXIT_CREDENTIALSfor most units.The strace bits for
fsconfig()have the same typo.Fixes 767c32fe6983 ("linux-user: implement fsmount(2) series of syscalls")Fixes 6e0aa9f6c731 ("linux-user/strace: add fsmount series of syscalls")Signed-off-by Matt Turner <[email protected]>---
linux-user/strace.c | 2 +-
linux-user/strace.list | 2 +-
linux-user/syscall.c | 4 ++--3 files changed, 4 insertions(+), 4 deletions(-)linux-user/strace.c +0
-0linux-user/strace.c print_statx(CPUArchState *cpu_env, const struct syscallname *name, · line 4346
Quoted 4 lines
linux-user/strace.c +1
-1@@ -4344,7 +4344,7 @@ print_statx(CPUArchState *cpu_env, const struct syscallname *name, } #endif -#if defined(TARGET_NR_fsconfig) && defined(NR_fsconfig) +#ifdef TARGET_NR_fsconfigYour patch is basically correct.
But I think instead of removing the (wrong)NR_fsconfig, we should instead depend on the (possibly existing)__NR_fsconfig.
Quoted 5 lines
Reason is, that if
__NR_fsconfigdoesn't exist on the host machine, the constants used inprint_fsconfig()likeFSCONFIG_SET_FLAGaren't known either, leading to build errors if we don't check against__NR_fsconfig.I change the patch accordingly.
and pushed to my linux-user git tree:
https://github.com/hdeller/qemu-hppa/commit/4fdc24696cbf1ac6d97075d877cafc9fead4c475
Helge