From: Greg KH <gregkh@linuxfoundation.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] driver core: bus: Fix a potential double free
Date: Thu, 31 Aug 2017 16:57:08 +0000 [thread overview]
Message-ID: <20170831165708.GA26329@kroah.com> (raw)
In-Reply-To: <20170829192349.15666-1-christophe.jaillet@wanadoo.fr>
On Tue, Aug 29, 2017 at 09:23:49PM +0200, Christophe JAILLET wrote:
> The .release function of driver_ktype is 'driver_release()'.
> This function frees the container_of this kobject.
>
> So, this memory must not be freed explicitly in the error handling path of
> 'bus_add_driver()'. Otherwise a double free will occur.
Oh, nice catch!
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I have left the 'drv->p = NULL' even if it looks useless to me. It does not
> hurt. I have also left a comment to explain why we do not free 'drv->p'
> explicitly before zeroing this pointer.
We need that for when people do static structures. Like as is done for
drivers. Well, I think that's why we need it, can't really remember,
might as well be safe, the error handling paths here are crazy at
times...
thnaks,
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] driver core: bus: Fix a potential double free
Date: Thu, 31 Aug 2017 18:57:08 +0200 [thread overview]
Message-ID: <20170831165708.GA26329@kroah.com> (raw)
In-Reply-To: <20170829192349.15666-1-christophe.jaillet@wanadoo.fr>
On Tue, Aug 29, 2017 at 09:23:49PM +0200, Christophe JAILLET wrote:
> The .release function of driver_ktype is 'driver_release()'.
> This function frees the container_of this kobject.
>
> So, this memory must not be freed explicitly in the error handling path of
> 'bus_add_driver()'. Otherwise a double free will occur.
Oh, nice catch!
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I have left the 'drv->p = NULL' even if it looks useless to me. It does not
> hurt. I have also left a comment to explain why we do not free 'drv->p'
> explicitly before zeroing this pointer.
We need that for when people do static structures. Like as is done for
drivers. Well, I think that's why we need it, can't really remember,
might as well be safe, the error handling paths here are crazy at
times...
thnaks,
greg k-h
next prev parent reply other threads:[~2017-08-31 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 19:23 [PATCH] driver core: bus: Fix a potential double free Christophe JAILLET
2017-08-29 19:23 ` Christophe JAILLET
2017-08-31 16:57 ` Greg KH [this message]
2017-08-31 16:57 ` Greg KH
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=20170831165708.GA26329@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.