From patchwork Wed Sep 25 10:01:36 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: 174350 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp408696ill; Wed, 25 Sep 2019 03:01:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIbFZD2bEuk4DDUlhJ6yZsh2amg7sM7JWWcHQQIBrq07rTM7aAd8t1gXAjtzWqYn7RcDI9 X-Received: by 2002:a2e:a41b:: with SMTP id p27mr5541479ljn.104.1569405717961; Wed, 25 Sep 2019 03:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569405717; cv=none; d=google.com; s=arc-20160816; b=oHusJ1SFd3jFHp2o/aKykjsoHtqJ1sXZocOJzP+eTm+1F9WhbRnDQ/YC/w3orcxK8Z wEgFNhUTz/o9F9IT7zSjC/901ttdHQ5KQ/nf28jaAAvM4Awm+EhGx2MavzoDVHJaSemH qiDluwHIX+SS5RtHVQlA+JQAo541OADdjvFuJOtqa/If7nTOtSFa4OQRn5trai5k4wG3 Plh0eG/KpnUUN/hljQ4nsEDDduNpnrg8Y/HfZ3Ec+yIX9GObKN5HbxAfwfof+wWaFnN+ 9w+WR84eM7IruXM7x0B4xTvaLCr5mcypadTU9fcm7SW6iEVpKb4UbgR0+4GwBBLnH3k4 pY2Q== 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=d9IHL3SsavX7o+Vm3pWE3DTrc8pCqnO3SJv0zYC1U9f09b9YKb72uFdTPPKsjfQuts 2hd3siXSJ6sGjImu5LqI29lNhYI6vuHUtSg8IhezIe6GgB0Ga8LVQ3K2KEP6xIfv7Oei oJVjHeLtvHxVGizM6IKzH7Nz4T6Y06Ka5R25wLm01+VlrTTuMMg1g3khSBcNSyQAhMsK i5Kg4R3zVXWnQsmdMzJicRGyWOkZygVoySTXW1UGdT5aOPbcSpkS9YM7atqYYmcaZ7GE p+4JQK1/yqrqxXEiqf09tusS78bdtkFiABMx+bkNKz5c2aHOT5IkOIttdV4dj8ckXwLg XkUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fgZbG64I; 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 va7si2477221ejb.4.2019.09.25.03.01.57; Wed, 25 Sep 2019 03:01:57 -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=fgZbG64I; 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 S2387663AbfIYKB5 (ORCPT + 26 others); Wed, 25 Sep 2019 06:01:57 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35419 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732976AbfIYKB4 (ORCPT ); Wed, 25 Sep 2019 06:01:56 -0400 Received: by mail-pg1-f196.google.com with SMTP id a24so2935444pgj.2 for ; Wed, 25 Sep 2019 03:01:55 -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=fgZbG64IXUHsvM7TRcuP1teXZYFqfqW0l7SKxCbGRJ2bNJ7G8EpFcfSrax7r7CdozP BXABVYGo2CR6D7Kkw4DVVdg474IKzw+R/pjsSnecWmnrGWxcJIMEYZ/++gMw9Idhwayu KCu7xK+zUn8yzhG++1aJwt2wXHOFVUz8LaagufwcDMk+08VxWMdzBibttTcqMYfRFoK+ rS/LwlpKsMDnOodWs+bKhJf6aKTdIapjDcd/xKx8DoXFGOZncOcYpM8kybdG8Qve6P41 j1jqedeNLtUzS/caYff3jb/HZHZj/vdy4Z9vKf31CSU1jaih7Ergo6ZtzgZlJ0Ima141 GGTA== 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=mGiqKuHcyY9KkrAfHC9Aw5kxq3QWsgngjbC4yAQ15ggMEn+Xwr7pchRbQ8HIIVI2+I hZmx9vxtxNsWtGvvxGbIH81xiLfzSeLdsdbpial2hzvatyYspBVFBWanF/F0QHtpsLbK 64zQLWDYULhqjYNaePygCzj1C9atXvS19HQQhxYbFAUjuudObkoGGeIsiDUtMcdQkvqA tA9UI5ERBWEs3e3uiu6AkFrWH7n/2dM2gkiuT/zgSdZYzLQw8na0tAwbbff0AJRtnVqd sfTdvmbwu31kolR5kVoC2VtbhT9KaSj3azWCguQgK2VOIDwWsdFhspdmBEbYiird/KLy cRyw== X-Gm-Message-State: APjAAAXa99gmz4zqk8cCaPi37DODFiJheYV7KYMB7BOHHUc01NM7em5E ULDEvYNrMqGAiUTTJshXW1R3xQ== X-Received: by 2002:a62:7710:: with SMTP id s16mr8743537pfc.139.1569405715384; Wed, 25 Sep 2019 03:01:55 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id l6sm3847418pje.28.2019.09.25.03.01.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Sep 2019 03:01:54 -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 v3 1/3] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Wed, 25 Sep 2019 18:01:36 +0800 Message-Id: <4ac2e84637ceaf5ec67cfc11ad58c489778693a8.1569405445.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,