Received: from eggs.gnu.org ([2001:4830:134:3::10]:53751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAH6K-0008HA-TX for qemu-devel@nongnu.org; Mon, 03 Feb 2014 05:50:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAH6G-0002cV-Tt for qemu-devel@nongnu.org; Mon, 03 Feb 2014 05:50:04 -0500 Received: from afflict.kos.to ([92.243.29.197]:53148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAH6G-0002c4-Mg for qemu-devel@nongnu.org; Mon, 03 Feb 2014 05:50:00 -0500 Date: Mon, 3 Feb 2014 12:49:57 +0200 From: Riku Voipio Message-ID: <20140203104957.GA17799@afflict.kos.to> References: <1391310292-18008-1-git-send-email-edgar.iglesias@gmail.com> <1391310292-18008-7-git-send-email-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1391310292-18008-7-git-send-email-edgar.iglesias@gmail.com> Subject: Re: [Qemu-devel] [PATCH 6/6] linux-user: Fix trampoline code for CRIS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: edgar.iglesias@gmail.com Cc: qemu-devel@nongnu.org On Sun, Feb 02, 2014 at 03:04:52AM +0000, edgar.iglesias@gmail.com wrote: > From: Stefan Weil > > __put_user can write bytes, words (2 bytes) or longwords (4 bytes). > Here obviously words should have been written, but bytes were written, > so values like 0x9c5f were truncated to 0x5f. > > Fix this by changing retcode from uint8_t to to uint16_t in > target_signal_frame and also in the unused rt_signal_frame. > > This problem was reported by static code analysis (smatch). Acked-by: Riku Voipio > Cc: qemu-stable@nongnu.org > Signed-off-by: Stefan Weil > Reviewed-by: Peter Maydell > Tested-by: Edgar E. Iglesias > Reviewed-by: Edgar E. Iglesias > Signed-off-by: Edgar E. Iglesias > --- > linux-user/signal.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/linux-user/signal.c b/linux-user/signal.c > index 01d7c39..82e8592 100644 > --- a/linux-user/signal.c > +++ b/linux-user/signal.c > @@ -3659,7 +3659,7 @@ struct target_sigcontext { > struct target_signal_frame { > struct target_sigcontext sc; > uint32_t extramask[TARGET_NSIG_WORDS - 1]; > - uint8_t retcode[8]; /* Trampoline code. */ > + uint16_t retcode[4]; /* Trampoline code. */ > }; > > struct rt_signal_frame { > @@ -3667,7 +3667,7 @@ struct rt_signal_frame { > void *puc; > siginfo_t info; > struct ucontext uc; > - uint8_t retcode[8]; /* Trampoline code. */ > + uint16_t retcode[4]; /* Trampoline code. */ > }; > > static void setup_sigcontext(struct target_sigcontext *sc, CPUCRISState *env) > @@ -3745,8 +3745,8 @@ static void setup_frame(int sig, struct target_sigaction *ka, > */ > err |= __put_user(0x9c5f, frame->retcode+0); > err |= __put_user(TARGET_NR_sigreturn, > - frame->retcode+2); > - err |= __put_user(0xe93d, frame->retcode+4); > + frame->retcode + 1); > + err |= __put_user(0xe93d, frame->retcode + 2); > > /* Save the mask. */ > err |= __put_user(set->sig[0], &frame->sc.oldmask); > -- > 1.8.3.2 >