From: Luis <luis.machado.foss@gmail.com>
To: Pedro Alves <pedro@palves.net>,
Luis Machado <luis.machado@amd.com>,
gdb-patches@sourceware.org
Cc: guinevere@redhat.com
Subject: Re: [PATCH v3] gdb: replace alloca with gdb::unique_xmalloc_ptr in remote-fileio.c
Date: Fri, 3 Jul 2026 09:35:07 +0100 [thread overview]
Message-ID: <91a6f517-9e4f-434a-ab65-daadadf00b1a@gmail.com> (raw)
In-Reply-To: <391c7c82-c658-4122-a006-520232ad3cd8@palves.net>
On 01/07/2026 20:08, Pedro Alves wrote:
> On 2026-07-01 20:01, Luis Machado wrote:
>> remote_fileio_extract_ptr_w_len parsed a debuggee controlled 64 bit
>> length, narrowed it to int with no bounds check, and the value flowed
>> directly into alloca() across RSP File I/O handlers (Fopen, Frename,
>> Funlink, Fstat, Fsystem). A malicious inferior or remote stub could
>> send a crafted packet with a large path length, displacing the stack
>> pointer by up to 2 GiB and potentially crashing the debugger.
>>
>> remote_fileio_extract_ptr_w_len now rejects negative lengths, lengths
>> that would overflow the int result (greater than INT_MAX), and zero.
>> An allow_zero_length flag lets the Fsystem handler opt in to the zero
>> length sentinel that signals a NULL cmdline query. All other handlers
>> use the default and are protected without any per call checks. Oversized
>> names are rejected naturally by the underlying syscall with ENAMETOOLONG.
>> All alloca(length) calls have been replaced with
>> gdb::unique_xmalloc_ptr<char>, so an oversized but positive length now
>> fails as a graceful heap allocation error rather than corrupting the
>> stack.
>>
>> Add a selftest that exercises various problematic cases.
>>
>> Signed-off-by: Luis Machado <luis.machado@amd.com>
>
> Approved-By: Pedro Alves <pedro@palves.net>
>
Thanks. Pushed now.
prev parent reply other threads:[~2026-07-03 8:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 9:52 [PATCH] gdb: replace alloca with gdb::char_vector " Luis Machado
2026-06-30 21:07 ` Guinevere Larsen
2026-07-01 13:03 ` Pedro Alves
2026-07-01 15:08 ` Machado, Luis
2026-07-01 15:07 ` [PATCH v2] gdb: replace alloca with gdb::unique_xmalloc_ptr " Luis Machado
2026-07-01 18:20 ` Pedro Alves
2026-07-01 19:01 ` Machado, Luis
2026-07-01 19:01 ` [PATCH v3] " Luis Machado
2026-07-01 19:08 ` Pedro Alves
2026-07-03 8:35 ` Luis [this message]
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=91a6f517-9e4f-434a-ab65-daadadf00b1a@gmail.com \
--to=luis.machado.foss@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
--cc=luis.machado@amd.com \
--cc=pedro@palves.net \
/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