All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: "José Pekkarinen" <jose.pekkarinen@foxhound.fi>
Cc: len.brown@intel.com, linux-pm@vger.kernel.org, rafael@kernel.org,
	linux-kernel@vger.kernel.org,
	syzbot+95f2e2439b97575ec3c0@syzkaller.appspotmail.com,
	pavel@ucw.cz, linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] drivers core: lookup sysfs power group before removal
Date: Fri, 3 Nov 2023 19:36:21 +0100	[thread overview]
Message-ID: <2023110353-bring-contented-c9f8@gregkh> (raw)
In-Reply-To: <835b2930c710381b8da38eca821aa92d@foxhound.fi>

On Fri, Nov 03, 2023 at 07:49:39PM +0200, José Pekkarinen wrote:
> On 2023-11-01 19:54, Greg KH wrote:
> > On Wed, Nov 01, 2023 at 07:36:27PM +0200, José Pekkarinen wrote:
> > > Hinted by syzboot, there is a few cases where the sysfs power group
> > > may
> > > not be there, like the failure while adding it, or adding its runtime
> > > group, or when the sysfs firmware loader fallback fail to populate. In
> > > the last case, the device_del function will be called leading to
> > > attempt
> > > to remove the sysfs group. This patch will lookup for it in advance to
> > > grant that it is effectively there before cleaning it up.
> > > 
> > > Reported-by: syzbot+95f2e2439b97575ec3c0@syzkaller.appspotmail.com
> > > 
> > > Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
> > > ---
> > >  drivers/base/power/sysfs.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> > > index a1474fb67db9..6601729c4698 100644
> > > --- a/drivers/base/power/sysfs.c
> > > +++ b/drivers/base/power/sysfs.c
> > > @@ -834,5 +834,7 @@ void dpm_sysfs_remove(struct device *dev)
> > >  	dev_pm_qos_constraints_destroy(dev);
> > >  	rpm_sysfs_remove(dev);
> > >  	sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
> > > -	sysfs_remove_group(&dev->kobj, &pm_attr_group);
> > > +
> > > +	if (kernfs_find_and_get((&dev->kobj)->sd, pm_attr_group.name))
> > > +		sysfs_remove_group(&dev->kobj, &pm_attr_group);
> > 
> > What's to keep it from going away right after finding it?
> > 
> > In other words, what is wrong with removing a group that is not there?
> > What error happens?  It should be fine, or are you seeing real code
> > failures somewhere?
> 
>     No, this is just hitting a warning that sysbot complains about by
> setting panic on warning, no big deal, though it can be a wrong behaviour
> in ueagle-atm driver, since it defines to disconnect the device if the
> firmware is not there, no matter the sysfs fallback.

Then fix the driver please.

And what warning are you seeing exactly?

thanks,

greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: "José Pekkarinen" <jose.pekkarinen@foxhound.fi>
Cc: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz,
	skhan@linuxfoundation.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	syzbot+95f2e2439b97575ec3c0@syzkaller.appspotmail.com
Subject: Re: [PATCH] drivers core: lookup sysfs power group before removal
Date: Fri, 3 Nov 2023 19:36:21 +0100	[thread overview]
Message-ID: <2023110353-bring-contented-c9f8@gregkh> (raw)
In-Reply-To: <835b2930c710381b8da38eca821aa92d@foxhound.fi>

On Fri, Nov 03, 2023 at 07:49:39PM +0200, José Pekkarinen wrote:
> On 2023-11-01 19:54, Greg KH wrote:
> > On Wed, Nov 01, 2023 at 07:36:27PM +0200, José Pekkarinen wrote:
> > > Hinted by syzboot, there is a few cases where the sysfs power group
> > > may
> > > not be there, like the failure while adding it, or adding its runtime
> > > group, or when the sysfs firmware loader fallback fail to populate. In
> > > the last case, the device_del function will be called leading to
> > > attempt
> > > to remove the sysfs group. This patch will lookup for it in advance to
> > > grant that it is effectively there before cleaning it up.
> > > 
> > > Reported-by: syzbot+95f2e2439b97575ec3c0@syzkaller.appspotmail.com
> > > 
> > > Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
> > > ---
> > >  drivers/base/power/sysfs.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> > > index a1474fb67db9..6601729c4698 100644
> > > --- a/drivers/base/power/sysfs.c
> > > +++ b/drivers/base/power/sysfs.c
> > > @@ -834,5 +834,7 @@ void dpm_sysfs_remove(struct device *dev)
> > >  	dev_pm_qos_constraints_destroy(dev);
> > >  	rpm_sysfs_remove(dev);
> > >  	sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
> > > -	sysfs_remove_group(&dev->kobj, &pm_attr_group);
> > > +
> > > +	if (kernfs_find_and_get((&dev->kobj)->sd, pm_attr_group.name))
> > > +		sysfs_remove_group(&dev->kobj, &pm_attr_group);
> > 
> > What's to keep it from going away right after finding it?
> > 
> > In other words, what is wrong with removing a group that is not there?
> > What error happens?  It should be fine, or are you seeing real code
> > failures somewhere?
> 
>     No, this is just hitting a warning that sysbot complains about by
> setting panic on warning, no big deal, though it can be a wrong behaviour
> in ueagle-atm driver, since it defines to disconnect the device if the
> firmware is not there, no matter the sysfs fallback.

Then fix the driver please.

And what warning are you seeing exactly?

thanks,

greg k-h

  reply	other threads:[~2023-11-03 18:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 17:36 [PATCH] drivers core: lookup sysfs power group before removal José Pekkarinen
2023-11-01 17:36 ` José Pekkarinen
2023-11-01 17:54 ` Greg KH
2023-11-01 17:54   ` Greg KH
2023-11-03 17:49   ` José Pekkarinen
2023-11-03 17:49     ` José Pekkarinen
2023-11-03 18:36     ` Greg KH [this message]
2023-11-03 18:36       ` Greg KH
2023-11-07  8:56       ` José Pekkarinen
2023-11-07  8:56         ` José Pekkarinen
2023-11-07  9:53         ` Greg KH
2023-11-07  9:53           ` Greg KH
2023-11-07 17:20           ` José Pekkarinen
2023-11-07 17:20             ` José Pekkarinen

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=2023110353-bring-contented-c9f8@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=jose.pekkarinen@foxhound.fi \
    --cc=len.brown@intel.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=syzbot+95f2e2439b97575ec3c0@syzkaller.appspotmail.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.