qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] gdbstub: Add a missing case of signal number tr


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] gdbstub: Add a missing case of signal number translation in gdbstub
Date: Tue, 4 Nov 2014 19:09:43 +0000

On 4 November 2014 17:51, Martin Simmons <address@hidden> wrote:
> While using qemu with gdb "target remote" to debug an application that uses
> fork and exec, the qemu process receives SIGSTOP every time the forked process
> terminates (sending SIGCHLD).
>
> This is caused by a missing call to gdb_signal_to_target in gdbstub.c, which
> is fixed by this patch:
>
> Signed-off-by: Martin Simmons <address@hidden>
>
> diff --git a/gdbstub.c b/gdbstub.c
> index d1b5afd..6a73a35 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -823,7 +823,9 @@ static int gdb_handle_packet(GDBState *s, const char 
> *line_buf)
>                  action = *p++;
>                  signal = 0;
>                  if (action == 'C' || action == 'S') {
> -                    signal = strtoul(p, (char **)&p, 16);
> +                    signal = gdb_signal_to_target (strtoul(p, (char **)&p, 
> 16));
> +                    if (signal == -1)
> +                        signal = 0;
>                  } else if (action != 'c' && action != 's') {
>                      res = 0;
>                      break;

The if() statement should have braces for our coding style,
and no space before the '(' in function calls; otherwise this
looks good to me.

I notice that gdb_signal_to_target() doesn't check for being
passed negative numbers, which means a malicious gdb could
make us crash here, but I assume nobody actually treats the
gdbstub as a security boundary... Anyway, that's a separate
issue for a different patch.

thanks
-- PMM



reply via email to

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