qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
Cc: Riku Voipio <riku.voipio@iki.fi>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 01/34] linux-user: Fix array bounds in errno conversion
Date: Fri, 11 Sep 2015 11:59:29 +0100	[thread overview]
Message-ID: <CAFEAcA8vUM_eSDxHOKocqrr488+tk+eOMQePaQK0fCoWy_fmBw@mail.gmail.com> (raw)
In-Reply-To: <1441497448-32489-2-git-send-email-T.E.Baldwin99@members.leeds.ac.uk>

On 6 September 2015 at 00:56, Timothy E Baldwin
<T.E.Baldwin99@members.leeds.ac.uk> wrote:
> Check array bounds in host_to_target_errno() and target_to_host_errno().
>
> Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> ---
>  linux-user/syscall.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 264debc..4e40dc6 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -566,14 +566,14 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE_SIZE] = {
>
>  static inline int host_to_target_errno(int err)
>  {
> -    if(host_to_target_errno_table[err])
> +    if(err < ERRNO_TABLE_SIZE && host_to_target_errno_table[err])
>          return host_to_target_errno_table[err];
>      return err;
>  }
>
>  static inline int target_to_host_errno(int err)
>  {
> -    if (target_to_host_errno_table[err])
> +    if (err < ERRNO_TABLE_SIZE && target_to_host_errno_table[err])
>          return target_to_host_errno_table[err];
>      return err;
>  }

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...)

-- PMM

  parent reply	other threads:[~2015-09-11 10:59 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-05 23:56 [Qemu-devel] [PATCH 00/34] linux-user: Fix signal race conditions and SA_RESTART Timothy E Baldwin
2015-09-05 23:56 ` [Qemu-devel] [PATCH 01/34] linux-user: Fix array bounds in errno conversion Timothy E Baldwin
2015-09-10 18:04   ` Peter Maydell
2015-09-11 10:59   ` Peter Maydell [this message]
2015-10-12 13:42     ` Riku Voipio
2015-10-31  2:51       ` Laurent Vivier
2015-09-05 23:56 ` [Qemu-devel] [PATCH 02/34] linux-user: Reindent signal handling Timothy E Baldwin
2015-09-05 23:56 ` [Qemu-devel] [PATCH 03/34] linux-user: Support for restarting system calls Timothy E Baldwin
2015-09-10 18:08   ` Peter Maydell
2015-09-05 23:56 ` [Qemu-devel] [PATCH 04/34] linux-user: Support for restarting system calls for x86 targets Timothy E Baldwin
2015-09-10 18:08   ` Peter Maydell
2015-09-05 23:56 ` [Qemu-devel] [PATCH 05/34] linux-user: Support for restarting system calls for ARM targets Timothy E Baldwin
2015-09-10 18:09   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 06/34] linux-user: Support for restarting system calls for MIPS targets Timothy E Baldwin
2015-09-10 18:09   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 07/34] linux-user: Support for restarting system calls for PPC targets Timothy E Baldwin
2015-09-10 18:10   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 08/34] linux-user: Support for restarting system calls for SPARC targets Timothy E Baldwin
2015-09-10 18:10   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 09/34] linux-user: Test for restarting system calls Timothy E Baldwin
2015-09-10 18:12   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 10/34] linux-user: Support for restarting system calls for Microblaze targets Timothy E Baldwin
2015-09-10 18:14   ` Peter Maydell
2016-03-03 20:15     ` Peter Maydell
2016-03-04  0:27       ` Edgar E. Iglesias
2016-03-04 10:11         ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 11/34] linux-user: Support for restarting system calls for SH4 targets Timothy E Baldwin
2015-09-10 18:15   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 12/34] linux-user: Support for restarting system calls for APLHA targets Timothy E Baldwin
2015-09-10 18:16   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 13/34] linux-user: Fix signal before blocking system calls race and SA_RESTART Timothy E Baldwin
2015-09-10 18:46   ` Peter Maydell
2015-09-11 10:57   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 14/34] linux-user: Use safe_syscall for read and write system calls Timothy E Baldwin
2015-09-10 18:48   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 15/34] linux-user: Remove redundant get_errno() calls Timothy E Baldwin
2015-09-10 18:50   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 16/34] linux-user: Use safe_syscall for open and openat system calls Timothy E Baldwin
2015-09-10 18:54   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 17/34] linux-user: Use safe_syscall for wait " Timothy E Baldwin
2015-09-10 18:58   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 18/34] linux-user: Fix race between multiple signals Timothy E Baldwin
2015-09-11 14:30   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 19/34] linux-user: Restart fork() if signals pending Timothy E Baldwin
2015-09-11 14:34   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 20/34] linux-user: Remove redundant default action check in queue_signal() Timothy E Baldwin
2015-09-11 14:41   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 21/34] linux-user: Remove redundant gdb_queuesig() Timothy E Baldwin
2015-09-05 23:57 ` [Qemu-devel] [PATCH 22/34] linux-user: Remove real-time signal queuing Timothy E Baldwin
2015-09-05 23:57 ` [Qemu-devel] [PATCH 23/34] linux-user: Queue synchronous signals separately Timothy E Baldwin
2015-09-05 23:57 ` [Qemu-devel] [PATCH 24/34] linux-user: Restart execve() if signal pending Timothy E Baldwin
2015-09-11 14:36   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 25/34] linux-user: Restart exit() " Timothy E Baldwin
2015-09-11 14:36   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 26/34] linux-user: Restart kill() " Timothy E Baldwin
2015-09-05 23:57 ` [Qemu-devel] [PATCH 27/34] linux-user: pause() should not pause " Timothy E Baldwin
2015-09-11 14:36   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 28/34] linux-user: Restart sigaction() " Timothy E Baldwin
2015-09-11 14:37   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 29/34] linux-user: Support for restarting system calls for UniCore32 targets Timothy E Baldwin
2015-09-10 19:05   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 30/34] linux-user: Support for restarting system calls for OpenRISC targets Timothy E Baldwin
2015-09-10 19:06   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 31/34] linux-user: Support for restarting system calls for M68K targets Timothy E Baldwin
2015-09-10 19:06   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 32/34] linux-user: Support for restarting system calls for S390 targets Timothy E Baldwin
2015-09-10 19:07   ` Peter Maydell
2015-09-05 23:57 ` [Qemu-devel] [PATCH 33/34] linux-user: Support for restarting system calls for CRIS targets Timothy E Baldwin
2015-09-10 19:12   ` Peter Maydell
2015-09-11 14:18     ` Edgar E. Iglesias
2015-09-11 14:20       ` Peter Maydell
2015-09-11 14:26         ` Edgar E. Iglesias
2015-09-05 23:57 ` [Qemu-devel] [PATCH 34/34] linux-user: Remove TARGET_USE_ERESTARTSYS Timothy E Baldwin
2015-09-10 19:13   ` Peter Maydell
2015-09-10 18:00 ` [Qemu-devel] [PATCH 00/34] linux-user: Fix signal race conditions and SA_RESTART Peter Maydell
2015-10-02 11:52   ` Riku Voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEAcA8vUM_eSDxHOKocqrr488+tk+eOMQePaQK0fCoWy_fmBw@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=T.E.Baldwin99@members.leeds.ac.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).