Subject: Re: [PATCH] can: should not use __dev_get_by_index() without locks

From: Oliver Hartkopp <[email-masked]>
Date: Fri, 06 Nov 2009 12:04:16 +0100

Eric Dumazet wrote:
> David
> 
> A more elegant patch will be possible for 2.6.33, but for 2.6.32,
> I think following patch is needed (Please note I did not test it)
> 
> (More elegant : use RCU lookups ;) , I'll wait for net-next-2.6 
>  upgrade as well)
> 
> Thanks
> 
> [PATCH] can: should not use __dev_get_by_index() without locks
> 
> bcm_proc_getifname() is called with RTNL and dev_base_lock
> not held. It calls __dev_get_by_index() without locks, and
> this is illegal (might crash)
> 
> Close the race by holding dev_base_lock and copying dev->name
> in the protected section.
> 
> Signed-off-by: Eric Dumazet <[email-masked]>

Thanks for pointing this out.
This is a quite old code section which is not used very often at runtime - and
usually the netdevice is not removed at that time ;-)

Btw. this is no excuse for that missing locking, sorry.

Thanks for the fix!

Compiled and tested successfully.

Signed-off-by: Oliver Hartkopp <[email-masked]>