Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
Subject: Re: [PATCH 0/7 V2] Trust readonly sections if target has memory protection
Date: Mon, 30 Sep 2013 17:50:00 -0000	[thread overview]
Message-ID: <5249B9F9.4030901@redhat.com> (raw)
In-Reply-To: <5232C9EC.2040707@codesourcery.com>

On 09/13/2013 09:16 AM, Yao Qi wrote:
> On 09/12/2013 05:49 PM, Mark Kettenis wrote:
>> I'm certainly not outright rejecting it.  But you'll certainly need to
>> rethink in which contexts it is safe/acceptable that "auto" actually
>> turns on the trust-readonly-sections feature.  That decision should
>> probably be done on a per-architecture, per-OS basis, and only for
>> remote debugging.
> 
> Yeah, that is reasonable to me.  Then, the proposed scope could be
> {x86, x86_64}-{linux,mingw,cygwin} for remote debugging only.  What do
> you think?

This makes me extremely nervous.

I think it's completely wrong to distinguish local/remote debugging.
Local or remote doesn't make the feature more or less safe.  We should
aim for local/remote feature (and experience/safeness) parity.  At some
point, native debugging may well always go through a "remote" server
behind the scenes (like connecting to a local gdbserver that gdb itself
spawns), so we could see this enablement now for remote targets as
a (unintended) "trojan" for having it silently enabled for native
targets at some point.  Having the debug session behave differently
with a native target vs a remote target is just fundamentally wrong, IMO.
I don't want to have to say or explain to people that they should
"debug natively to be safer".

I've been background-thinking about taking a step back and understand
why each use case that is sped up with this patch is slow to begin with.
That is, the series jumps to a solution, but we haven't done our due diligence
with analyzing the problem thoroughly, IMO.  E.g., for the disassembly use
case, presented in the v1 series, I'd think that the problem is that GDB is
fetching data off the target instruction by instruction, instead of requesting
a block of memory and working with that.  More aggressive over fetching
could be a better/safer approach.

We have similar infrastructure already, in dcache.c -- we use
it for stack memory nowadays, and if the memory region is marked as
cacheable.  We used to support caching more than just stack, but
that was never enabled by default because it may not be safe to
read memory outside of the range the caller is specifying, because of
things like memory mapped registers, etc.  (In the case of stack, we assume
stack is allocated in page chunks, so that dcache never steps on memory is
should not).  But in cases like disassembly, we're being driven by debug
info or user input.  As GDB knows upfront the whole range of memory it'll
be fetching, accessing a bigger chunk upfront, as long as it doesn't
step out of the range we read piecemeal anyway, should have no effect
on correctness.

Another orthogonal idea (we could/should have both) would be to check
whether sections/blocks/pages of memory haven't been changed in the target
with  target_verify_memory/qCRC packet, and iff not, fall back to reading
from the file.  IOW, don't fallback to reading from file if the memory has
been changed in the target (or if we can't tell).

These things could in addition be predicated on whether the target
is completely stopped (we have a crude version of that today in
prepare_execute_command).

-- 
Pedro Alves


  reply	other threads:[~2013-09-30 17:50 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06  2:03 [PATCH 0/3] " Yao Qi
2013-09-06  2:03 ` [PATCH 1/3] set trust-readonly-sections off in test cases Yao Qi
2013-09-06  5:56   ` Eli Zaretskii
2013-09-06 17:23   ` Pedro Alves
2013-09-06  2:03 ` [PATCH 2/3] Trust readonly sections if target has memory protection Yao Qi
2013-09-06  6:05   ` Eli Zaretskii
2013-09-06  9:07     ` Yao Qi
2013-09-06  9:24       ` Eli Zaretskii
2013-09-06  2:03 ` [PATCH 3/3] Linux " Yao Qi
2013-09-06  5:57 ` [PATCH 0/3] Trust readonly sections if target " Eli Zaretskii
2013-09-06  8:24   ` Yao Qi
2013-09-06  8:45     ` Eli Zaretskii
2013-09-06 13:03       ` Joel Brobecker
2013-09-06 13:27         ` Yao Qi
2013-09-06 13:32         ` Eli Zaretskii
2013-09-06 14:17           ` Pierre Muller
     [not found]           ` <"000d01ceab0b$d53ae600$7fb0b200$@muller"@ics-cnrs.unistra.fr>
2013-09-06 14:38             ` Eli Zaretskii
2013-09-06 14:52           ` Joel Brobecker
2013-09-06 15:56             ` Eli Zaretskii
2013-09-06 18:10               ` Joel Brobecker
2013-09-06 18:36                 ` Eli Zaretskii
2013-09-06 13:00 ` Joel Brobecker
2013-09-08 12:04 ` [PATCH 0/7 V2] " Yao Qi
2013-09-08 12:04   ` [PATCH 1/7] Emit a warning when writing to a readonly section and trust_readonly is true Yao Qi
2013-09-08 15:10     ` Eli Zaretskii
2013-09-08 12:05   ` [PATCH 4/7] Trust readonly sections if target has memory protection Yao Qi
2013-09-08 15:13     ` Eli Zaretskii
2013-09-09  7:49       ` Yao Qi
2013-09-09 16:25         ` Eli Zaretskii
2013-09-08 12:05   ` [PATCH 3/7] New function windows_init_abi Yao Qi
2013-09-08 12:05   ` [PATCH 7/7] Windows has memory protection Yao Qi
2013-09-08 12:05   ` [PATCH 2/7] set trust-readonly-sections off in test cases Yao Qi
2013-09-08 12:05   ` [PATCH 5/7] DOC and NEWS Yao Qi
2013-09-08 12:05   ` [PATCH 6/7] Linux has memory protection Yao Qi
2013-09-09 19:16   ` [PATCH 0/7 V2] Trust readonly sections if target " Mark Kettenis
2013-09-10  4:06     ` Yao Qi
2013-09-12  8:30       ` Yao Qi
2013-09-12  9:49         ` Mark Kettenis
2013-09-13  8:17           ` Yao Qi
2013-09-30 17:50             ` Pedro Alves [this message]
2013-09-30 18:08               ` Pedro Alves
2013-10-07 22:29                 ` Stan Shebs
2013-10-08 12:18                   ` Pedro Alves
2013-10-08 12:47                     ` Abid, Hafiz
2013-10-08 13:36                       ` tmirza
2013-10-09  2:24               ` Doug Evans
2013-10-23 10:16                 ` Yao Qi
2013-10-15  0:44               ` Yao Qi
2013-09-20  2:47   ` [PATCH 0/7 V3] " Yao Qi
2013-09-20  2:47     ` [PATCH 4/7] Trust readonly sections if target has memory protection and in remote debugging Yao Qi
2013-09-20  2:47     ` [PATCH 7/7] Windows has memory protection Yao Qi
2013-09-20  2:47     ` [PATCH 1/7] Emit a query when writing to a readonly section and trust_readonly is true Yao Qi
2013-09-20  2:47     ` [PATCH 3/7] New function windows_init_abi Yao Qi
2013-09-30 18:23       ` Pedro Alves
2013-10-01  6:47         ` Yao Qi
2013-10-01  9:35           ` Pedro Alves
2013-10-01 13:23             ` Yao Qi
2013-09-20  2:47     ` [PATCH 6/7] Linux has memory protection Yao Qi
2013-09-20  2:47     ` [PATCH 2/7] set trust-readonly-sections off in test cases Yao Qi
2013-09-20  2:47     ` [PATCH 5/7] DOC and NEWS Yao Qi
2013-09-20  8:21       ` Eli Zaretskii
2013-09-29 13:51     ` [PATCH 0/7 V3] Trust readonly sections if target has memory protection Yao Qi

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=5249B9F9.4030901@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=yao@codesourcery.com \
    /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