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: <CAK7N6vqS9PW85hgcA7EVzCk-TQo_ru4OcC5i0Rw-b2hvb4YoXg@mail.gmail.com>
Date:	Fri, 28 Sep 2012 09:01:13 +0530
From:	anish singh <anish198519851985@...il.com>
To:	Ming Lei <ming.lei@...onical.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org,
	Russell King <linux@....linux.org.uk>, stable@...r.kernel.org
Subject: Re: [PATCH] driver core: fix possible missing of device probe

Hello Ming,
Though I am not an expert in this driver core area but
I have been following this fix.So have some queries below:

On Fri, Sep 28, 2012 at 6:22 AM, Ming Lei <ming.lei@...onical.com> wrote:
> Inside bus_add_driver(), one device might be added into
should it not be "driver might be added into"?
> the bus or probed which is triggered by deferred probe
> just after completing of driver_attach() and before
> 'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)',
> so the device won't be probed by this driver.
So the corresponding device will not be probed.
>
> This patch moves the below line
>
>         'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)'
>
> before driver_attach() inside bus_add_driver().
>
> So fixes the problem since the below way can guarantee that
> no probe(dev) may be lost.
>
As I understand CPU0 is just calling bus_add_driver and driver_attach
is called and after that it was pre-empted and cpu1 came into picture.
Deferred probe started running on cpu1 and it didn't find the driver present
int the knode_bus and unloaded the driver(why it unloaded is already
explained by russell in his first post).
Hope my understanding is correct.
> CPU0                                    CPU1
> driver_register
>         ...
>         write(bus->driver_list)
>         smp_mb()
>         read(bus->device_list)
>         ...
>                                         device_add
>                                                 /* bus_add_device */
>                                                 write(bus->device_list)
>                                                 smp_mb()
>                                                 /* bus_probe_device*/
>                                                 read(bus->driver_list)
>
> And the smp_mb() has been implicit by UNLOCK+LOCK
> of 'klist' according to 'VARIETIES OF MEMORY BARRIER' part
> of Documentation/memory-barriers.txt.
>
> Reported-and-Tested-by: Russell King <linux@....linux.org.uk>
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Ming Lei <ming.lei@...onical.com>
> ---
>  drivers/base/bus.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 181ed26..3b5bddb 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -714,12 +714,12 @@ int bus_add_driver(struct device_driver *drv)
>         if (error)
>                 goto out_unregister;
>
> +       klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers);
>         if (drv->bus->p->drivers_autoprobe) {
>                 error = driver_attach(drv);
>                 if (error)
>                         goto out_unregister;
>         }
> -       klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers);
>         module_add_driver(drv->owner, drv);
>
>         error = driver_create_file(drv, &driver_attr_uevent);
> --
> 1.7.9.5
>
> --
> 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/
--
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