All of lore.kernel.org
 help / color / mirror / Atom feed
* Possible race in nsc-ircc.ko
@ 2017-08-25 14:05 Anton Volkov
  2017-08-25 16:48 ` Jean Tourrilhes
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Volkov @ 2017-08-25 14:05 UTC (permalink / raw)
  To: dagb, jt, samuel; +Cc: netdev, linux-kernel, ldv-project, Alexey Khoroshilov

Hello.

While searching for races in the Linux kernel I've come across 
"drivers/net/irda/nsc-ircc.ko" module. Here is a question that I came up 
with while analyzing results. Lines are given using the info from Linux 
v4.12.

Consider the following case:

Thread 1:                   Thread 2:
nsc_ircc_init
->nsc_ircc_open
     self = netdev_priv(dev)
     register_netdev(dev)
                             nsc_ircc_net_ioctl
                             ->nsc_ircc_change_speed
     self->dongle_id = ...       <READ self->io.dongle_id>
     (nsc-ircc.c: line 485)      (nsc-ircc.c: line 1318)
     platform_device_register_simple

Before the initialization of self->dongle_id in msc_ircc_open() its 
value is 0. Thus if read access to its value in nsc_ircc_change_speed 
occurs before the initialization there will be an attempt to change 
speed of dongle with undesired id (if the dongle with id 0 exists). Is 
this case feasible from your point of view?

Thank you for your time.

-- Anton Volkov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
e-mail: avolkov@ispras.ru

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Possible race in nsc-ircc.ko
  2017-08-25 14:05 Possible race in nsc-ircc.ko Anton Volkov
@ 2017-08-25 16:48 ` Jean Tourrilhes
  0 siblings, 0 replies; 2+ messages in thread
From: Jean Tourrilhes @ 2017-08-25 16:48 UTC (permalink / raw)
  To: Anton Volkov
  Cc: dagb, samuel, netdev, linux-kernel, ldv-project, Alexey Khoroshilov

On Fri, Aug 25, 2017 at 05:05:25PM +0300, Anton Volkov wrote:
> Hello.
> 
> While searching for races in the Linux kernel I've come across
> "drivers/net/irda/nsc-ircc.ko" module. Here is a question that I came up
> with while analyzing results. Lines are given using the info from Linux
> v4.12.
> 
> Consider the following case:
> 
> Thread 1:                   Thread 2:
> nsc_ircc_init
> ->nsc_ircc_open
>     self = netdev_priv(dev)
>     register_netdev(dev)
>                             nsc_ircc_net_ioctl
>                             ->nsc_ircc_change_speed
>     self->dongle_id = ...       <READ self->io.dongle_id>
>     (nsc-ircc.c: line 485)      (nsc-ircc.c: line 1318)
>     platform_device_register_simple
> 
> Before the initialization of self->dongle_id in msc_ircc_open() its value is
> 0. Thus if read access to its value in nsc_ircc_change_speed occurs before
> the initialization there will be an attempt to change speed of dongle with
> undesired id (if the dongle with id 0 exists). Is this case feasible from
> your point of view?
> 
> Thank you for your time.
> 
> -- Anton Volkov

	A first glance, that seems like a valid race. I'm not sure if
there is a netdev lock/status to protect the driver, because it looks
like doing any operation on a device before "open" has completed would
be dangerous for most drivers.
	I don't have time to check the code paths, as I have not
looked at that code in ages.
	Good luck !

	Jean

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-25 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 14:05 Possible race in nsc-ircc.ko Anton Volkov
2017-08-25 16:48 ` Jean Tourrilhes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.