lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cd0cd3a9-f372-4c49-9530-de51719f3cbc@paulmck-laptop>
Date: Fri, 30 Aug 2024 03:39:50 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Zhen Lei <thunder.leizhen@...wei.com>
Cc: Lai Jiangshan <jiangshanlai@...il.com>,
	Josh Triplett <josh@...htriplett.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	rcu@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] srcu: Replace WARN_ON_ONCE() with BUILD_BUG_ON() if
 possible

On Thu, Aug 22, 2024 at 11:21:28AM +0800, Zhen Lei wrote:
> The value of ARRAY_SIZE() can be determined at compile time, so if both
> sides of the equation are ARRAY_SIZE(), using BUILD_BUG_ON() can help us
> catch the problem earlier.
> 
> While there are cases where unequal array sizes will work, there is no
> point in allowing them, so it makes more sense to force them to be equal
> using BUILD_BUG_ON().
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>

Reviewed-by: Paul E. McKenney <paulmck@...nel.org>

> ---
>  kernel/rcu/srcutree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index b24db425f16d850..a9c7795bb77d650 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -128,7 +128,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
>  	 * Initialize the per-CPU srcu_data array, which feeds into the
>  	 * leaves of the srcu_node tree.
>  	 */
> -	WARN_ON_ONCE(ARRAY_SIZE(sdp->srcu_lock_count) !=
> +	BUILD_BUG_ON(ARRAY_SIZE(sdp->srcu_lock_count) !=
>  		     ARRAY_SIZE(sdp->srcu_unlock_count));
>  	for_each_possible_cpu(cpu) {
>  		sdp = per_cpu_ptr(ssp->sda, cpu);
> @@ -186,7 +186,7 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags)
>  	/* Each pass through this loop initializes one srcu_node structure. */
>  	srcu_for_each_node_breadth_first(ssp, snp) {
>  		spin_lock_init(&ACCESS_PRIVATE(snp, lock));
> -		WARN_ON_ONCE(ARRAY_SIZE(snp->srcu_have_cbs) !=
> +		BUILD_BUG_ON(ARRAY_SIZE(snp->srcu_have_cbs) !=
>  			     ARRAY_SIZE(snp->srcu_data_have_cbs));
>  		for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) {
>  			snp->srcu_have_cbs[i] = SRCU_SNP_INIT_SEQ;
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ