From: Stephan Gerhold <stephan@gerhold.net>
To: Saravana Kannan <saravanak@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: Re: [PATCH 4.14 07/15] driver core: Extend device_is_dependent()
Date: Tue, 9 Feb 2021 20:04:10 +0100 [thread overview]
Message-ID: <YCLcqvgEB6fVtWMx@gerhold.net> (raw)
In-Reply-To: <CAGETcx8q4WmpF1mT8uLHYQXnioDKFi0PL1wUuVOtCyCnvyvKhg@mail.gmail.com>
On Fri, Feb 05, 2021 at 09:52:56AM -0800, Saravana Kannan wrote:
> On Fri, Feb 5, 2021 at 6:14 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> >
> > commit 3d1cf435e201d1fd63e4346b141881aed086effd upstream
> >
> > If the device passed as the target (second argument) to
> > device_is_dependent() is not completely registered (that is, it has
> > been initialized, but not added yet), but the parent pointer of it
> > is set, it may be missing from the list of the parent's children
> > and device_for_each_child() called by device_is_dependent() cannot
> > be relied on to catch that dependency.
> >
> > For this reason, modify device_is_dependent() to check the ancestors
> > of the target device by following its parent pointer in addition to
> > the device_for_each_child() walk.
> >
> > Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support")
> > Reported-by: Stephan Gerhold <stephan@gerhold.net>
> > Tested-by: Stephan Gerhold <stephan@gerhold.net>
> > Reviewed-by: Saravana Kannan <saravanak@google.com>
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Link: https://lore.kernel.org/r/17705994.d592GUb2YH@kreacher
> > Cc: stable <stable@vger.kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > drivers/base/core.c | 17 ++++++++++++++++-
> > 1 file changed, 16 insertions(+), 1 deletion(-)
> >
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -96,6 +96,16 @@ void device_links_read_unlock(int not_us
> > }
> > #endif /* !CONFIG_SRCU */
> >
> > +static bool device_is_ancestor(struct device *dev, struct device *target)
> > +{
> > + while (target->parent) {
> > + target = target->parent;
> > + if (dev == target)
> > + return true;
> > + }
> > + return false;
> > +}
> > +
> > /**
> > * device_is_dependent - Check if one device depends on another one
> > * @dev: Device to check dependencies for.
> > @@ -109,7 +119,12 @@ static int device_is_dependent(struct de
> > struct device_link *link;
> > int ret;
> >
> > - if (dev == target)
> > + /*
> > + * The "ancestors" check is needed to catch the case when the target
> > + * device has not been completely initialized yet and it is still
> > + * missing from the list of children of its parent device.
> > + */
> > + if (dev == target || device_is_ancestor(dev, target))
> > return 1;
> >
> > ret = device_for_each_child(dev, target, device_is_dependent);
> >
> >
>
> I think 4.14 device links API is so busted it's not worth patching
> this. It's not a memory leak or any kind of security issue.
>
> Stephan, are you seeing this issue in 4.14 or even care about it?
>
I guess I'm too late here (sorry about this), but in any case:
Actually, the issue I had only caused problems in some of the early 5.11
release candidates. The cyclic device link was also created on earlier
kernel versions, but (seemingly) did not cause any issues so far.
I try to stay on RCs/stable kernel versions so as far as
I'm concerned there is no need to backport this to 4.14.
Thanks!
Stephan
next prev parent reply other threads:[~2021-02-09 21:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-05 14:08 [PATCH 4.14 00/15] 4.14.220-rc1 review Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 01/15] net: dsa: bcm_sf2: put device node before return Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 02/15] ibmvnic: Ensure that CRQ entry read are correctly ordered Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 03/15] ACPI: thermal: Do not call acpi_thermal_check() directly Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 04/15] net_sched: reject silly cell_log in qdisc_get_rtab() Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 05/15] net_sched: gen_estimator: support large ewma log Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 06/15] base: core: Remove WARN_ON from link dependencies check Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 07/15] driver core: Extend device_is_dependent() Greg Kroah-Hartman
2021-02-05 17:52 ` Saravana Kannan
2021-02-09 19:04 ` Stephan Gerhold [this message]
2021-02-05 14:08 ` [PATCH 4.14 08/15] phy: cpcap-usb: Fix warning for missing regulator_disable Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 09/15] x86: __always_inline __{rd,wr}msr() Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 10/15] scsi: scsi_transport_srp: Dont block target in failfast state Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 11/15] scsi: libfc: Avoid invoking response handler twice if ep is already completed Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 12/15] mac80211: fix fast-rx encryption check Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 13/15] scsi: ibmvfc: Set default timeout to avoid crash during migration Greg Kroah-Hartman
2021-02-05 14:08 ` [PATCH 4.14 14/15] objtool: Dont fail on missing symbol table Greg Kroah-Hartman
2021-02-05 14:09 ` [PATCH 4.14 15/15] kthread: Extract KTHREAD_IS_PER_CPU Greg Kroah-Hartman
2021-02-06 14:57 ` [PATCH 4.14 00/15] 4.14.220-rc1 review Naresh Kamboju
2021-02-06 16:01 ` Guenter Roeck
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=YCLcqvgEB6fVtWMx@gerhold.net \
--to=stephan@gerhold.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=saravanak@google.com \
--cc=stable@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.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 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.