linux-user: don't short-circuit read with zero length
PATCH 1/1 linux-user: don't short-circuit read with zero length
A zero-length read still needs to do the usual checks, thus it may return errors like EBADF.
Signed-off-by Andreas Schwab <[email protected]>
--- linux-user/syscall.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
linux-user/syscall.c +7 -11
@@ -7930,18 +7930,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =0 ;/* avoid warning */ break ;case TARGET_NR_read: -if (arg3 ==0 ) - ret =0 ; -else { -if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; - ret =get_errno (safe_read (arg1, p, arg3)); -if (ret >=0 && -fd_trans_host_to_target_data (arg1)) { - ret =fd_trans_host_to_target_data (arg1)(p, ret); - } -unlock_user (p, arg2, ret); +if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) + goto efault; + ret =get_errno (safe_read (arg1, p, arg3)); +if (ret >=0 && +fd_trans_host_to_target_data (arg1)) { + ret =fd_trans_host_to_target_data (arg1)(p, ret); } +unlock_user (p, arg2, ret);break ;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 )))
Signature · 6 lines
2.18.0 -- Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 7934
Quoted 2 lines · Andreas Schwab
linux-user/syscall.c +2
-0+if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) + goto efault;
The goto should not compile on head, after 2852aafd9d05.
r~