Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp131784ybp; Thu, 3 Oct 2019 11:12:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoU70qgS8nVZW4QilhsSmP/OlVT/6DfvirhD4EiaDC4N8Mqo+VOWCiGBaVsHBTByOYtLCu X-Received: by 2002:a17:906:bcd9:: with SMTP id lw25mr1322831ejb.330.1570126372524; Thu, 03 Oct 2019 11:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570126372; cv=none; d=google.com; s=arc-20160816; b=hViWsmhz+91OIsCtucEWpkyriuK2gHWXYT5ysDdJBMo6uVynLOAq/dWtwAoB4ID+N3 qPQJhSd/w6NUE/9gvRf2W91X7Nw5u02q56ejCgXjTRMINecrZ6ZL9mlFNQQjXKP3vtQ7 1lq6Bx5FEEghz4EhUYIpxnb7oKI+MCsap8AhNjMXUAg5MNT88Q9zo1WqLwxADxaIBFSz cphv4Uqjd+eiqu1Rc3f7HqOp4yTMRFP2rlSDNM2HUol7M6CDySe7dABmItdxEo8xMewU N8Zk+bZdhbcoMN1mB1B6zWe+Rzymiue5ViapMdJ/ptOv2+My/BurlJk/llaVLEsyVeCs 7d7w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JtNwAEhlML0vbw40uEk7utwgafYYk2JrX2a0D2GuMOg=; b=mPXYQZ7sP2Y3aZAIl4IkkNg8LpeDZC8AI4eEdWcKG23ZYb2ZXGPRTY3FYkBcKD170v Goevr967xJVoPfsOq6OPqeWomXojyoMl9vQulkWCQqQ3IEU9wFPOraSAlIubWaWWnhoa +72yN09zNplag7lw8MkhU43XAOVTVqqbenmeATR0jhS8Z0jqP96xpit/jx7s3oVmf5Mu Ft53YI7nDO8HmvsNCud1CsZcRJm1nJIyxleo6cMBzq4YG5q28y0WCGDBtaXH+LUgXCj9 4LNjZ7L27ZH2YU5jgESy2HMkSuBCz9emNSZGVJDyfj7SNkQajoUd4xwNcgo3x5xZpNEf m54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SW5ZTXLt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n26si1663488eja.273.2019.10.03.11.12.28; Thu, 03 Oct 2019 11:12: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=SW5ZTXLt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731839AbfJCQHG (ORCPT + 99 others); Thu, 3 Oct 2019 12:07:06 -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,