Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5644711img; Wed, 27 Mar 2019 12:19:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqws9bHm0bLgydpEXvpnuaReDqaHqz2lfKMnuI7meYprdTYXr63AP+givFH+HUnhQrmMvKMO X-Received: by 2002:a63:744b:: with SMTP id e11mr17937237pgn.327.1553714392732; Wed, 27 Mar 2019 12:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714392; cv=none; d=google.com; s=arc-20160816; b=JfS+awkKzXvgmO31qfiApUC6j6GlOZp3ZccyJdqjneE5q3i+nuwcPhejZeWEVw4c1d MyvGvQqpH1TIWpruDriwjs/kwNveAaCJW4CYxQVVyuYjQrgjElCpQ1LTfy6wXwgJ7lnu VBeJZyN1m+qHBclZ0T5BilENoMmRVtpgsTIlUlUPF18EJ2Jm00qVc0sQwtRLpxnas5/k TZj5m+YxnndcO3mczd2j4Jk44PDz6iUXUuRCOzHGtaJT8wtYJQQOCra+Px4GiblFi4bx qjjBPMdb421kbsM/Ymhr40v0+OhBX3vi5Ctq5b/r6A8zYAppI/86y7zoS30iM/4oFyUm 7N2A== 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=2wRRWCZMY9fhN4izqU/JfAZmpwirs7ltNck/j2Go4Cc=; b=Eh5cCi9EdNzCtFFSb0/Rs8Z1KGqN0/EahXYP9fTh0qRXiGQ42y6RB7KTEPvGV4wF+q i51o02EGZ2p9L1cjLP7EjxReZd4NFuKMIYgumDGM6OpMjWsbZT4P4NKVmqiOkJTScNwE 9OoiMuGuSvAlHLWZSRTr8qlfgFss6DLfivxaoVMXNyb/DEnWW05Zfltob1epgASFyyYG aTLnDkKQl8wOAwlW9mey7XwL7ERu6y0Z59rdA98VkG0xTk8I7NCU4/KWGFdPubae7c4O bnLPOOkIJN+iaQl14Z54prQiE1DtDuS+hpQabMeWC6MRD9Ow0Y6o4Xzlg+GNGOS2nFcK /HJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AfWHXwGX; 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 61si20823364plr.153.2019.03.27.12.19.37; Wed, 27 Mar 2019 12:19:52 -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=AfWHXwGX; 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 S2388272AbfC0SH6 (ORCPT + 99 others); Wed, 27 Mar 2019 14:07:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387771AbfC0SHx (ORCPT ); Wed, 27 Mar 2019 14:07:53 -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 3DD642070B; Wed, 27 Mar 2019 18:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710073; bh=IaPlX6IEHzPs+4YwrnS3bFC3HSK18Ih73OZktKlDt4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AfWHXwGX/MmkCUnSdRrYfuKQk43vz420aou1FoymxnNl8XIlXNDTn8MbJo9iiYg2c mZQBRcI1cLVFyXlArTWxxMjb6C7I11eeBDFcE1Z+oXXVh8Ne2TjySh0KQidU/3RHfO fElGZrSVeR8YAnzvowPimvG+hGSsEES2fAj9XdbU= 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 5.0 185/262] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Wed, 27 Mar 2019 14:00:40 -0400 Message-Id: <20190327180158.10245-185-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 95932333a48b..56bf86c76c23 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3497,6 +3497,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