Re: [PATCH] drivers: net: remove a dangling pointer in peak_usb_create_dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 22, 2022 at 3:36 AM Pavel Skripkin <paskripkin@xxxxxxxxx> wrote:
>
> Hi Dongliang,
>
> On 1/21/22 08:58, Dongliang Mu wrote:
> [...]>> 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.
> >
>
> Yeah, it seems like (at least based on code), that this dangling pointer
> is not dangerous, since nothing accesses it. And next_siblings
> _guaranteed_ to be NULL, since dev->next_siblings is set NULL in
> disconnect()

Yes, you're right. As a security researcher, I am sensitive to such
dangling pointers.

As its nullifying site is across functions, I suggest developers
remove this dangling pointer in case that any newly added code in this
function or before the nullifying location would touch next_siblings.

If Pavel and others think it's fine, then it's time to close this patch.

>
>
>
>
> With regards,
> Pavel Skripkin



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux