From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7849EC32792 for ; Thu, 3 Oct 2019 16:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A108222D0 for ; Thu, 3 Oct 2019 16:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118830; bh=NN1pVruRmKwEYEzP7tC27w3B8RxR6A5WUC+VH95oF3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g4t1DMQkkdyjvR57RErYbtPTba4FuhrVhchNuH49C/9emIW7fxMt37F89BEbOXlSB AWSQVrs96W97/hQ76ai/LZg55rnujn6vVyAgPkiyRU2MPUeN6suJNHRZtWu+Phcwwc zO6rlyQIeMSI8VUHWDzph2wpwGJUVVJapvpoWbBU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732878AbfJCQHI (ORCPT ); Thu, 3 Oct 2019 12:07:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:54498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732858AbfJCQG6 (ORCPT ); Thu, 3 Oct 2019 12:06:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01DAC222BE; Thu, 3 Oct 2019 16:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118817; bh=NN1pVruRmKwEYEzP7tC27w3B8RxR6A5WUC+VH95oF3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SW5ZTXLtjO5LE2G38532uHkHNZaQwnIaFbWYoSb+iE39UGDpdLOdQV0Zu7dGBkrQN SV2z1oAzyzYFz8MtukKb19VIJ8SAU/+DRMAaMn58fgHi5MC4lf5ZozaUOawrneMsBY eg+AZwjYFDEwAw/nbWL4GlZIvTSP8Nbk+rziv4wo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot+53383ae265fb161ef488@syzkaller.appspotmail.com, Waiman Long , "Peter Zijlstra (Intel)" , Andrew Morton , Linus Torvalds , "Paul E. McKenney" , Thomas Gleixner , Will Deacon , Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 020/185] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Thu, 3 Oct 2019 17:51:38 +0200 Message-Id: <20191003154442.180689450@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154437.541662648@linuxfoundation.org> References: <20191003154437.541662648@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Signed-off-by: Greg Kroah-Hartman --- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3688,6 +3688,9 @@ static int __lock_downgrade(struct lockd 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,