mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jordan Rife <jrife@google.com>,
	acme@kernel.org, alexander.shishkin@linux.intel.com,
	andrii.nakryiko@gmail.com, ast@kernel.org, bpf@vger.kernel.org,
	joel@joelfernandes.org, linux-kernel@vger.kernel.org,
	mark.rutland@arm.com, mhiramat@kernel.org, mingo@redhat.com,
	mjeanson@efficios.com, namhyung@kernel.org, paulmck@kernel.org,
	peterz@infradead.org,
	syzbot+b390c8062d8387b6272a@syzkaller.appspotmail.com,
	yhs@fb.com
Subject: Re: [RFC PATCH v1] tracing: Fix syscall tracepoint use-after-free
Date: Sat, 26 Oct 2024 11:17:38 -0400	[thread overview]
Message-ID: <da4beb18-7bed-41bd-aeba-94497eff0b58@efficios.com> (raw)
In-Reply-To: <b961bc6b-331c-4315-b424-60d514cc112e@efficios.com>

On 2024-10-26 10:25, Mathieu Desnoyers wrote:
> On 2024-10-26 03:13, Steven Rostedt wrote:
>> On Fri, 25 Oct 2024 15:38:48 -0400
>> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>
>>>> I'm curious if it might be better to add some field to struct
>>>> tracepoint like "sleepable" rather than adding a special case here
>>>> based on the name? Of course, if it's only ever going to be these
>>>> two cases then maybe adding a new field doesn't make sense.
>>>
>>> I know Steven is reluctant to bloat the tracepoint struct because there
>>> are lots of tracepoint instances (thousands). So for now I thought that
>>> just comparing the name would be a good start.
>>
>> You are correct. I really trying to keep the footprint of
>> tracepoints/events down.
>>
>>>
>>> We can eventually go a different route as well: introduce a section just
>>> to put the syscall tracepoints, and compare the struct tracepoint
>>> pointers to the section begin/end range. But it's rather complex
>>> for what should remain a simple fix.
>>
>> A separate section could work.
> 
> I have another approach to suggest: it shrinks the
> size of struct tracepoint from 80 bytes down to 72 bytes
> on x86-64, we don't have to do any section/linker
> script trickery, and it's extensible for future flags:
> 
> struct static_key {
>          int enabled;
>          void *p;
> };
> 
> struct static_key_false {
>          struct static_key key;
> };
> 
> struct static_call_key {
>          void *func;
>          void *p;
> };
> 
> struct tracepoint {
>          const char *name;               /* Tracepoint name */
>          struct static_key_false key;
>          struct static_call_key *static_call_key;
>          void *static_call_tramp;
>          void *iterator;
>          void *probestub;
>          void *funcs;
>          /* Flags. */
>          unsigned int regfunc:1,
>                       syscall:1;
> };
> 
> struct tracepoint_regfunc {
>          struct tracepoint tp;
>          int (*regfunc)(void);
>          void (*unregfunc)(void);
> };
> 
> Basically, a tracepoint with regfunc would define a
> struct tracepoint_regfunc rather than a struct tracepoint.
> So we remove both regfunc and unregfunc NULL pointers in
> the common case, which gives us plenty of room for flags.
> 
> When we want to access the regfunc/unregfunc from
> a struct tracepoint, we check the regfunc flag, and
> if set, we can use container_of() to get the struct
> tracepoint_regfunc.

Actually I can achieve the same space saving with fewer
changes like this:

struct tracepoint_ext {
     void *regfunc;
     void *unregfunc;
     /* Flags. */
     unsigned int syscall:1;
}

struct tracepoint {
         const char *name;               /* Tracepoint name */
         struct static_key_false key;
         struct static_call_key *static_call_key;
         void *static_call_tramp;
         void *iterator;
         void *probestub;
         void *funcs;
         struct tracepoint_ext *ext;
};

Thanks,

Mathieu

> 
> Thoughts ?
> 
> Thanks,
> 
> Mathieu
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


      reply	other threads:[~2024-10-26 15:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 18:21 Mathieu Desnoyers
2024-10-25 19:08 ` Jordan Rife
2024-10-25 19:38   ` Mathieu Desnoyers
2024-10-26  7:13     ` Steven Rostedt
2024-10-26 14:25       ` Mathieu Desnoyers
2024-10-26 15:17         ` Mathieu Desnoyers [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=da4beb18-7bed-41bd-aeba-94497eff0b58@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=jrife@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjeanson@efficios.com \
    --cc=namhyung@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=syzbot+b390c8062d8387b6272a@syzkaller.appspotmail.com \
    --cc=yhs@fb.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

all inboxes | Powered by JetHome®