Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1846146pxb; Mon, 13 Sep 2021 06:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp7nVq7iy7Nr0rWjJhb30rkOuYqm5TJ00To9w4lTW7sFeUxhNzVNNDDfGrIJWklaws5Uz3 X-Received: by 2002:a05:6e02:cc5:: with SMTP id c5mr6960484ilj.110.1631540979192; Mon, 13 Sep 2021 06:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540979; cv=none; d=google.com; s=arc-20160816; b=xD86l2pnp9FwB7azrzURAhY/p3ln3AZ1RZnzIPRGwsgen7Q36Ivu5/WCDD5xQDQ5cR ok2sxsboJDWoldgMkQJZ1uaeIOlhfbN6F1TFPPmhlqQ+kFZzJKkiigXc6cmhfUT5tWT8 rLyj9eqAPFUvSsoh2vGjaBH8nWDla78DlNy3ySnZzvEfn09mSo856n/rB58/nnIfBSLv e/jyyTY/FS9RbG0hNbg5wBbj2OukjazQ0+5tG2zRO7P3djxiMschNMgOcYvOLDnBpy6T iP0VW8MFDK+NMqwfMAHFxdiofv25FoLLtizulL8D+X0iKky8eGA4BR+CBK3R1Ro65mX/ rrVw== 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=QLU03VLkNEHMzuaKTZxdBqdT6xPFV28ctBqujk+3dTNCfnvu1H6qzXkDWmFO3/Pxtp n5FOH0+BNtV6nxSZS/PWmmiEz9yYEjRn/Ykv+4WBFirjn8yO0sROxAX9NsZLUyV8shtQ CvR6g8jkscRfef4vWN4OXdruqUQys++guXTZj1S1tCKl0FdmLj+TWvs5gUN5DFWHNvwX hqlOJsGSAATsgKv/TbOqnNsXhvmaEUT5UW+g2ih9tjv0v7bbJ0YR5hjV8CelTgJwORQH XLZuuU+oFUq/B8iIX1DDX4pR/flW903wQS4oKITrHSwjrf+AAFUQNerBqbh5xmazquSf jfNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OIac7O+q; 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 t5si6264328jac.62.2021.09.13.06.49.27; Mon, 13 Sep 2021 06:49:39 -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=OIac7O+q; 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 S244037AbhIMNrb (ORCPT + 99 others); Mon, 13 Sep 2021 09:47:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:46600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243169AbhIMNmD (ORCPT ); Mon, 13 Sep 2021 09:42:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A3B16135A; Mon, 13 Sep 2021 13:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539799; bh=6Qk9BssbyK0UYvw8za6Swqpm4GUFOO+l2eyAMHBkIfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIac7O+qs6/nITKjDH0WMk5d2Sj2x31vO3ONTpzniArnDJz26dYB6hgnnqSdQeOC1 +PkeO4NYcPb99mRLMsPGsmF5d1qs2q2HlnvRkc/t5em7j3kvxY3omsc+7gCNwJXa3k aPDih9H8m05x/bzF/tjvhWn6WFdTtz353t+O0z/U= 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.10 164/236] locking/local_lock: Add missing owner initialization Date: Mon, 13 Sep 2021 15:14:29 +0200 Message-Id: <20210913131105.959519252@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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