Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5612801img; Wed, 27 Mar 2019 11:42:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxn+bgIyWvtUBwe/bSTicvcu/LbQrsWscFFbVovAIYP//gWRDM2vQOeUaGGIMKsIyWcq1TI X-Received: by 2002:a63:1912:: with SMTP id z18mr36726309pgl.115.1553712156469; Wed, 27 Mar 2019 11:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712156; cv=none; d=google.com; s=arc-20160816; b=jmZVq8IzfdxtWktaAjkI83bMWzR8m1+bZZyX//UFGsHtGPzE2/7XJw7FcFSQJpFg/+ y3I4IgAiSoNgR37ByIP/WEyBLzRZanxv1M0asmmYHNZ+zq7oiLeNxL/tg9OdTqzvibLC oFarvQdlN0sPIAB3BWxrJhQr1niXri51Q9tdpL2qvsvXK3UZw7ugKnWA5/oOTFLIyEYo eEJV/WtA39Xd0cw2F/yqTZfpwAYXSqZLdES0kQyVenzVaJ2+rBMtPYRTzilQkQGXT2vZ WnpjQcflOGF/bTNiPD3Ht4T5/f/ySVoVqWa3DluOvcmgst310ztrNfmfoydejx65j45e BGEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TrNkDdLQ/uQCVghkCVvZQdaRXwXt57GoZ6vEk2fJirk=; b=ne6ZCa9UYZmh1f92xsJDjmPS4T0RvITljDnNSobu4IRXIKYajUE12ueWlaFHRHqYbO 4KhPFTEmwQy1zEMgLw4pLVxXlKfC/9m4tgl/7sFnJ0GeCM11kZo3ExSDH3KLqCctk+eR csPRqftNNtzM/+QPZNr9jSiWjCxyYKNjTlWa8XbC9161XGlQdK8MpCFBvIA69eyypcKb 4a9HcQ/qyrApXazS+aAOe9knzoSs/XJrVp6ph1q66iWUxFBdbTUauqcYEp0JP5fYB+sa T+C6KnvZS11NBBAUMmAZR7LPWwM0/GJu2U//Xszd539GW//ZKY2J/15gBKsvKAYaj/qh c7fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOIra25D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si16513522pls.53.2019.03.27.11.42.21; Wed, 27 Mar 2019 11:42:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOIra25D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391321AbfC0SWi (ORCPT + 99 others); Wed, 27 Mar 2019 14:22:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:40664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389853AbfC0SWb (ORCPT ); Wed, 27 Mar 2019 14:22:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 041CB2063F; Wed, 27 Mar 2019 18:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710950; bh=YsxROj5dKKBXrXS2/P9qZM7/IDRD+qK2hBIIV6KS1c4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOIra25DCKh1K0Zq1SY5LOPhuzrce3X0btfftTi7wz+CeFP0434eO4dSmex8uzoRU sFsKq8xl4unEjMCvpyUNeyKHbcobDTljJR5YJehq0YKoj3BS8Dep4ThBgIrOSRXhC5 gr/jYKuMXVOfKW8ABruJSc2yb9vyjagpMXfWIDkU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Waiman Long , Peter Zijlstra , Andrew Morton , Linus Torvalds , "Paul E . McKenney" , Thomas Gleixner , Will Deacon , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 4.9 61/87] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Wed, 27 Mar 2019 14:20:14 -0400 Message-Id: <20190327182040.17444-61-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Waiman Long [ Upstream commit 71492580571467fb7177aade19c18ce7486267f5 ] Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning. Fix that by add a check for debug_locks at the beginning of __lock_downgrade(). Debugged-by: Tetsuo Handa Reported-by: Tetsuo Handa Reported-by: syzbot+53383ae265fb161ef488@syzkaller.appspotmail.com Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Link: https://lkml.kernel.org/r/1547093005-26085-1-git-send-email-longman@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 26fc428476b9..d5b779d7e79f 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3446,6 +3446,9 @@ __lock_set_class(struct lockdep_map *lock, const char *name, unsigned int depth; int i; + if (unlikely(!debug_locks)) + return 0; + depth = curr->lockdep_depth; /* * This function is about (re)setting the class of a held lock, -- 2.19.1