From patchwork Thu Sep 5 03:07:14 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: 173108 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp154027ilq; Wed, 4 Sep 2019 20:07:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA1EVV8205gCUwRXbFV112K+YaEegD2AuKYaIOCG2BLCMUphlfBvnRT0Kq/dK/dDD4W2oY X-Received: by 2002:a63:3046:: with SMTP id w67mr1160065pgw.37.1567652866728; Wed, 04 Sep 2019 20:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567652866; cv=none; d=google.com; s=arc-20160816; b=mGCBm2vvzlFK3kYXFVjr2EbyZp1sx0FlfR+Ns0XP3PeuQIVF+2gNKeIbb5AT6+qLyY I9s8e0c4DyKpD6W/Wa5hoSyK7jeTcMEWn2CMegwjkKbuKLOvrVzVaCZXOxFanLm1xifA /a9tsYcaGmofor8qy5SJnWNMjZjwwLb5eoLK1WsKEgQqF1FtH3YASiI0Lj4mDHo26V+W 7+OcQmWOqAaCJGmCUmZQRtnFBUMZ4UmlS8MpZyRPgtx8u32KACsihHIWY7sOPCMuF/YL 7SLieoJEkR3QmXmxeFjSWtQslHHSPBixcnH8gmcGfL7MPaW43oxRg+c+twbKiZHqeQk2 fYJA== 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=bv8aLyZNsRQTuIGo9WBDbNKWSEWFm7lp2gBa2Tmb/+Y=; b=ktTUYUjaBE82fzeMVj5bbrp1uheMw2Zy/072VA7eRdIx2xHF2F0B5IA7Mj6+k88TLR v54UHWS4TDeujygse2VUEVynuPD9oCWVf/HaYPEMo2qrFO8LQUNJ/LW5eobGd0rmZuh/ aMDsS2Ju6tbcfTtNXK381aaieLqmRma34gmkD6zM9dFt/XUlLTDilu8mAl9rY/jtLiu5 fEOUdzm+WaudVzUYG5oHgjtlinKgYc2aLozHcKw8SOVByBi+jYJEHRfl15OSbbpgh0oY UAiaKu9Q7VSvk/HaCb9xq8zlWjTfUpEjlMNl8Y3nq1uinfi6LXSL61ICzgQwuB+OD/Fn AGmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dJ/kcZiL"; 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 q206si511254pgq.483.2019.09.04.20.07.46; Wed, 04 Sep 2019 20:07:46 -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="dJ/kcZiL"; 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 S1731068AbfIEDHp (ORCPT + 28 others); Wed, 4 Sep 2019 23:07:45 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33803 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbfIEDHp (ORCPT ); Wed, 4 Sep 2019 23:07:45 -0400 Received: by mail-pg1-f194.google.com with SMTP id n9so569261pgc.1 for ; Wed, 04 Sep 2019 20:07:44 -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=bv8aLyZNsRQTuIGo9WBDbNKWSEWFm7lp2gBa2Tmb/+Y=; b=dJ/kcZiLoIWOyyw6EfFPZeTXLsTZNg9iDTuBuXEqB+kjja/lH3LAkPeOLFJAsOWKCc C/z6F3GUxZ/IB7EDbx9Q1NptWBRZprPFMK5DtN2adq5zQx7CI500p6v2GhBCDewaN/05 GM3lH33ZsVbgMrZZVG7Bp2m/1UrW4z8G9ztPyacNo9gFE1b5xSmhBxudlHqFKmPtOldy IoCm5mHDORE/jjJKkueXfSaUX72IOBNrHiwt63UBkSpiASgBZkMzI2rpreM5GrrxVkGa flKKFL1ofwgPuI9Ap/pt1WBEWqVlX4gFTOGVEeJUxSVIbk9YhecfTtoYN4CrlRp3uy9X h9ZQ== 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=bv8aLyZNsRQTuIGo9WBDbNKWSEWFm7lp2gBa2Tmb/+Y=; b=Tf7wKhbArVJibdXgcPEP6rJlsWfA7FQ/9Gnn0nGNiNQp6iEo5UiUhgBkL14nxcWX6I 2oO4WVQV3kcuW8QdyeWrZjN0npx1ksY4V+23rRXQlRCTjxaq1OkwmnIeLfPy4wejSvfs oMMn1jC6C7FUX7y7Tr4OPVTDniI1Wv1lBCebeaUzRwrwmz43wQfYxG6UnALfUJunSiuy vWo9DaPu9fVJhvgTFyBuVLz08yLE3Gv0igjPRbtHPjg1DNzjhMy7nlGZ8GSequUHvBtZ NCqbplKlcAotUVPEgY83tv9qTM2JeNp6KNOfHDf9okPCurB60l4q6+Lo6QdeVfSyzwjv ICcA== X-Gm-Message-State: APjAAAWcb60pQMEiItQYsg8x99EBq+MF/ZguDVA+KlWtiZ4L3cvTIU4h KRHJFBmD3vxpsKeU2odbBd8gMw== X-Received: by 2002:aa7:8d12:: with SMTP id j18mr1128275pfe.33.1567652864452; Wed, 04 Sep 2019 20:07:44 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x9sm425686pgp.75.2019.09.04.20.07.41 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Sep 2019 20:07:43 -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.14.y v2 2/6] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Thu, 5 Sep 2019 11:07:14 +0800 Message-Id: <7d3d221015cd343df47de4a68ed4776aca2ca0ab.1567649729.git.baolin.wang@linaro.org> 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 565005a..5c370c6 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3650,6 +3650,9 @@ static int reacquire_held_locks(struct task_struct *curr, unsigned int depth, 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,