linux-user: Small fix for copy_file_range
cover linux-user: Small fix for copy_file_range
From: Giuseppe Musacchio <[email protected]>
An unwanted sign-extension is currently making the host kernel return EOVERFLOW when calling copy_file_range with a count of 0xffffffff, despite the host being a 64bit platform.
The fix is only affecting 32bit targets on 64bit hosts, it's a no-op when the target bitness matches the host one.
As a bonus add a pretty-printer for copy_file_range syscall.
Giuseppe Musacchio (2):
linux-user: Add copy_file_range to strace.list
linux-user: Fix erroneous conversion in copy_file_range
linux-user/strace.list | 3 +++ linux-user/syscall.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.30.2
PATCH 1/2 linux-user: Add copy_file_range to strace.list
From: Giuseppe Musacchio <[email protected]>
--- linux-user/strace.list | 3 +++ 1 file changed, 3 insertions(+)
linux-user/strace.list +3 -0
@@ -1665,3 +1665,6 @@ #ifdef TARGET_NR_statx { TARGET_NR_statx, "statx", NULL, print_statx, NULL }, #endif +#ifdef TARGET_NR_copy_file_range +{ TARGET_NR_copy_file_range, "copy_file_range", "%s(%d,%p,%d,%p,"TARGET_ABI_FMT_lu",%u)", NULL, NULL }, +#endif
Signature · 1 line
2.30.2
Re: [PATCH 1/2] linux-user: Add copy_file_range to strace.list
Le 03/05/2021 à 19:41, LemonBoy a écrit :
Quoted 13 lines
From: Giuseppe Musacchio <[email protected]>
Signed-off-by Giuseppe Musacchio <[email protected]>--- linux-user/strace.list | 3 +++ 1 file changed, 3 insertions(+)linux-user/strace.list +0
-0
linux-user/strace.list line 1670
Quoted 6 lines
linux-user/strace.list +3
-0@@ -1665,3 +1665,6 @@ #ifdef TARGET_NR_statx { TARGET_NR_statx, "statx", NULL, print_statx, NULL }, #endif +#ifdef TARGET_NR_copy_file_range +{ TARGET_NR_copy_file_range, "copy_file_range", "%s(%d,%p,%d,%p,"TARGET_ABI_FMT_lu",%u)", NULL, NULL }, +#endif
PATCH 2/2 linux-user: Fix erroneous conversion in copy_file_range
In reply to LemonBoyFrom: Giuseppe Musacchio <[email protected]>
The implicit cast from abi_long to size_t may introduce an intermediate unwanted sign-extension of the value for 32bit targets running on 64bit hosts.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -13245,8 +13245,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } poutoff = &outoff; } +/* Do not sign-extend the count parameter. */ ret =get_errno (safe_copy_file_range (arg1, pinoff, arg3, poutoff, - arg5, arg6)); + (abi_ulong )arg5, arg6));if (!is_error (ret) && ret >0 ) {if (arg2) {if (put_user_u64 (inoff, arg2)) {
Signature · 1 line
2.30.2
Re: [PATCH 2/2] linux-user: Fix erroneous conversion in copy_file_range
Le 03/05/2021 à 19:41, LemonBoy a écrit :
Quoted 17 lines
From: Giuseppe Musacchio <[email protected]>
The implicit cast from
abi_longtosize_tmay introduce an intermediate unwanted sign-extension of the value for 32bit targets running on 64bit hosts.Signed-off-by Giuseppe Musacchio <[email protected]>--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 13253
Quoted 10 lines
linux-user/syscall.c +2
-1@@ -13245,8 +13245,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } poutoff = &outoff; } +/* Do not sign-extend the count parameter. */ ret =get_errno (safe_copy_file_range (arg1, pinoff, arg3, poutoff, - arg5, arg6)); + (abi_ulong )arg5, arg6));if (!is_error (ret) && ret >0 ) {if (arg2) {if (put_user_u64 (inoff, arg2)) {
Laurent Vivier
AppliedLe 03/05/2021 à 19:41, LemonBoy a écrit :
Quoted 11 lines
From: Giuseppe Musacchio <[email protected]>
An unwanted sign-extension is currently making the host kernel return EOVERFLOW when calling
copy_file_rangewith a count of0xffffffff, despite the host being a 64bit platform.The fix is only affecting 32bit targets on 64bit hosts, it's a no-op when the target bitness matches the host one.
As a bonus add a pretty-printer for
copy_file_rangesyscall.
Quoted 8 lines
Giuseppe Musacchio (2):
linux-user: Addcopy_file_rangeto strace.list
linux-user: Fix erroneous conversion incopy_file_rangelinux-user/strace.list | 3 +++ linux-user/syscall.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
Applied to my linux-user-for-6.1 branch.
Thanks,
Laurent