* [Qemu-devel] [PATCH] fix read() and acct() on NULL arguments
@ 2009-01-19 15:29 Riku Voipio
2009-01-30 19:52 ` Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Riku Voipio @ 2009-01-19 15:29 UTC (permalink / raw)
To: qemu-devel
Returning efault in these cases is not correct. Originally
proposed by Thayne Harbaugh in 2007:
http://www.mail-archive.com/qemu-devel@nongnu.org/msg14658.html
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4eb003a..ab81b3a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3713,10 +3713,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
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 == 0)
+ 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)))
@@ -4217,10 +4221,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
goto unimplemented;
#endif
case TARGET_NR_acct:
- if (!(p = lock_user_string(arg1)))
- goto efault;
- ret = get_errno(acct(path(p)));
- unlock_user(p, arg1, 0);
+ if (arg1 == 0) {
+ ret = get_errno(acct(NULL));
+ } else {
+ if (!(p = lock_user_string(arg1)))
+ goto efault;
+ ret = get_errno(acct(path(p)));
+ unlock_user(p, arg1, 0);
+ }
break;
#ifdef TARGET_NR_umount2 /* not on alpha */
case TARGET_NR_umount2:
--
1.5.6.5
--
"rm -rf" only sounds scary if you don't have backups
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] fix read() and acct() on NULL arguments
2009-01-19 15:29 [Qemu-devel] [PATCH] fix read() and acct() on NULL arguments Riku Voipio
@ 2009-01-30 19:52 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2009-01-30 19:52 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel
On Mon, Jan 19, 2009 at 05:29:12PM +0200, Riku Voipio wrote:
> Returning efault in these cases is not correct. Originally
> proposed by Thayne Harbaugh in 2007:
>
> http://www.mail-archive.com/qemu-devel@nongnu.org/msg14658.html
>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Thanks, applied.
> ---
> linux-user/syscall.c | 24 ++++++++++++++++--------
> 1 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 4eb003a..ab81b3a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3713,10 +3713,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> 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 == 0)
> + 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)))
> @@ -4217,10 +4221,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> goto unimplemented;
> #endif
> case TARGET_NR_acct:
> - if (!(p = lock_user_string(arg1)))
> - goto efault;
> - ret = get_errno(acct(path(p)));
> - unlock_user(p, arg1, 0);
> + if (arg1 == 0) {
> + ret = get_errno(acct(NULL));
> + } else {
> + if (!(p = lock_user_string(arg1)))
> + goto efault;
> + ret = get_errno(acct(path(p)));
> + unlock_user(p, arg1, 0);
> + }
> break;
> #ifdef TARGET_NR_umount2 /* not on alpha */
> case TARGET_NR_umount2:
> --
> 1.5.6.5
>
>
> --
> "rm -rf" only sounds scary if you don't have backups
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-30 19:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-19 15:29 [Qemu-devel] [PATCH] fix read() and acct() on NULL arguments Riku Voipio
2009-01-30 19:52 ` Aurelien Jarno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).