netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Pavel Skripkin <paskripkin@gmail.com>
Cc: "Dongliang Mu" <dzm91@hust.edu.cn>,
	"Wolfgang Grandegger" <wg@grandegger.com>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Stephane Grosjean" <s.grosjean@peak-system.com>,
	"Stefan Mätje" <stefan.maetje@esd.eu>,
	"Vincent Mailhol" <mailhol.vincent@wanadoo.fr>,
	linux-can@vger.kernel.org,
	"open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers: net: remove a dangling pointer in peak_usb_create_dev
Date: Sat, 22 Jan 2022 14:45:24 +0800	[thread overview]
Message-ID: <CAD-N9QUATFcaOO2reg=Y0jum83UJGOzMhcX3ukCY+cY-XCJaPA@mail.gmail.com> (raw)
In-Reply-To: <8d4b0822-4e94-d124-e191-bec3effaf97c@gmail.com>

On Sat, Jan 22, 2022 at 3:36 AM Pavel Skripkin <paskripkin@gmail.com> 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

  reply	other threads:[~2022-01-22  6:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 13:05 [PATCH] drivers: net: remove a dangling pointer in peak_usb_create_dev Dongliang Mu
2022-01-20 14:27 ` Pavel Skripkin
2022-01-21  0:09   ` Dongliang Mu
2022-01-21  3:36     ` Dongliang Mu
2022-01-21  5:58       ` Dongliang Mu
2022-01-21 19:36         ` Pavel Skripkin
2022-01-22  6:45           ` Dongliang Mu [this message]
2022-01-23 13:48             ` Pavel Skripkin
2022-01-24  6:04               ` Dongliang Mu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD-N9QUATFcaOO2reg=Y0jum83UJGOzMhcX3ukCY+cY-XCJaPA@mail.gmail.com' \
    --to=mudongliangabcd@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dzm91@hust.edu.cn \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=s.grosjean@peak-system.com \
    --cc=stefan.maetje@esd.eu \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).