zero/NULL fixes.
PATCH 1/1 zero/NULL fixes.
The EFAULT changes use a result of NULL to detect a failure from lock*() functions. There are syscalls that accept NULL as a valid argument and now the syscalls return -EFAULT. These patches allow appropriate syscalls to accept NULL.
I have put together a regression test harness wrapped around the Linux Test Project (LTP). I've been able to find regressions that were caused by the EFAULT changes. It's more exhaustive than running an ls executable and has helped find existing bugs as well as regressions. It will run regression tests for multiple architectures.
I'll be sending a few more patches for this same type of regression. I should also be sending in the test harness once I've worked out a few more details.
linux-user/syscall.c +2 -2
@@ -5399,7 +5399,7 @@ grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist)); -if (!is_error (ret)) { +if (!is_error (ret) && arg1) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *2 ,0 );if (!target_grouplist) goto efault;
@@ -5549,7 +5549,7 @@ grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist)); -if (!is_error (ret)) { +if (!is_error (ret) && arg1) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *4 ,0 );if (!target_grouplist) { ret = -TARGET_EFAULT ;
linux-user/syscall.c +8 -4
@@ -3398,10 +3398,14 @@ ret =0 ;/* avoid warning */ break ;case TARGET_NR_read: -if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; - ret =get_errno (read (arg1, p, arg3)); -unlock_user (p, arg2, ret); +if (!arg3) + ret =0 ; +else { +if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) + goto efault; + ret =get_errno (read (arg1, p, arg3)); +unlock_user (p, arg2, ret); + }break ;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 )))
linux-user/syscall.c +1 -1
@@ -1203,7 +1203,7 @@abi_long ret;if (get_user_u32 (addrlen, target_addrlen_addr)) -return -TARGET_EFAULT ; +return -TARGET_EINVAL ; addr =alloca (addrlen);
linux-user/path.c +1 -1
@@ -152,7 +152,7 @@ {/* Only do absolute paths: quick and dirty, but should mostly be OK. Could do relative by tracking cwd. */ -if (!base || name[0 ] !='/' ) +if (!base || !name || name[0 ] !='/' )return name;return follow_path (base, name) ?: name;
linux-user/syscall.c +6 -2
@@ -3864,8 +3864,12 @@ goto unimplemented;#endif case TARGET_NR_acct: -if (!(p =lock_user_string (arg1))) - goto efault; +if (arg1) { +if (!(p =lock_user_string (arg1))) + goto efault; + }else { + p =NULL ; + } ret =get_errno (acct (path (p)));unlock_user (p, arg1,0 );break ;
I think these patches are important bugfixes and they should be applied on the qemu head.
They fix some LTP tests.
Lauro
2007/12/11, Thayne Harbaugh <[email protected]>:
Quoted 16 lines
The EFAULT changes use a result of NULL to detect a failure from lock*() functions. There are syscalls that accept NULL as a valid argument and now the syscalls return
-EFAULT. These patches allow appropriate syscalls to accept NULL.I have put together a regression test harness wrapped around the Linux Test Project (LTP). I've been able to find regressions that were caused by the EFAULT changes. It's more exhaustive than running an ls executable and has helped find existing bugs as well as regressions. It will run regression tests for multiple architectures.
I'll be sending a few more patches for this same type of regression. I should also be sending in the test harness once I've worked out a few more details.
Quoted 3 lines · Lauro Ramos Venancio
I think these patches are important bugfixes and they should be applied on the qemu head.
They fix some LTP tests.
Tonight I'll be pulling my local tree up to CVS current and I'll resend any remaining EFAULT and zero/NULL patches that haven't been included. Right now I simply haven't tracked which patches have been incorporated and which ones are pending.
Thanks for the interest.
Quoted 17 lines
2007/12/11, Thayne Harbaugh <[email protected]>:
Quoted 16 lines
The EFAULT changes use a result of NULL to detect a failure from lock*() functions. There are syscalls that accept NULL as a valid argument and now the syscalls return
-EFAULT. These patches allow appropriate syscalls to accept NULL.I have put together a regression test harness wrapped around the Linux Test Project (LTP). I've been able to find regressions that were caused by the EFAULT changes. It's more exhaustive than running an ls executable and has helped find existing bugs as well as regressions. It will run regression tests for multiple architectures.
I'll be sending a few more patches for this same type of regression. I should also be sending in the test harness once I've worked out a few more details.