All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: linux-kernel@vger.kernel.org
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@kernel.org>
Subject: [PATCH] debugobjects: skip activate fixup when disabled by a concurrent OOM
Date: Wed, 10 Jun 2026 11:47:25 +0800	[thread overview]
Message-ID: <20260610034726.213910-1-jiayuan.chen@linux.dev> (raw)

When a tracking object cannot be allocated, lookup_object_or_alloc()
sets debug_objects_enabled = false and the caller runs
debug_objects_oom(), which wipes the whole hash. The flag is cleared
before the hash is wiped.

debug_object_activate() only tests debug_objects_enabled once on entry.
If another CPU hits OOM and wipes the hash after that test, the lookup
here misses and the object is taken as ODEBUG_STATE_NOTAVAILABLE.
fixup_activate() then "repairs" it; for timers that overwrites a live
timer's callback with stub_timer, which later fires a bogus WARN.

Re-check debug_objects_enabled while still holding the bucket lock,
before the fixup. The flag is cleared before the hash is wiped, and both
the wipe and the lookup are serialized by the bucket lock, so a
wipe-induced miss is guaranteed to observe the cleared flag and the
spurious fixup is skipped.

Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
 lib/debugobjects.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index b18a682fe3da..fcb7949cb2be 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -865,6 +865,16 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)
 		}
 	}
 
+	/*
+	 * A concurrent OOM teardown may have disabled debugobjects and
+	 * wiped the hash after the check at function entry. So we need
+	 * check it again here.
+	 */
+	if (!debug_objects_enabled) {
+		raw_spin_unlock_irqrestore(&db->lock, flags);
+		return 0;
+	}
+
 	raw_spin_unlock_irqrestore(&db->lock, flags);
 	debug_print_object(&o, "activate");
 
-- 
2.43.0


                 reply	other threads:[~2026-06-10  3:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260610034726.213910-1-jiayuan.chen@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.