qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Damien Hedde <damien.hedde@greensocs.com>
Cc: luis.machado@linaro.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	richard.henderson@linaro.org, qemu-devel@nongnu.org,
	alan.hayward@arm.com
Subject: Re: [PATCH v3 04/20] gdbstub: move mem_buf to GDBState and use GByteArray
Date: Thu, 19 Dec 2019 14:44:24 +0000	[thread overview]
Message-ID: <87sglge5o7.fsf@linaro.org> (raw)
In-Reply-To: <b5cfb77b-b969-f7e8-fb7f-a2eddd394578@greensocs.com>


Damien Hedde <damien.hedde@greensocs.com> writes:

> On 12/11/19 6:05 PM, Alex Bennée wrote:
>> This is in preparation for further re-factoring of the register API
>> with the rest of the code. Theoretically the read register function
>> could overwrite the MAX_PACKET_LENGTH buffer although currently all
>> registers are well within the size range.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
>> Tested-by: Damien Hedde <damien.hedde@greensocs.com>
>> 
>> ---
>> v3
>>   - fixed up email on Damien's tags
>> ---
>>  gdbstub.c | 56 ++++++++++++++++++++++++++++++++++---------------------
>>  1 file changed, 35 insertions(+), 21 deletions(-)
>> 
>
>> @@ -2092,11 +2105,12 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx)
>>      }
>>  
>>      len = len / 2;
>> -    hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len);
>> -    gdb_ctx->mem_buf[len++] = 0;
>> -    qemu_chr_be_write(gdbserver_state.mon_chr, gdb_ctx->mem_buf, len);
>> +    g_byte_array_set_size(gdbserver_state.mem_buf, len);
>
> Hi Alex,
>
> Just found out that the g_byte_array_set_size() above should be removed.
> hextomem() will append data starting at offset [len] instead of [0] and
> we end up with an uninitialized prefix in the array.

Oops, fixed. I should assert len is 0 before we start.

>
>> +    hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len);
>> +    g_byte_array_append(gdbserver_state.mem_buf, &zero, 1);
>> +    qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->data,
>> +                      gdbserver_state.mem_buf->len);
>>      put_packet("OK");
>> -
>>  }
>>  #endif
>>  
>> 
>
> I did double-checked the rest of the patch and it is it the only resize
> that passed through v2 review.
>
> Regards,
> Damien


-- 
Alex Bennée


  reply	other threads:[~2019-12-19 14:57 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 17:05 [PATCH v3 00/20] gdbstub refactor and SVE support (+check-tcg tweaks) Alex Bennée
2019-12-11 17:05 ` [PATCH v3 01/20] gdbstub: make GDBState static and have common init function Alex Bennée
2019-12-11 17:05 ` [PATCH v3 02/20] gdbstub: stop passing GDBState * around and use global Alex Bennée
2019-12-11 17:05 ` [PATCH v3 03/20] gdbstub: move str_buf to GDBState and use GString Alex Bennée
2019-12-11 17:05 ` [PATCH v3 04/20] gdbstub: move mem_buf to GDBState and use GByteArray Alex Bennée
2019-12-13 12:31   ` Damien Hedde
2019-12-19 14:44     ` Alex Bennée [this message]
2019-12-11 17:05 ` [PATCH v3 05/20] gdbstub: add helper for 128 bit registers Alex Bennée
2019-12-11 17:05 ` [PATCH v3 06/20] target/arm: use gdb_get_reg helpers Alex Bennée
2019-12-12  1:44   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 07/20] target/m68k: " Alex Bennée
2019-12-11 17:08   ` Laurent Vivier
2019-12-11 17:05 ` [PATCH v3 08/20] gdbstub: extend GByteArray to read register helpers Alex Bennée
2019-12-11 18:31   ` Damien Hedde
2019-12-19 17:50     ` Alex Bennée
2019-12-12  1:55   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 09/20] target/arm: prepare for multiple dynamic XMLs Alex Bennée
2019-12-11 17:05 ` [PATCH v3 10/20] target/arm: explicitly encode regnum in our XML Alex Bennée
2019-12-11 17:05 ` [PATCH v3 11/20] target/arm: default SVE length to 64 bytes for linux-user Alex Bennée
2019-12-12  2:09   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 12/20] target/arm: generate xml description of our SVE registers Alex Bennée
2019-12-12  2:26   ` Richard Henderson
2019-12-12  8:24     ` Alex Bennée
2019-12-19 19:15     ` Alex Bennée
2019-12-20 11:45       ` Luis Machado
2019-12-20 13:14         ` Alex Bennée
2019-12-20 13:18           ` Luis Machado
2020-01-08 15:57             ` Alan Hayward
2020-01-09 12:08               ` Alex Bennée
2020-01-09 14:10                 ` Alan Hayward
2019-12-11 17:05 ` [PATCH v3 13/20] tests/tcg: add a configure compiler check for ARMv8.1 and SVE Alex Bennée
2019-12-11 17:05 ` [PATCH v3 14/20] target/arm: don't bother with id_aa64pfr0_read for USER_ONLY Alex Bennée
2019-12-12  2:29   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 15/20] tests/tcg/aarch64: userspace system register test Alex Bennée
2019-12-11 17:05 ` [PATCH v3 16/20] tests/tcg: ensure we re-configure if configure.sh is updated Alex Bennée
2019-12-12  2:34   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 17/20] tests/guest-debug: add a simple test runner Alex Bennée
2019-12-11 17:05 ` [PATCH v3 18/20] tests/tcg/aarch64: add a gdbstub testcase for SVE registers Alex Bennée
2019-12-11 17:05 ` [PATCH v3 19/20] tests/tcg/aarch64: add SVE iotcl test Alex Bennée
2019-12-12  2:37   ` Richard Henderson
2019-12-11 17:05 ` [PATCH v3 20/20] tests/tcg/aarch64: add test-sve-ioctl guest-debug test Alex Bennée

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=87sglge5o7.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=alan.hayward@arm.com \
    --cc=damien.hedde@greensocs.com \
    --cc=luis.machado@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).