mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Raushan Patel <raushan.jhon@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] tracing/fprobe: Roll back on enable_trace_fprobe() failure
Date: Tue, 28 Jul 2026 23:54:17 +0900	[thread overview]
Message-ID: <20260728235417.67604155d14d30094d6fd100@kernel.org> (raw)
In-Reply-To: <20260724064208.480030-1-raushan.jhon@gmail.com>

On Fri, 24 Jul 2026 12:12:08 +0530
Raushan Patel <raushan.jhon@gmail.com> wrote:

> enable_trace_fprobe() sets the file link or the TP_FLAG_PROFILE flag and
> then registers each trace_fprobe in the probe list. If
> __register_trace_fprobe() fails partway through, the function returns
> immediately without unregistering the trace_fprobes it already registered
> or undoing the file link / flag it set, leaving the event half-enabled and
> leaking the registered fprobe(s).
> 
> enable_trace_kprobe() already handles this with a rollback path. Do the
> same for fprobe: on failure, unregister all probes and clear the file link
> or profile flag.
> 

OK, looks good to me.

Thanks!

> Fixes: 334e5519c375 ("tracing/probes: Add fprobe events for tracing function entry and exit.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Raushan Patel <raushan.jhon@gmail.com>
> ---
>  kernel/trace/trace_fprobe.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> index 9f5f08c0e7c2..3120403a5b60 100644
> --- a/kernel/trace/trace_fprobe.c
> +++ b/kernel/trace/trace_fprobe.c
> @@ -1481,11 +1481,21 @@ static int enable_trace_fprobe(struct trace_event_call *call,
>  		list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) {
>  			ret = __register_trace_fprobe(tf);
>  			if (ret < 0)
> -				return ret;
> +				goto err;
>  		}
>  	}
>  
>  	return 0;
> +
> +err:
> +	/* Failed to enable one of them. Roll back all */
> +	list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list)
> +		__unregister_trace_fprobe(tf);
> +	if (file)
> +		trace_probe_remove_file(tp, file);
> +	else
> +		trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
> +	return ret;
>  }
>  
>  /*
> -- 
> 2.53.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2026-07-28 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  6:42 Raushan Patel
2026-07-28 14:54 ` Masami Hiramatsu [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=20260728235417.67604155d14d30094d6fd100@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=raushan.jhon@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /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®