Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2882537rwb; Mon, 15 Aug 2022 13:14:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ePydCm0D7+CTAph+MqgPROWLuU8NMak0rfI1d6NG9sgauqHBNhEguamHmrauiP/FnuDTh X-Received: by 2002:a17:907:3f95:b0:733:1e1f:d75c with SMTP id hr21-20020a1709073f9500b007331e1fd75cmr11443734ejc.727.1660594478865; Mon, 15 Aug 2022 13:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594478; cv=none; d=google.com; s=arc-20160816; b=exHx324u0sKEEm4EJk7hRP8b7VQ6dUJ4Aw/arTjluWPRtWQMALTH5Vd1nzmjuhf0Mf maLOjADmP5YNY/6BV1SCtpJM50HAXo3VS2rQCLIYamwSDa9AdEiuppgCAsCU9KlPLaVB owXD/5eZPchgUfFSazp0S6RVW5VeKhDrpX1wgD1hIm0H3W6TLsdkA5RL0Em03uyWAobS mnlCtLJDGueTw/QIFTvkOawCWY0/zssKNQr6F9dIlSB6awDLPY1en9AnJVAtVSiNJLo3 N99LdVJ4rRdyoMIlUNo5wDUJ4VxF7Lch8BXNy4v48BFMrkTU4rVHAU7Ai8dUDZuNJrhj IOYw== 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=Ms8BKr3Cvj2bbL489hw5RJzEc0sNx+TKCVwsUNgvIWk=; b=CeHqMB3DzYOs/vYum4pgAjWAjLSFk4jnOu8gOR68qMS9cx2jGOsmW+4AEqsQCVlzi9 AIR0D7TcinJF4/PrXlTOoRBRlpFqtKwdN+EAuhC/hEEc5NH1mlHuYUZYygAVJtsk/jCt +FrglymopPge9R/Gi8gABzR5f2P4cHRU+1Qr6R0E7B4cHkMy3W9vu6Os+6fIUs2UYJEa qTP8CUu5GIzAcvAAzp6p4bnXbGlH7qlsxc+bj6x+9JwELKCxmN9bOK/sbkCSBVwh7dD8 vd7W6JHCRYcGN86htsyfuiGoJG/b++6QzZ5gKTXHQ5iOxRPu0mT8sTuqViXi0YfPb7kA gs3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zooY/Nqw"; 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 f12-20020aa7d84c000000b0043cb2fabd05si7404810eds.326.2022.08.15.13.14.12; Mon, 15 Aug 2022 13:14:38 -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="zooY/Nqw"; 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 S243679AbiHOSer (ORCPT + 99 others); Mon, 15 Aug 2022 14:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243660AbiHOSeR (ORCPT ); Mon, 15 Aug 2022 14:34:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C0C639B81; Mon, 15 Aug 2022 11:22:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2111CB80F99; Mon, 15 Aug 2022 18:22:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F709C433C1; Mon, 15 Aug 2022 18:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587726; bh=8K7a4B/rMAB9jXSrY6O6bL252uaeUFiBy4iV2O9dGKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zooY/NqwTHwzRpokSGU0egnKIRlHH+il3lcyxq4Y8k+mD3b+0JQq7LXxID/HLOfV7 BmK7DULEWBqJrTjqzGj7KPem5LbzvptYVNK7HP9HFcJL6qbGTlT+s7ie1o2rRAUj2V 5xEEFXP678ypbAHo+83KvTHFYmVctq0RiIEzZfJc= 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.15 175/779] locking/lockdep: Fix lockdep_init_map_*() confusion Date: Mon, 15 Aug 2022 19:56:59 +0200 Message-Id: <20220815180344.762135625@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 9fe165beb0f9..aa0ecfc6cdb4 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 a30702b847ba..120bbdacd58b 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -5202,9 +5202,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