Re: [PATCH v2 03/13] tracing/uprobes: handle errors from resolving the real inode

From: Christian Brauner

Date: Wed Nov 18 2026 - 11:41:40 EST


On Wed, Nov 18, 2026 at 10:30:48AM +0900, Masami Hiramatsu (Google) wrote:
> On Mon, 16 Nov 2026 10:44:00 +0100, Christian Brauner <brauner@xxxxxxxxxx> wrote:
> > d_real() is about to be able to fail for D_REAL_DATA. So switch
> > trace_uprobe from d_real_inode() to d_real_data_inode() and deal with
> > the error.
> >
> > Currently, nothing checks whether the data can be resolved when a uprobe
> > is created. The first resolution happens in validate_ref_ctr_offset()
> > under event_mutex and the last one when the event is enabled. If the
> > data of a metacopy file in an overlayfs data-only layer can't be found
> > the event is created just fine and enabling it fails later with an -EIO
> > from uprobe_register() because the overlayfs inode has no
> > ->read_folio().
> >
> > Instead, resolve the inode hosting the data once in
> > __trace_uprobe_create() right after kern_path(). That happens outside
> > of event_mutex and if it fails the write to uprobe_events or
> > dynamic_events fails with the actual error and a new NO_FILE_DATA entry
> > in the error log. The resolved inode is passed down to
> > validate_ref_ctr_offset() and trace_uprobe_has_same_uprobe() so we don't
> > resolve it again under event_mutex.
> >
> > Both functions still resolve the existing probes they compare against.
> > If that fails the existing probe can't be on the same inode so we just
> > skip it. For validate_ref_ctr_offset() that's fine because
> > uprobe_register() refuses a mismatching reference counter offset for the
> > same uprobe anyway.
> >
> > trace_uprobe_enable() returns the error and probe_event_enable()
> > already unwinds the probes that were enabled before.
> >
> > While at it, resolve the data in create_local_trace_uprobe() as well.
> > perf_event_open() of a uprobe PMU event registers the probe right away
> > so it would fail in trace_uprobe_enable() anyway. But this way the first
> > resolution happens before perf_uprobe_init() takes event_mutex just like
> > for uprobes created through tracefs.
> >
> > This is a no-op until d_real() can actually fail.
> >
>
> Looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> However, since this conflict with commit 72d3a5cb0cd7 ("tracing/probes:
> Enable newly appended probe when target event is enabled"), please
> rebase it on v7.4-rc3.

Yeah, I had already done that.