Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1870018pxb; Mon, 13 Sep 2021 07:16:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzREiHkF5imRfbzo3dfBDiONyfFYYaZsvyK++XbGoDchRgUGxTtW4GyDUI8o5LZuqtPfRD3 X-Received: by 2002:a05:6402:4cb:: with SMTP id n11mr13253877edw.292.1631542568347; Mon, 13 Sep 2021 07:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542568; cv=none; d=google.com; s=arc-20160816; b=vJmFaDfsAsB87J3Cl9yMnKeUDBhIJDrXDg/alUuFNyLchculY0gpzQ16f7LSc9Bgps 00ASl+GdP4C5sUJmosmNvDx3vSn/dOdfTMDRuvxOAP1v8JiUrA60gCvR/gjBGItugoVP yN793j35RRVsIlU5Zq6DNowiYX08gFUUPlRFim9x1GePVOC8JXDQWXh+ypuU+/AiOKue jdIIx4t7gQMAAm4SOD6spE6G+965dK3D7x6fNKwSsRDQ+lnzwk9MBbj7bYvEbaIfW9aW FSu+OXCXOWRdBZLIFKH0PtzzOVqgBMlLHr/O7OPwAWQbY/mQgWZyrBihUvF9YE3kCoLX cTsg== 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=Bq34Vf18TzU0J24qGJyCrgyFLFP6fFtybRu/nFzZ7rvaRXGVGNus5VMPhGygqWqA2P CNUaMEOkzPVwTZChWfnCWIPWT5tV9So5c4zP0AyqvWqx6hniH63ZysHZ55KBL0j406GN UifZJDGtoObvzjVdaWQC9vo8hqZV3sUGbMqMA0Zi5/FJ7mDApYIDbBhRlEvYcSle5ld7 KZPVy88lOeFAfF4BDtdXmnpvdNEHftufzN8xnnY3R8+eTZWSHCDnKz8gLuWHL7ptaF4X Mc+bPUk6QMIgkjEE/6Pfs7Vz7nzy2XpPLjldjf2SM8Nh8RgXeasp8DrF8SDfZvarPVuv VaAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D9TGPck8; 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 w20si7359965ejv.231.2021.09.13.07.15.43; Mon, 13 Sep 2021 07:16:08 -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=D9TGPck8; 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 S1344217AbhIMOOK (ORCPT + 99 others); Mon, 13 Sep 2021 10:14:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:34312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344237AbhIMOLK (ORCPT ); Mon, 13 Sep 2021 10:11:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50FAD6134F; Mon, 13 Sep 2021 13:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540525; bh=6Qk9BssbyK0UYvw8za6Swqpm4GUFOO+l2eyAMHBkIfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9TGPck8CiebibiQGU7D2m8uNg5GEMNSvZgFGIOQsLXzn9P6TnMMKyOZ1s/kytzwF kl05slfunePUAPL66v85JsUr5fXbdQY/5Uej61OsvIETv8y83xw4x+EXCRHtkekKCh JiRoFSbR3WaO/NoY9EWdddISU6WOw6ZzJU7DasT8= 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.13 197/300] locking/local_lock: Add missing owner initialization Date: Mon, 13 Sep 2021 15:14:18 +0200 Message-Id: <20210913131116.031623064@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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