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: <20150313.123822.1761706097366192562.davem@davemloft.net>
Date:	Fri, 13 Mar 2015 12:38:22 -0400 (EDT)
From:	David Miller <davem@...emloft.net>
To:	Yuval.Mintz@...gic.com
Cc:	netdev@...r.kernel.org, Ariel.Elior@...gic.com
Subject: Re: [PATCH net] bnx2x: Fix statistics locking scheme

From: Yuval Mintz <Yuval.Mintz@...gic.com>
Date: Fri, 13 Mar 2015 15:32:45 +0200

> -	spin_lock_bh(&bp->stats_lock);
> -	state = bp->stats_state;
> +	/* Statistics update run from timer context, and we don't want to stop
> +	 * that context in case someone is in the middle of a transition.
> +	 * For other events, wait a bit until lock is taken.
> +	 */
> +	if (down_trylock(&bp->stats_lock)) {
> +		if (event == STATS_EVENT_UPDATE)
> +			return;
> +
> +		if (down_timeout(&bp->stats_lock, HZ / 10))
> +			BNX2X_ERR("Unable to acquire stats lock\n");
> +	}
> +
> +	bnx2x_stats_stm[state][event].action(bp);

You run the action even if you can't get the semaphore.

> +{
> +	int cnt = 10;
> +
> +	if (down_timeout(&bp->stats_lock, HZ / 10))
>  		BNX2X_ERR("Unable to acquire stats lock\n");
> +
> +	/* Wait for statistics to end, then run supplied function 'safely' */
>  	bnx2x_stats_comp(bp);
> +	while (bp->stats_pending && cnt) {
> +		if (bnx2x_storm_stats_update(bp)) {
> +			usleep_range(1000, 2000);
> +			cnt--;
> +		}
> +	}
> +	if (bp->stats_pending)
> +		BNX2X_ERR("Failed to wait for stats pending to stop; Continuing anyway\n");

Here again, same thing, if you timeout trying to wait for the pending
counter to clear, you still execute the protected section of code.

This is terrible.

Either you use locking to protect critical sections, or you don't.

I do not want to see any code that enters the critical section when
the locked state cannot be acquired.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ