mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jordan Rife <jrife@google.com>
To: mathieu.desnoyers@efficios.com
Cc: acme@kernel.org, alexander.shishkin@linux.intel.com,
	 andrii.nakryiko@gmail.com, ast@kernel.org, bpf@vger.kernel.org,
	 joel@joelfernandes.org, jrife@google.com,
	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,
	rostedt@goodmis.org,
	 syzbot+b390c8062d8387b6272a@syzkaller.appspotmail.com,
	yhs@fb.com
Subject: Re: [RFC PATCH v1] tracing: Fix syscall tracepoint use-after-free
Date: Fri, 25 Oct 2024 19:08:54 +0000	[thread overview]
Message-ID: <20241025190854.3030636-1-jrife@google.com> (raw)
In-Reply-To: <20241025182149.500274-1-mathieu.desnoyers@efficios.com>

> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 59de664e580d..1191dc1d4206 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -3006,14 +3006,21 @@ static void bpf_link_free(struct bpf_link *link)
>                 bpf_prog_put(link->prog);

I think we would need the same treatment with bpf_prog_put here.
Something like,

tracepoint_call_rcu(raw_tp->btp->tp, &link->prog->aux->rcu,
		    bpf_link_defer_bpf_prog_put);

static void bpf_link_defer_bpf_prog_put(struct rcu_head *rcu)
{
	struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu);
	bpf_prog_put(aux->prox);
}

Alternatively, some context would need to be passed down to
__bpf_prog_put_noref via the call to bpf_prog_put so it can choose
whether or not to use call_rcu or call_rcu_tasks_trace.

> -static inline void release_probes(struct tracepoint_func *old)
> +static bool tracepoint_is_syscall(struct tracepoint *tp)
> +{
> +       return !strcmp(tp->name, "sys_enter") || !strcmp(tp->name, "sys_exit");
> +}

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.

-Jordan

  reply	other threads:[~2024-10-25 19:09 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 [this message]
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

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=20241025190854.3030636-1-jrife@google.com \
    --to=jrife@google.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=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.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®