From patchwork Tue Sep 3 06:57:21 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: 172779 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5275412ily; Mon, 2 Sep 2019 23:57:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5wFtPDy3EzjBZsRGYlyc62VMWoX8HZEgnnLrN/vIkw9f/h9Wb+Pq26yJnI7J/IU1lpsCg X-Received: by 2002:a63:e901:: with SMTP id i1mr28201014pgh.451.1567493875481; Mon, 02 Sep 2019 23:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567493875; cv=none; d=google.com; s=arc-20160816; b=PShsUGiiKbCgNIOq+6puYn6go4hUpVz7YNj2jsFnEbXqlrMHEL3jfJNjDI42bJ2Uvv 4gYGD9P87I3lHi99kAihsHvoBuUuHTNIo0zi+j5nhDlrERaVld5s1fSPIxgMjLA2jpVg RlLeYaXW/ocB3Nu/AFQ6vO3vyxAof6cu0v/juGvnLBOwAfnMwFiKfOkZX3nMOoe1xDnn 1FD1YXMKkwaWaTPyODHeEQXjPTFXNCWd0uVO69/gt7K4b0QyOPiZwovGM5BF2SkUglpR NTKUSi1D5YVql5aGYyKbve6RoVIc1PEer71ezmipeIplrazt/pM6sIIL/eCOo+tTdJhp 2ktg== 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=AeeV14OyLBTF7KaAD5jDBEtXBCp8zTp9/udCZix5Xks=; b=EhFjsjzPkHTD4u6L5enz7ssr2bYfLr+z3mZgfDpXsuATDBoi/6y2YM1KBB7y89iyE7 jScPM6MYAEsBPZf3wpGLLLG0ptfkhC5C9E1zmuvNkvPRIi3Df2mYU0uRuhPemNGbd8UQ kklAjWih2yrKy8EExM0QiibgHVBwEhfRqLJFuBWh0ySVyqq1YuKMHU+ObYK97pRsmodI szFvf+U58B2HDrDpf4V8vVf2p+B9HtIKGvPLWD61Dp9F0nYa605yhMswOeHyKd+aVisx Ku8YKNwS//hV8juedTuD5fcdU/60zp1xG0/KB1kMCO4/oOXOL6mj9KoEEyag+xinwV7R Jw5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p9W6jfMk; 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 e11si10112032pfj.104.2019.09.02.23.57.55; Mon, 02 Sep 2019 23:57:55 -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=p9W6jfMk; 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 S1727413AbfICG5y (ORCPT + 28 others); Tue, 3 Sep 2019 02:57:54 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38464 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbfICG5y (ORCPT ); Tue, 3 Sep 2019 02:57:54 -0400 Received: by mail-pg1-f196.google.com with SMTP id d10so4028592pgo.5 for ; Mon, 02 Sep 2019 23:57:53 -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=AeeV14OyLBTF7KaAD5jDBEtXBCp8zTp9/udCZix5Xks=; b=p9W6jfMk6gjNMTcRQ3sw84ltehgzUrnBrlh77posPmyU5yfQhoe+6buCNhGW0ouOGj fLnPvg2yonl4VXRxfOkrpbcSHkZHd5RiscvSIOx0ZOJ1y1Mw2BDydU+Tq8i/qIRcBIZx +kx/N9qbHhYCGyQIec7LgW6gKOBQYvgFJt2UMX6odCHU2GQWEMxkr04++3zHyCeXc34L 7eZJiEuJTgcyNT/uahiEanGfJOlJFyMwu44Dr5DfitUxj8zsp5SQ7BWzq2z52GmNkFUl 3SedRw8KmftQPXKutX0FC5A5QVg0B13e2mT1t0uKzT/BB0taIQEJma/91cTQ5vfguCNO LMhg== 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=AeeV14OyLBTF7KaAD5jDBEtXBCp8zTp9/udCZix5Xks=; b=P3pWl2MBJw6G+tbv7b6Epuk4nv9IBd4xc0g5IGYdWATiHG4t1FTa5Ljb3WN3bvbPBH 9x2911aYufLLpHuEQOBXZFVhVRiH7CzScGo3AWhvX3rWRf1jPXGdg1nVk8fObNfdIwB6 sBld/ab7JQIZ1OSjENE7gpFofJqkFGE2WpuTNVEcSEwb+nmrNS62jmlKTQ+Q/5b3b5KN +2deTcvE53Zmc8XyzfzKYWOlR74BGugD3SnduiA8IctFaIAX6Pqwa+FZOGiBnxnZKCTT trCfzjrcOQdhtl+NcXbpjmAlc9LMEoNae7e7/YGk5dmQYvISi3BJ71mk8BAhZMIucLX5 WoqQ== X-Gm-Message-State: APjAAAXI0OYpEM4tmlT+nmWGs+knTOOEDywjyWpKuuY+vPu4L/BL4L0H N0Unhw19X3Bt6R7SnrN5s1uD6Q== X-Received: by 2002:a17:90a:b781:: with SMTP id m1mr16250972pjr.141.1567493873489; Mon, 02 Sep 2019 23:57:53 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id n66sm307197pfn.90.2019.09.02.23.57.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Sep 2019 23:57:53 -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 3/8] locking/lockdep: Add debug_locks check in __lock_downgrade() Date: Tue, 3 Sep 2019 14:57:21 +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 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,