All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Zubin Mithra <zsm@chromium.org>
Cc: stable@vger.kernel.org, groeck@chromium.org,
	benh@kernel.crashing.org, rafael@kernel.org
Subject: Re: [PATCH v4.4.y] drivers: core: Remove glue dirs from sysfs earlier
Date: Tue, 29 Jan 2019 07:58:36 +0100	[thread overview]
Message-ID: <20190129065836.GA24231@kroah.com> (raw)
In-Reply-To: <20190128173130.22618-1-zsm@chromium.org>

On Mon, Jan 28, 2019 at 09:31:30AM -0800, Zubin Mithra wrote:
> From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> commit 726e41097920a73e4c7c33385dcc0debb1281e18 upstream
> 
> For devices with a class, we create a "glue" directory between
> the parent device and the new device with the class name.
> 
> This directory is never "explicitely" removed when empty however,
> this is left to the implicit sysfs removal done by kobject_release()
> when the object loses its last reference via kobject_put().
> 
> This is problematic because as long as it's not been removed from
> sysfs, it is still present in the class kset and in sysfs directory
> structure.
> 
> The presence in the class kset exposes a use after free bug fixed
> by the previous patch, but the presence in sysfs means that until
> the kobject is released, which can take a while (especially with
> kobject debugging), any attempt at re-creating such as binding a
> new device for that class/parent pair, will result in a sysfs
> duplicate file name error.
> 
> This fixes it by instead doing an explicit kobject_del() when
> the glue dir is empty, by keeping track of the number of
> child devices of the gluedir.
> 
> This is made easy by the fact that all glue dir operations are
> done with a global mutex, and there's already a function
> (cleanup_glue_dir) called in all the right places taking that
> mutex that can be enhanced for this. It appears that this was
> in fact the intent of the function, but the implementation was
> wrong.
> 
> Backport Note: kref_read() is not present in 4.4. Hence,
> use atomic_read(&kref.refcount) instead of kref_read(&kref).
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Zubin Mithra <zsm@chromium.org>
> ---
>  drivers/base/core.c     |  2 ++
>  include/linux/kobject.h | 17 +++++++++++++++++
>  2 files changed, 19 insertions(+)

Wait, why is this needed?

And why only for 4.4?  What about 4.9 and 4.14?  Do you want to upgrade
and suddenly hit the same "bug" that you fixed before?

There was a reason that I did not backport this to the stable tree when
it was submitted, and that was because this was an odd race to ever hit.
Are you hitting this in the real world without kobject deferred
release enabled?  And if so, are you hitting the WARN_ON that is added
here?

I would like to hold off on this until some more information is
provided, and at the least, if it is accepted, we add it to all of the
stable trees, not just 4.4.y.  So I'm going to go drop it from the 4.4.y
queue for now.

thanks,

greg k-h

  parent reply	other threads:[~2019-01-29  6:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 17:31 [PATCH v4.4.y] drivers: core: Remove glue dirs from sysfs earlier Zubin Mithra
2019-01-28 19:44 ` Sasha Levin
2019-01-29  6:58 ` Greg KH [this message]
2019-01-29 14:35   ` Guenter Roeck
2019-01-29 15:19     ` Greg KH
2019-01-29 19:22       ` Guenter Roeck
2019-01-29 21:17         ` Guenter Roeck
2019-02-04  8:58 ` 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=20190129065836.GA24231@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=groeck@chromium.org \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zsm@chromium.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.