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:   Tue, 5 Feb 2019 09:27:49 -0500
From:   Sven Van Asbroeck <thesven73@...il.com>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     Tejun Heo <tj@...nel.org>, Lai Jiangshan <jiangshanlai@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Sebastian Reichel <sre@...nel.org>,
        Kees Cook <keescook@...omium.org>
Subject: Re: [RFC v1 2/3] max17042_battery: fix potential user-after-free on
 module unload

On Tue, Feb 5, 2019 at 3:27 AM Dmitry Torokhov
<dmitry.torokhov@...il.com> wrote:
>
> Are there many more instances of this?

Unfortunately I think so.
A simple grep brings up a couple of candidates, but I'm sure there are more:

drivers/regulator/arizona-micsupp.c
drivers/nfc/port100.c
drivers/power/supply/max14656_charger_detector.c
drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c

> I am unsure if we need
> devm_init_work() when we can easily do the same in remove() call.

The devm_init_work() suggestion only addresses the problem for those modules
that use devm_. The others will need fixes in remove(). But this is not as
elegant and error-proof as using devm_init_work().

For example, take port100.c's disconnect function. It starts deallocating
resources, but the cmd_complete_work (scheduled by urb completion) may still
be in progress, and touch these resources after free.

At least, I _think_ that is the case. I'm not familiar enough with this driver
to be 100% sure, but it sounds likely.

static void port100_disconnect(struct usb_interface *interface)
{
    struct port100 *dev;

    dev = usb_get_intfdata(interface);
    usb_set_intfdata(interface, NULL);

    nfc_digital_unregister_device(dev->nfc_digital_dev);
    nfc_digital_free_device(dev->nfc_digital_dev);

    usb_kill_urb(dev->in_urb);
    usb_kill_urb(dev->out_urb);

    usb_free_urb(dev->in_urb);
    usb_free_urb(dev->out_urb);
    usb_put_dev(dev->udev);

    kfree(dev->cmd);

    nfc_info(&interface->dev, "Sony Port-100 NFC device disconnected\n");
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ