Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026550rwb; Mon, 15 Aug 2022 16:24:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6N6RWxCwBEwchiZGAOCDEdoaR1swDgxb6+nh/EQ/xFNZz7H1nC475OZrRZ8yJPRjxs+u5d X-Received: by 2002:a17:903:2448:b0:171:4853:e580 with SMTP id l8-20020a170903244800b001714853e580mr19236433pls.145.1660605880232; Mon, 15 Aug 2022 16:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605880; cv=none; d=google.com; s=arc-20160816; b=uFtYdy7zdJw/aD/G0VoiBtAQTnOXiMNA3DCf/1k8vs5xKLEpZk/EaeTptsNf+MwgCB QmMNukbVxP4UU8c9blso/uOR26ok/2US/VovrEyxh/zFsCVBsrGtEk5ochZhmfd8Hao6 wzG/M4mmJtwII3Spm5HtS3jRFT0r383Q/GJ2eSXjJqwJVP8t5EZSKeBJXk/teTZkKvaX QP8dBUA5tF5pQMzc7qh0ZjylwwJAsbfIDpKlXpQAiA0aUG/wX+22dDa8bF4pKOPB7vEB FUUItHhqezeOV07BIpsG93vsRTFBvdggZEsJTofByo8j8KR70sy52FveOmcbkBz5MIlF hV7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OFTFNW05mF/Pm84tCJgn5tPcXPwBO7JPEm/lFkY/AOc=; b=N+Opctxa2sCwtO29MXp8W1T8zrJ1Tlmqgz4Z0bA+GhMYOyA+Etn032wGkpigyXo49K U/JuImsVnVRpOGhUic59u07mX5jbKGpuzZ3FWt54DFvQt87LEP8MiNq28jVCX6xwPp99 vRXpKszmyl+VUWCBy6PC5ZB92+idE34QIFjGZ6CJTh5atIUz5l7eKcwIJzEab936c3Hq t9lHnXHWOIyh2R1o1xsWH6whIN6qRtwyyh4CbK12KcxNgFjFy3Y4/yRToCq7NEqnyXR/ b5cPSSKLebO7ltqejbncoZ8zfKFjIt0xnt1eEcuhMiar0oqGODOfzPARw6WaK95a7IEh ZOsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OXztzpPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a64-20020a639043000000b0041cb4fc5adfsi11219903pge.387.2022.08.15.16.24.27; Mon, 15 Aug 2022 16:24:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OXztzpPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351682AbiHOWqM (ORCPT + 99 others); Mon, 15 Aug 2022 18:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350971AbiHOWnS (ORCPT ); Mon, 15 Aug 2022 18:43:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199571F2D8; Mon, 15 Aug 2022 12:52:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 47DA961226; Mon, 15 Aug 2022 19:52:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A425C433C1; Mon, 15 Aug 2022 19:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593147; bh=PsE69xMvmGk2e7/ex3krG6uJwOrvOxYgpOS9K1/wK1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OXztzpPQCZfOBfQP5rsghidWfWqVsewFOr51vb0+y/qooVf7Ixsfi8JpaJBNQq1Ru z5nL5PgBWA3MaP+ltGlYMof3NSBI0TIwscAz0soz3VUIlqLDt/DQ/xVrXpTjNYS5Vj ovH/hcYzLO+ZaEQ2+cSS8uiREkIoauuVZXAF00pY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.19 0221/1157] locking/lockdep: Fix lockdep_init_map_*() confusion Date: Mon, 15 Aug 2022 19:52:57 +0200 Message-Id: <20220815180448.426798069@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit eae6d58d67d9739be5f7ae2dbead1d0ef6528243 ] Commit dfd5e3f5fe27 ("locking/lockdep: Mark local_lock_t") added yet another lockdep_init_map_*() variant, but forgot to update all the existing users of the most complicated version. This could lead to a loss of lock_type and hence an incorrect report. Given the relative rarity of both local_lock and these annotations, this is unlikely to happen in practise, still, best fix things. Fixes: dfd5e3f5fe27 ("locking/lockdep: Mark local_lock_t") Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/YqyEDtoan20K0CVD@worktop.programming.kicks-ass.net Signed-off-by: Sasha Levin --- include/linux/lockdep.h | 30 +++++++++++++++++------------- kernel/locking/lockdep.c | 7 ++++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b6829b970093..1f1099dac3f0 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -188,7 +188,7 @@ static inline void lockdep_init_map_waits(struct lockdep_map *lock, const char *name, struct lock_class_key *key, int subclass, u8 inner, u8 outer) { - lockdep_init_map_type(lock, name, key, subclass, inner, LD_WAIT_INV, LD_LOCK_NORMAL); + lockdep_init_map_type(lock, name, key, subclass, inner, outer, LD_LOCK_NORMAL); } static inline void @@ -211,24 +211,28 @@ static inline void lockdep_init_map(struct lockdep_map *lock, const char *name, * or they are too narrow (they suffer from a false class-split): */ #define lockdep_set_class(lock, key) \ - lockdep_init_map_waits(&(lock)->dep_map, #key, key, 0, \ - (lock)->dep_map.wait_type_inner, \ - (lock)->dep_map.wait_type_outer) + lockdep_init_map_type(&(lock)->dep_map, #key, key, 0, \ + (lock)->dep_map.wait_type_inner, \ + (lock)->dep_map.wait_type_outer, \ + (lock)->dep_map.lock_type) #define lockdep_set_class_and_name(lock, key, name) \ - lockdep_init_map_waits(&(lock)->dep_map, name, key, 0, \ - (lock)->dep_map.wait_type_inner, \ - (lock)->dep_map.wait_type_outer) + lockdep_init_map_type(&(lock)->dep_map, name, key, 0, \ + (lock)->dep_map.wait_type_inner, \ + (lock)->dep_map.wait_type_outer, \ + (lock)->dep_map.lock_type) #define lockdep_set_class_and_subclass(lock, key, sub) \ - lockdep_init_map_waits(&(lock)->dep_map, #key, key, sub,\ - (lock)->dep_map.wait_type_inner, \ - (lock)->dep_map.wait_type_outer) + lockdep_init_map_type(&(lock)->dep_map, #key, key, sub, \ + (lock)->dep_map.wait_type_inner, \ + (lock)->dep_map.wait_type_outer, \ + (lock)->dep_map.lock_type) #define lockdep_set_subclass(lock, sub) \ - lockdep_init_map_waits(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\ - (lock)->dep_map.wait_type_inner, \ - (lock)->dep_map.wait_type_outer) + lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\ + (lock)->dep_map.wait_type_inner, \ + (lock)->dep_map.wait_type_outer, \ + (lock)->dep_map.lock_type) #define lockdep_set_novalidate_class(lock) \ lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index f06b91ca6482..e2f179491b08 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -5238,9 +5238,10 @@ __lock_set_class(struct lockdep_map *lock, const char *name, return 0; } - lockdep_init_map_waits(lock, name, key, 0, - lock->wait_type_inner, - lock->wait_type_outer); + lockdep_init_map_type(lock, name, key, 0, + lock->wait_type_inner, + lock->wait_type_outer, + lock->lock_type); class = register_lock_class(lock, subclass, 0); hlock->class_idx = class - lock_classes; -- 2.35.1