From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhFcm-0000o6-FO for qemu-devel@nongnu.org; Mon, 05 May 2014 05:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhFcf-0002I3-93 for qemu-devel@nongnu.org; Mon, 05 May 2014 05:55:52 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34095 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhFcf-0002GN-2x for qemu-devel@nongnu.org; Mon, 05 May 2014 05:55:45 -0400 Message-ID: <5367601E.7030807@suse.de> Date: Mon, 05 May 2014 11:55:42 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1396977870-108623-1-git-send-email-petar.jovanovic@rt-rk.com> In-Reply-To: <1396977870-108623-1-git-send-email-petar.jovanovic@rt-rk.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] linux-user: fix getrusage and wait4 failures with invalid rusage struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Petar Jovanovic , qemu-devel@nongnu.org Cc: riku.voipio@linaro.org, petar.jovanovic@imgtec.com Am 08.04.2014 19:24, schrieb Petar Jovanovic: > From: Petar Jovanovic >=20 > Implementations of system calls getrusage and wait4 have not previously > handled correctly cases when incorrect address of struct rusage is > passed. > This change makes sure return values are correctly set for these cases. >=20 > Signed-off-by: Petar Jovanovic > --- > linux-user/syscall.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) >=20 > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 9864813..fc52f0b 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -6309,7 +6309,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_l= ong arg1, > struct rusage rusage; > ret =3D get_errno(getrusage(arg1, &rusage)); > if (!is_error(ret)) { > - host_to_target_rusage(arg2, &rusage); > + ret =3D host_to_target_rusage(arg2, &rusage); > } > } > break; Why do you always set ret here ... > @@ -6974,6 +6974,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_l= ong arg1, > abi_long status_ptr =3D arg2; > struct rusage rusage, *rusage_ptr; > abi_ulong target_rusage =3D arg4; > + abi_long rusage_err; > if (target_rusage) > rusage_ptr =3D &rusage; > else > @@ -6985,8 +6986,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_= long arg1, > if (put_user_s32(status, status_ptr)) > goto efault; > } > - if (target_rusage) > - host_to_target_rusage(target_rusage, &rusage); > + if (target_rusage) { > + rusage_err =3D host_to_target_rusage(target_rusage= , &rusage); > + if (rusage_err) { > + ret =3D rusage_err; > + } > + } > } > } > break; ... but only on error here? Isn't obvious from the commit message. Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg