From patchwork Wed Sep 25 09:53:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 174346 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp400427ill; Wed, 25 Sep 2019 02:53:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqypIFDrR3iOEqgD/59c4C5i8A4qELJyr6OPUfpA6q5pzSgFlGERAcaTgsXu1YDBeQFwPaIw X-Received: by 2002:a5d:430e:: with SMTP id h14mr8210526wrq.18.1569405221351; Wed, 25 Sep 2019 02:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569405221; cv=none; d=google.com; s=arc-20160816; b=HhVOQPsAtBdFGiImBBnnztyZi4pB2yFRCCDekzYw1fDX8U6kpeaFUj2cxU1hzpHkMD VCu8YesktHUBSNswab1AW5NHFAmrcd5rHhYUPE2zBUx/pqS6tzh4PNFqUGFhch8QSqI/ W18GGR5/2ZnYFCbhxyISOl2CECNHyecpeEgDJxwFOE2T2xMhkEQXqJb9FKvemk5A1YrT 4Hddyp4rrdjeCC4rXhh4phHk6kU/x7byx+sjOEuCji1n199ctXGAUUKL+1PPpEAKXkxV jpc3wS/5mq2d301O1l/Ev/+3Dwm9ydAvJmeKA62ACiz3EkF3Kdw3OolBWpFAyvfC85qJ DuWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=D6PfaOSiK5wWk46TCo3+Vx3pnanuAKuyWAXUeX0igJw=; b=po9JuZdUW72IQx+LEN5yMGPOiuOuZegZtPSSy2104N4URVcb8ySPLoM5pDKKe0Otzv bqRNQ73w0sfacCxX+K9UORk9ShdA1W+HnwUgIwY0u4ku2ao28FX/ORz9gh9rprj6v/Gi 6z0o95lvNkhWv7ReaM6/HpvbvFUiHYkbt/56EZXakPAS5WT4TdNPyHPfVeAyofY7fNUy g2gyFNign6PDZpF0lygPtznPeZCcXWWFVAMRNjqN0rKLVGg9d+aMPywMDjf/JtcnMq/U A2Rgd074+9hc0vVojCLP+UXSWzFLbZ7D4GRClMW3U/WOADFwm6MX+KR8okMMMuQPkoef s9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lBYt+7KM; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si3284239eda.111.2019.09.25.02.53.41; Wed, 25 Sep 2019 02:53:41 -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=@linaro.org header.s=google header.b=lBYt+7KM; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732153AbfIYJxk (ORCPT + 26 others); Wed, 25 Sep 2019 05:53:40 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42151 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727579AbfIYJxj (ORCPT ); Wed, 25 Sep 2019 05:53:39 -0400 Received: by mail-pf1-f195.google.com with SMTP id q12so3068187pff.9 for ; Wed, 25 Sep 2019 02:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D6PfaOSiK5wWk46TCo3+Vx3pnanuAKuyWAXUeX0igJw=; b=lBYt+7KM1phKd/Mg67rR70qFXk2fx7VgIHTfyDK91GSNr5+6CQr8bQQ8hg1pR0ghSQ diNdvPjQuTEZKaYUFJDoVmaAHayHS5MvLuFY41wN5GYGxJ9Pv+vWBnifx+bbo+H+tybk Wkr1cUhcOEX9ry9+GkXxBMN43P2uS599c3QQY9kXnOtsolhtsp4K/lpktiWOUy29grOv scjYue4zUnGohWsIl5saJX7Qe0dNfkgKFqbtnkgdJSxph/T0pG9kIlYfvFqLkVouEkWi ysHoDOujZOGOpOE3V1A8LL4rAqDj8GG+pb90xKe+Ms9qcDWM2AJGzxAArEKGb89rkdUD VCyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D6PfaOSiK5wWk46TCo3+Vx3pnanuAKuyWAXUeX0igJw=; b=YpYbJkzf+hXVv/V+UjpKGlyasxYlUrw7d5ZxweoeXQoalDa47NGi6saM90kFhnJD/o 9/r6McEAsns1/L1JCiRy6q3470qx4ckdjbr9va0y4JymOpLFpie8AwPwcdwoaU6J+He0 8+bSXEacnhXyCnvaRPuI+2Q9ec2nGr8QVn4kBdakJe3EEeUyzTmklWNMJ4fcxhG1iiH9 K++sErownlmC5g0grK61tpEUt+inRz9Gie1V9UDwcOfhMyrjqLYQVz4zGrD6hT2nmLgK blyk4ADR0eR6QZOvZXR+oeVe/XmZyK/FbAPR2RRwAVYkx838dJyC78ko0d0LPa/ib4nT iuDw== X-Gm-Message-State: APjAAAU+9wDQgBadPVfrSw8qIk/LbHiGsz/KIBN3kiXcLP+Nc+ulWJCK 4AWdZGV9z1pQSl6lRCj+DWjxRw== X-Received: by 2002:aa7:8bcc:: with SMTP id s12mr8722557pfd.93.1569405219091; Wed, 25 Sep 2019 02:53:39 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 197sm5054282pge.39.2019.09.25.02.53.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Sep 2019 02:53:38 -0700 (PDT) From: Baolin Wang To: stable@vger.kernel.org, peterz@infradead.org, mingo@redhat.com Cc: longman@redhat.com, arnd@arndb.de, baolin.wang@linaro.org, orsonzhai@gmail.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.19.y 1/3] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Wed, 25 Sep 2019 17:53:12 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Waiman Long [Upstream commit 513e1073d52e55b8024b4f238a48de7587c64ccf] 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(). 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: Baolin Wang --- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.7.9.5 diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index e810e8c..1e272f6 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3605,6 +3605,9 @@ static int __lock_downgrade(struct lockdep_map *lock, unsigned long ip) 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,