qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault
Date: Sun, 20 Nov 2011 15:31:04 +0000

On 20 November 2011 12:06, Alexander Graf <address@hidden> wrote:
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -711,6 +711,9 @@ static inline int host_to_target_errno(int err)
>
>  static inline int target_to_host_errno(int err)
>  {
> +    if (err >= ERRNO_TABLE_SIZE) {
> +        return err;
> +    }
>     if (target_to_host_errno_table[err])
>         return target_to_host_errno_table[err];
>     return err;

Really strace shouldn't be assuming all negative values
are errnos: the code has a "print in one format for errnos,
print in another if we're assuming it's an address", so we
should have a way for the stracing code to be making the
right "errno or not?" decision, so we can print these normal
return values properly.

Since target_to_host_errno() is only used by target_strerror()
and target_strerror() is only used by the strace code we should
just change its API to something easier for the strace code to
use. How about having target_strerror() return NULL for "this
doesn't look like an errno", and then the strace layer prints
the plain address or "address (errno string)" accordingly?

OTOH host_to_target_errno() could probably use a bounds check.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]