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]
Date:	Wed, 22 Oct 2008 06:57:31 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Catalin Marinas <catalin.marinas@....com>
CC:	netdev@...r.kernel.org
Subject: Re: [PATCH 3/3] smc911x: Make the driver safer on SMP

Catalin Marinas wrote:
> This patch extends the critical regions covered by lp->lock to make it
> safer on SMP. The main failure point was the smc911x_hard_start_xmit
> function being called from different CPUs. It was tested on the ARM SMP
> platforms.
> 
> Signed-off-by: Catalin Marinas <catalin.marinas@....com>
> ---
>  drivers/net/smc911x.c |   25 ++++++++-----------------
>  1 files changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 0216440..89f1fa6 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -155,23 +155,17 @@ static void PRINT_PKT(u_char *buf, int length)
>  /* this enables an interrupt in the interrupt mask register */
>  #define SMC_ENABLE_INT(lp, x) do {			\
>  	unsigned int  __mask;				\
> -	unsigned long __flags;				\
> -	spin_lock_irqsave(&lp->lock, __flags);		\
>  	__mask = SMC_GET_INT_EN((lp));			\
>  	__mask |= (x);					\
>  	SMC_SET_INT_EN((lp), __mask);			\
> -	spin_unlock_irqrestore(&lp->lock, __flags);	\
>  } while (0)
>  
>  /* this disables an interrupt from the interrupt mask register */
>  #define SMC_DISABLE_INT(lp, x) do {			\
>  	unsigned int  __mask;				\
> -	unsigned long __flags;				\
> -	spin_lock_irqsave(&lp->lock, __flags);		\
>  	__mask = SMC_GET_INT_EN((lp));			\
>  	__mask &= ~(x);					\
>  	SMC_SET_INT_EN((lp), __mask);			\
> -	spin_unlock_irqrestore(&lp->lock, __flags);	\
>  } while (0)

Very nice... this has the added benefit of making the locking more 
obvious to the reviewer, rather than burying the locking in a macro as 
the previous code did.

	Jeff



--
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