Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1860600rwb; Fri, 19 Aug 2022 10:35:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IcTm2LE+Nrh/1wOXvD18Gs6xRqxN9GwyGgOTedMxA36M438sg5zu7QcxtlOXZdns0ln68 X-Received: by 2002:a63:d448:0:b0:41d:d4e9:b4aa with SMTP id i8-20020a63d448000000b0041dd4e9b4aamr6880203pgj.123.1660930524796; Fri, 19 Aug 2022 10:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930524; cv=none; d=google.com; s=arc-20160816; b=WFueivc8szngNtcmv5HqnkP6iKNZWkSHeHMZBXkLSf7Dm3qyFg8ZJgZbP8G4dTGQUy eDoKuFPekh17xklsQJRi7rNXLPWcoJOiD7FXO1T9J5GMeeN14l3K0IXM1ZyEWmP8ra9i CIH0wq+IYDHyiEf05mgCz2v37WsadUr1X2vmAFQkWTkpr9SMiT2UY8SfejNk3N1Wl07t bvan5ywzC7HsOACKaoc/lve45VL9QcNkdNb7XkOHDS3+UkYpgHqVV6KSLm6C/8P9576p kWgrbnK92KVuvkKDONzKXVtV1TCOJdhkXXw+KPlEdTG9DWwxoU2WAzQiyThotIUbuC3M 6FpA== 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=xrR3t+AEs8RUPQqumCzqFOBJXdpcjzd+54fAnBAoRW8=; b=IKSPxcLSUMtwpEFcj5jpXzA5IVYjfXdrhZlZyKzmLEq6v+qDIgW3oGzHR21i8gKZjA HGQoptyyqCYLhBxBq4uHLAyJe6iZObUJgAZ5gr4fCznW3M6I52CFy5rFXP/5VifYAnuH RjMvQQ4waBtH9CpWCQoGHW9mENXNScMGnoTH2Po32K3ts5JWackfv2DcnwQIihfRS8Vh dEcQnH+iPvaxEWRCjfMa1jfcxFKdtVPgtfLRoiIe4pzI9FD6Tq7lx48Cp+HT6XUAmfad 4fQjlaSzmWSo/BEGPV+/XzHWNduT6ggcWm07/FpOctvmJS0GbriYdGmINxhpRsU3IDdW R+yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gU1NUn0B; 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 br3-20020a056a00440300b00528cc4fc308si4307539pfb.268.2022.08.19.10.35.13; Fri, 19 Aug 2022 10:35:24 -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=gU1NUn0B; 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 S1351212AbiHSQED (ORCPT + 99 others); Fri, 19 Aug 2022 12:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351314AbiHSQBR (ORCPT ); Fri, 19 Aug 2022 12:01:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E694DA5; Fri, 19 Aug 2022 08:53:12 -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 sin.source.kernel.org (Postfix) with ESMTPS id 02577CE26BF; Fri, 19 Aug 2022 15:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFFB5C433C1; Fri, 19 Aug 2022 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924385; bh=opWy0O5OTamT+0c/R43KXN60EgWbjqlI6jS+eL26dls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gU1NUn0ByPo+F2VDMaxbmtapqWUhjHg0EIRCyDQRaLur9UDSjeMfApz9A1GYf5DE7 pUWqUh374ntWzSCdehqF1A2I2soDYxKwxLttmFdOKbScY/ufgujm6M0mMadzwCcsj8 g0ztWjlU4N76C4xDCCdN36uj/AC0i1LcxeJMJ+Nc= 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.10 123/545] locking/lockdep: Fix lockdep_init_map_*() confusion Date: Fri, 19 Aug 2022 17:38:13 +0200 Message-Id: <20220819153834.803911319@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 20b6797babe2..2c2586312b44 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -192,7 +192,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 @@ -215,24 +215,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 c3387cdc075a..6cbd2b444476 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -5139,9 +5139,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