[DTrace-devel] [PATCH] Relocation processing of STBSZ in ERROR's get_bvar() is too early
Eugene Loh
eugene.loh at oracle.com
Mon Sep 16 17:28:31 UTC 2024
On 9/13/24 22:53, Kris Van Hees wrote:
> I don't thibk this is the right solution. There are other values that are
> resolved as a relocation in dt_link_construct() and that could be found in
> an ERROR clause and thus get resolved before the correct value is known.
>
> Instead, I think we need to simply move the construction of the dt_error
> program into dt_bpf_load_progs(). I should have done that when I split
> up program construction and loading into two distinct phases.
>
> I'll post an alternative patch in a moment...
Thanks. I confess I posted this patch impatiently, with the uneasy
suspicion that the relocation was simply being performed at the wrong time.
> On Fri, Sep 13, 2024 at 07:36:04PM -0400, eugene.loh--- via DTrace-devel wrote:
>> From: Eugene Loh <eugene.loh at oracle.com>
>>
>> When we call dtrace_go(), we do something like this:
>>
>> dt_bpf_make_progs()
>> dt_program_construct() // just for ERROR
>> dt_link()
>> dt_link_construct()
>> dt_bpf_gmap_create()
>> dt_bpf_load_progs() // other
>> dt_link()
>> dt_link_construct()
>>
>> In dt_link_construct() we dive down and find dt_get_bvar(). One of the
>> relocations is to supply the value of STBSZ. The first dt_link() is for
>> ERROR, while the subsequent calls in dt_bpf_load_progs() are for other
>> clauses -- that is, two separate versions of dt_get_bvar() are used.
>> Meanwhile, the value of STBSZ is not set until dt_bpf_gmap_create().
>> This means that the ERROR copy of dt_get_bvar() does not have STBSZ set
>> properly. This means that if ERROR accesses probeprov or probename,
>> dt_get_bvar() returns the beginning of the string table, which is a NUL
>> terminator.
>>
>> Change dt_bpf_reloc_prog() -- which performs relocation processing for
>> BPF maps, necessarily after dt_bpf_gmap_create()! -- to check STBSZ
>> and set its value if necessary.
More information about the DTrace-devel
mailing list