From: Peter Maydell <peter.maydell@linaro.org>
To: Martin Simmons <martin@lispworks.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
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 [thread overview]
Message-ID: <CAFEAcA9X35ptR64c=rFEN42de1Lrp_+ikuVFcxM2ZENGZY_aag@mail.gmail.com> (raw)
In-Reply-To: <201411041751.sA4Hpu4X013678@heapu.cam.lispworks.com>
On 4 November 2014 17:51, Martin Simmons <martin@lispworks.com> 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 <martin@lispworks.com>
>
> 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
next prev parent reply other threads:[~2014-11-04 19:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 17:51 [Qemu-devel] [PATCH] gdbstub: Add a missing case of signal number translation in gdbstub Martin Simmons
2014-11-04 19:09 ` Peter Maydell [this message]
2014-11-05 13:50 ` Martin Simmons
2014-11-05 14:17 ` Peter Maydell
2014-11-05 14:47 ` Martin Simmons
2014-11-05 15:06 ` Peter Maydell
2014-11-11 5:59 ` Michael Tokarev
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='CAFEAcA9X35ptR64c=rFEN42de1Lrp_+ikuVFcxM2ZENGZY_aag@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=martin@lispworks.com \
--cc=qemu-devel@nongnu.org \
/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).