From nobody Fri Oct 2 09:22:05 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25F553B0AC4; Mon, 3 Aug 2026 08:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785744602; cv=none; b=OEjtcCHEF3oHYpMFv3L9H1/XIrkRN+mYHgc2hWCEX/wm2fVegK79ldEn6b+FBefOhWVjR0CT0+hAObHzvBbEiWp+/+i7QF1iVWu/9O4rLaYv+SWZnAME932NfXElsNr4Jw+imr/s9B5uTzHNBOFZ8jMDgsnf5OYtE0mT3EYRuxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785744602; c=relaxed/simple; bh=RFWrJpEerE4jq4K8JYkSe8jFpBW+sC5O64JewAu45rQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=a7NqZN9arX5G/tpWFsyrJPE8EC9nVauELdWkAXAWJCB++76Z7/ZFqMxsHM4sI8wuuNepEVpkzJQr7B8NWiRO9tOpWEVLulseYBLThYozCOi33nIm1NSPaXJ6gu9R1qQVsw1HlOj/UAxgevApDR7PiI6LFkWFZrWreCNfPVbX+A8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BjrxHEkL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=20RMkAyC; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BjrxHEkL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="20RMkAyC" Date: Mon, 03 Aug 2026 08:09:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785744593; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nc8F0io+B/d5FlMgxX4/RQ9qJmRCM+7El/tioT3xm2g=; b=BjrxHEkL6sxl1L7Ws0Nf5J6AmeueB9mVLuMEaR9npIqrL5/0XGhlgKAJbLRkmWxc8ynSJ0 2di58r62LVLCwmYfBHpy3KbAJ6C9AOk5z/E5bntJOxCGiRxiVBgjhxCvXU6mFGjem4TTDm CfDe/qwekWOik244/nKSEoKeFZLwvh7iE8QUU6H48StsjeTBLerpbBU2TCUzMfXkQwm8Tw CTFzGcKFTWZKfmpK6mmm8MD+nJ1MIcbNlq2BaBBdgpaGeIoc+SG1FL/rycQv98AH9b4SE/ h2vGwKpj+PYJNMi8xGizJVJrgtXTOygrrAf3q3Pi05nUQL+pqxzwOLTiax0LUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785744593; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nc8F0io+B/d5FlMgxX4/RQ9qJmRCM+7El/tioT3xm2g=; b=20RMkAyCJ0fqFFhy7dCDWclcDjJP7MKOvXUIo+6raFj3DQ0jGGvy0FMTmXM2Sp2y8LKHBA onjlrVvIRATsVHBg== From: "tip-bot2 for Naveen Kumar Chaudhary" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/lockdep: Fix NULL pointer dereference in __lock_set_class() Cc: Naveen Kumar Chaudhary , "Peter Zijlstra (Intel)" , Waiman Long , Dmitry Ilvokhin , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178574459165.1210945.497337409025757463.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: 7577e00b9ab506202b9f1a33de3cc8cc6413a4db Gitweb: https://git.kernel.org/tip/7577e00b9ab506202b9f1a33de3cc8cc6= 413a4db Author: Naveen Kumar Chaudhary AuthorDate: Thu, 11 Jun 2026 23:08:17 +05:30 Committer: Peter Zijlstra CommitterDate: Fri, 31 Jul 2026 10:32:24 +02:00 locking/lockdep: Fix NULL pointer dereference in __lock_set_class() register_lock_class() can return NULL when the lock class pool is exhausted, graph_lock() fails, or key validation fails. However, __lock_set_class() uses the return value directly in pointer arithmetic without a NULL check: class =3D register_lock_class(lock, subclass, 0); hlock->class_idx =3D class - lock_classes; If class is NULL, this computes a wild offset that corrupts hlock->class_idx. The subsequent reacquire_held_locks() call will invoke hlock_class() with this corrupted index, leading to a NULL or out-of-bounds pointer dereference. Add the missing NULL check, consistent with how __lock_acquire() already handles this case at the same call site. Fixes: 64aa348edc61 ("lockdep: lock_set_subclass - reset a held lock's subc= lass") Signed-off-by: Naveen Kumar Chaudhary Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Waiman Long Reviewed-by: Dmitry Ilvokhin Link: https://patch.msgid.link/h2kfw43n4527x6mgi2lwpz2rieqnfzgictpv4wr5nyfj= kc47co@2r5vz4uz44db --- kernel/locking/lockdep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index ff4bbf1..25d77d4 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -5453,6 +5453,8 @@ __lock_set_class(struct lockdep_map *lock, const char= *name, lock->wait_type_outer, lock->lock_type); class =3D register_lock_class(lock, subclass, 0); + if (!class) + return 0; hlock->class_idx =3D class - lock_classes; =20 curr->lockdep_depth =3D i;