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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120903094345.GJ5574@leaf>
Date:	Mon, 3 Sep 2012 02:43:45 -0700
From:	Josh Triplett <josh@...htriplett.org>
To:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, laijs@...fujitsu.com,
	dipankar@...ibm.com, akpm@...ux-foundation.org,
	mathieu.desnoyers@...ymtl.ca, niv@...ibm.com, tglx@...utronix.de,
	peterz@...radead.org, rostedt@...dmis.org, Valdis.Kletnieks@...edu,
	dhowells@...hat.com, eric.dumazet@...il.com, darren@...art.com,
	fweisbec@...il.com, sbw@....edu, patches@...aro.org,
	"Paul E. McKenney" <paul.mckenney@...aro.org>
Subject: Re: [PATCH tip/core/rcu 21/23] rcu: Eliminate signed overflow in
 synchronize_rcu_expedited()

On Thu, Aug 30, 2012 at 11:18:36AM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paul.mckenney@...aro.org>
> 
> In the C language, signed overflow is undefined.  It is true that
> twos-complement arithmetic normally comes to the rescue, but if the
> compiler can subvert this any time it has any information about the values
> being compared.  For example, given "if (a - b > 0)", if the compiler
> has enough information to realize that (for example) the value of "a"
> is positive and that of "b" is negative, the compiler is within its
> rights to optimize to a simple "if (1)", which might not be what you want.
> 
> This commit therefore converts synchronize_rcu_expedited()'s work-done
> detection counter from signed to unsigned.
> 
> Signed-off-by: Paul E. McKenney <paul.mckenney@...aro.org>
> Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>

Reviewed-by: Josh Triplett <josh@...htriplett.org>

>  kernel/rcutree_plugin.h |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> index befb0b2..7ed45c9 100644
> --- a/kernel/rcutree_plugin.h
> +++ b/kernel/rcutree_plugin.h
> @@ -677,7 +677,7 @@ void synchronize_rcu(void)
>  EXPORT_SYMBOL_GPL(synchronize_rcu);
>  
>  static DECLARE_WAIT_QUEUE_HEAD(sync_rcu_preempt_exp_wq);
> -static long sync_rcu_preempt_exp_count;
> +static unsigned long sync_rcu_preempt_exp_count;
>  static DEFINE_MUTEX(sync_rcu_preempt_exp_mutex);
>  
>  /*
> @@ -792,7 +792,7 @@ void synchronize_rcu_expedited(void)
>  	unsigned long flags;
>  	struct rcu_node *rnp;
>  	struct rcu_state *rsp = &rcu_preempt_state;
> -	long snap;
> +	unsigned long snap;
>  	int trycount = 0;
>  
>  	smp_mb(); /* Caller's modifications seen first by other CPUs. */
> @@ -811,10 +811,10 @@ void synchronize_rcu_expedited(void)
>  			synchronize_rcu();
>  			return;
>  		}
> -		if ((ACCESS_ONCE(sync_rcu_preempt_exp_count) - snap) > 0)
> +		if (ULONG_CMP_LT(snap, ACCESS_ONCE(sync_rcu_preempt_exp_count)))
>  			goto mb_ret; /* Others did our work for us. */
>  	}
> -	if ((ACCESS_ONCE(sync_rcu_preempt_exp_count) - snap) > 0)
> +	if (ULONG_CMP_LT(snap, ACCESS_ONCE(sync_rcu_preempt_exp_count)))
>  		goto unlock_mb_ret; /* Others did our work for us. */
>  
>  	/* force all RCU readers onto ->blkd_tasks lists. */
> -- 
> 1.7.8
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ