Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf dso: With ref count checking, avoid dso_data holding dso live

With the dso_data embedded in a dso there is a reference counted
pointer to the dso rather than using container_of with reference count
checking. This data can hold the dso live meaning that no dso__put
ever deletes it. Add a check for this case and close the dso_data when
it happens. There isn't an infinite loop as the dso_data clears the
file descriptor prior to putting on the dso.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250624190326.2038704-5-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
e793e2c0 d1f18106

+4
+4
tools/perf/util/dso.c
··· 1612 1612 1613 1613 void dso__put(struct dso *dso) 1614 1614 { 1615 + #ifdef REFCNT_CHECKING 1616 + if (dso && dso__data(dso) && refcount_read(&RC_CHK_ACCESS(dso)->refcnt) == 2) 1617 + dso__data_close(dso); 1618 + #endif 1615 1619 if (dso && refcount_dec_and_test(&RC_CHK_ACCESS(dso)->refcnt)) 1616 1620 dso__delete(dso); 1617 1621 else