From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsMGk-0007zV-49 for qemu-devel@nongnu.org; Fri, 30 Oct 2015 22:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsMGf-0004qT-4Z for qemu-devel@nongnu.org; Fri, 30 Oct 2015 22:51:50 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:59716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsMGe-0004qL-Rh for qemu-devel@nongnu.org; Fri, 30 Oct 2015 22:51:45 -0400 References: <1441497448-32489-1-git-send-email-T.E.Baldwin99@members.leeds.ac.uk> <1441497448-32489-2-git-send-email-T.E.Baldwin99@members.leeds.ac.uk> <4d9a4d2f-5c12-48e3-964c-65e0922950d8@iki.fi> From: Laurent Vivier Message-ID: <56342CB4.3050003@vivier.eu> Date: Sat, 31 Oct 2015 03:51:32 +0100 MIME-Version: 1.0 In-Reply-To: <4d9a4d2f-5c12-48e3-964c-65e0922950d8@iki.fi> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 01/34] linux-user: Fix array bounds in errno conversion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio , Peter Maydell Cc: Timothy E Baldwin , QEMU Developers Le 12/10/2015 15:42, Riku Voipio a écrit : > On perjantaina 11. syyskuuta 2015 13.59.29 EEST, Peter Maydell wrote: >> On 6 September 2015 at 00:56, Timothy E Baldwin >> wrote: >>> Check array bounds in host_to_target_errno() and target_to_host_errno(). >>> >>> Signed-off-by: Timothy Edward Baldwin >>> >>> --- >>> linux-user/syscall.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) ... >> >> Maybe we should also check that the passed in error value is >> not negative? (Given the errno-is-positive/syscall-return-negative >> conventions, it's an easy mistake to make...) > > I've applied a version of this patch that implements this by setting the > function argument to unsigned > > Riku > > This patch breaks get_errno(). On a 64bit target, if errno is 22, host_to_target_errno(22) is (unsigned int)-22 = 0xffffffea, and get_errno() is (abi_long)0xffffffea = 0x000000000xffffffea = 4294967274. It is not negative, and thus is not an error. host_to_target_errno() and target_to_host_errno() must stay signed. Laurent