Re: [RFA] [1/2] auto-loading scripts from .debug_gdb_scripts section

Doug Evans
2010-04-20T21:38:41Z

On Tue, Apr 20, 2010 at 12:13 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> This patch adds support for auto-loading scripts mentioned in
> Doug> section .debug_gdb_scripts.
>
> It seems reasonable to me.  I looked through the patch and didn't see
> anything I disagreed with.

Great.

> I'm curious why these new scripts are attached to the program space and
> not just the objfile from which the section came.  But, I don't think it
> really matters.

In the case of multiple scripts each being defined in multiple
objfiles, I wanted to minimize the accumulated number of scripts one
had to deal with (there could be *lots* of duplicates). Once one does
that one can't attach scripts to objfiles because one doesn't
necessarily want the script to go away if the objfile goes away. I
had a patch that reference counted them, but it seemed excessive for
now so I abandoned it.

> I'm somewhat concerned about security.  I don't know why I didn't think
> of this before :-(.  The issue is that either approach can result in
> random Python code being loaded into gdb.
>
> One idea for a fix would be to check the script file's ownership and
> permissions before reading it.  I think we'd need to allow files to be
> owned by the current user or by root in order for this to work nicely in
> the distro case.

That's probably the right default choice, but I can imagine wanting
more flexibility.