Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1895981pxb; Mon, 13 Sep 2021 07:43:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMj5SgY7iXJo3ycIU4tg88d47XX8X9FjTuc8LX8NMMfDBRIoQBE5fNAjJ8ywueUY4fj0o/ X-Received: by 2002:a17:907:7785:: with SMTP id ky5mr13121809ejc.247.1631544195827; Mon, 13 Sep 2021 07:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631544195; cv=none; d=google.com; s=arc-20160816; b=Zs9kXKn829cLA0jNIMs2baSGCVX4dOkco1h9iDcbO6Cn45Env9dms/vWNEq/7c8L36 pZWgUFAugN8Uxws4nEuvyqf5/l/YMmNhLm35iTUCkgzntoRa1tdLTH1Wy9CULcUtlOaZ Ew6gmu6Ez43ABy3naluQmz7PeKM3TWaAIr/sy3tAQlrPpyPS6yPh7UBS22/HuRBnNXtr ZlSvtCln5EuknzxhQQubg2EUBQgNGjWTEuP50qW1G/zhEjJVAkIuWsMtnHkhchlESIl1 dd92EensUL32q52r6rSfQTfIFJFGI1v6vwB40wgNhkxR3D7rSWXFy6d/Is6+ku6dGGTp wbfQ== 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=r3MpX0ER1/JHLL3ZxBgesYbKJaVo5u557zXdetVIQDk=; b=CNzRXXAzFui8efxfpPiUwyBk4aBwxUtxHyqt/3x7mRZvBsrnSzOYC/bybJmeJvVxom okYl4BNK4Hp+hcodtO054DbYULCPyTMBAd+yg9Nz//mV1CRjXFvFx6YqyYrS47clOtd7 5XYlzDQqfEZGC5UK+xS5FMxDZl/tLIAKgMagOGaaM3RfsBeNPo5weE9f5qrad9bWjgRO p/vEEUhv0JAiMEiCnP4F/ko3mhdzc3MVORKJJ/KU7aoz3HIfSpNPKNGETMv62wl2eavB GI+9A7eBuGc3Rp/Gvvfj9Ph1akOrnfc9ZtAtTCgbumHNM4k4VUiG9jW1rIwGFtM6Zs7P IyAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HokepvDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si7217880edn.26.2021.09.13.07.42.50; Mon, 13 Sep 2021 07:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HokepvDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1344347AbhIMOlv (ORCPT + 99 others); Mon, 13 Sep 2021 10:41:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:55708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345423AbhIMOgK (ORCPT ); Mon, 13 Sep 2021 10:36:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 929BE61BE3; Mon, 13 Sep 2021 13:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541235; bh=6Qk9BssbyK0UYvw8za6Swqpm4GUFOO+l2eyAMHBkIfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HokepvDi4zYOS0WbrrZEX11Q/BAFV65wRIu26uYYhBpw75EMrtJ7q9ZxQD5ES75m+ /A3frhGCKPiK4nXlBEK1u2/4i0i9a0el1Ockj4Y3GUxyLqUSltmE76qnAS/hZBB49S YEVmqWhTk4PSk2ggpzHaiMB13JyWx8WXTVdU8xqc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , "Peter Zijlstra (Intel)" , Ingo Molnar , Sasha Levin Subject: [PATCH 5.14 218/334] locking/local_lock: Add missing owner initialization Date: Mon, 13 Sep 2021 15:14:32 +0200 Message-Id: <20210913131120.789460851@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit d8bbd97ad0b99a9394f2cd8410b884c48e218cf0 ] If CONFIG_DEBUG_LOCK_ALLOC=y is enabled then local_lock_t has an 'owner' member which is checked for consistency, but nothing initialized it to zero explicitly. The static initializer does so implicit, and the run time allocated per CPU storage is usually zero initialized as well, but relying on that is not really good practice. Fixes: 91710728d172 ("locking: Introduce local_lock()") Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20210815211301.969975279@linutronix.de Signed-off-by: Sasha Levin --- include/linux/local_lock_internal.h | 42 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h index ded90b097e6e..3f02b818625e 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -14,29 +14,14 @@ typedef struct { } local_lock_t; #ifdef CONFIG_DEBUG_LOCK_ALLOC -# define LL_DEP_MAP_INIT(lockname) \ +# define LOCAL_LOCK_DEBUG_INIT(lockname) \ .dep_map = { \ .name = #lockname, \ .wait_type_inner = LD_WAIT_CONFIG, \ - .lock_type = LD_LOCK_PERCPU, \ - } -#else -# define LL_DEP_MAP_INIT(lockname) -#endif - -#define INIT_LOCAL_LOCK(lockname) { LL_DEP_MAP_INIT(lockname) } - -#define __local_lock_init(lock) \ -do { \ - static struct lock_class_key __key; \ - \ - debug_check_no_locks_freed((void *)lock, sizeof(*lock));\ - lockdep_init_map_type(&(lock)->dep_map, #lock, &__key, 0, \ - LD_WAIT_CONFIG, LD_WAIT_INV, \ - LD_LOCK_PERCPU); \ -} while (0) + .lock_type = LD_LOCK_PERCPU, \ + }, \ + .owner = NULL, -#ifdef CONFIG_DEBUG_LOCK_ALLOC static inline void local_lock_acquire(local_lock_t *l) { lock_map_acquire(&l->dep_map); @@ -51,11 +36,30 @@ static inline void local_lock_release(local_lock_t *l) lock_map_release(&l->dep_map); } +static inline void local_lock_debug_init(local_lock_t *l) +{ + l->owner = NULL; +} #else /* CONFIG_DEBUG_LOCK_ALLOC */ +# define LOCAL_LOCK_DEBUG_INIT(lockname) static inline void local_lock_acquire(local_lock_t *l) { } static inline void local_lock_release(local_lock_t *l) { } +static inline void local_lock_debug_init(local_lock_t *l) { } #endif /* !CONFIG_DEBUG_LOCK_ALLOC */ +#define INIT_LOCAL_LOCK(lockname) { LOCAL_LOCK_DEBUG_INIT(lockname) } + +#define __local_lock_init(lock) \ +do { \ + static struct lock_class_key __key; \ + \ + debug_check_no_locks_freed((void *)lock, sizeof(*lock));\ + lockdep_init_map_type(&(lock)->dep_map, #lock, &__key, \ + 0, LD_WAIT_CONFIG, LD_WAIT_INV, \ + LD_LOCK_PERCPU); \ + local_lock_debug_init(lock); \ +} while (0) + #define __local_lock(lock) \ do { \ preempt_disable(); \ -- 2.30.2