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: <CAD-N9QUZ95zqboe=58gybue6ssSO-M-raijd3XnGXkXnp3wiqQ@mail.gmail.com>
Date:   Fri, 21 Jan 2022 13:58:58 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Pavel Skripkin <paskripkin@...il.com>
Cc:     Dongliang Mu <dzm91@...t.edu.cn>,
        Wolfgang Grandegger <wg@...ndegger.com>,
        Marc Kleine-Budde <mkl@...gutronix.de>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Stephane Grosjean <s.grosjean@...k-system.com>,
        Stefan Mätje <stefan.maetje@....eu>,
        Vincent Mailhol <mailhol.vincent@...adoo.fr>,
        linux-can@...r.kernel.org,
        "open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers: net: remove a dangling pointer in peak_usb_create_dev

On Fri, Jan 21, 2022 at 11:36 AM Dongliang Mu <mudongliangabcd@...il.com> wrote:
>
> On Fri, Jan 21, 2022 at 8:09 AM Dongliang Mu <mudongliangabcd@...il.com> wrote:
> >
> > On Thu, Jan 20, 2022 at 10:27 PM Pavel Skripkin <paskripkin@...il.com> wrote:
> > >
> > > Hi Dongliang,
> > >
> > > On 1/20/22 16:05, Dongliang Mu wrote:
> > > > From: Dongliang Mu <mudongliangabcd@...il.com>
> > > >
> > > > The error handling code of peak_usb_create_dev forgets to reset the
> > > > next_siblings of previous entry.
> > > >
> > > > Fix this by nullifying the (dev->prev_siblings)->next_siblings in the
> > > > error handling code.
> > > >
> > > > Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
> > > > ---
> > > >   drivers/net/can/usb/peak_usb/pcan_usb_core.c | 3 +++
> > > >   1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> > > > index b850ff8fe4bd..f858810221b6 100644
> > > > --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> > > > +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> > > > @@ -894,6 +894,9 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter,
> > > >               dev->adapter->dev_free(dev);
> > > >
> > > >   lbl_unregister_candev:
> > > > +     /* remove the dangling pointer in next_siblings */
> > > > +     if (dev->prev_siblings)
> > > > +             (dev->prev_siblings)->next_siblings = NULL;
> > > >       unregister_candev(netdev);
> > > >
> > > >   lbl_restore_intf_data:
> > >
> > >
> > > Is this pointer used somewhere? I see, that couple of
> > > struct peak_usb_adapter::dev_free() functions use it, but
> > > peak_usb_disconnect() sets dev->next_siblings to NULL before calling
> > > ->dev_free().
> > >
> > > Do you have a calltrace or oops log?
> >
> > Hi Pavel,
> >
> > I have no calltrace or log since this dangling pointer may not be
> > dereferenced in the following code. But I am not sure. So the commit
> > title of this patch is "remove a dangling pointer in
> > peak_usb_create_dev".
>
> BTW, as you mentioned, dev->next_siblings is used in struct
> peak_usb_adapter::dev_free() (i.e., pcan_usb_fd_free or
> pcan_usb_pro_free), how about the following path?
>
> peak_usb_probe
> -> peak_usb_create_dev (goto adap_dev_free;)
>    -> dev->adapter->dev_free()
>       -> pcan_usb_fd_free or pcan_usb_pro_free (This function uses
> next_siblings as condition elements)
>
> static void pcan_usb_fd_free(struct peak_usb_device *dev)
> {
>         /* last device: can free shared objects now */
>         if (!dev->prev_siblings && !dev->next_siblings) {
>                 struct pcan_usb_fd_device *pdev =
>                         container_of(dev, struct pcan_usb_fd_device, dev);
>
>                 /* free commands buffer */
>                 kfree(pdev->cmd_buffer_addr);
>
>                 /* free usb interface object */
>                 kfree(pdev->usb_if);
>         }
> }
>
> If next_siblings is not NULL, will it lead to the missing free of
> cmd_buffer_addr and usb_if?

The answer is No. Forget my silly thought.

>
> Please let me know if I made any mistakes.
>
> > >
> > >
> > >
> > >
> > > With regards,
> > > Pavel Skripkin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ