From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Andreas Kemnade <andreas@kemnade.info>
Cc: sre@kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, hns@goldelico.com,
stable@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>
Subject: Re: [PATCH] power: supply: sysfs: enable is_writeable check during sysfs creation
Date: Sat, 14 Sep 2024 10:28:16 +0200 [thread overview]
Message-ID: <e76a8e70-1a0c-4242-ba96-07590e02c221@t-8ch.de> (raw)
In-Reply-To: <20240914081523.798940-1-andreas@kemnade.info>
Hi Andreas,
On 2024-09-14 10:15:23+0000, Andreas Kemnade wrote:
> The files in sysfs are created during device_add(). psy->use_cnt
> is not incremented yet. So attributes are created readonly
> without checking desc->property_is_writeable() and writeable
> files are readonly.
>
> To fix this, revert back to calling desc->property_is_writeable()
> directly without using the helper.
Hans noticed the same issue, but fixed it differently [0].
The problem is that the hwmon registration also uses
power_supply_property_is_writeable() and has the same issue.
(Independently from my change)
IMO this is the better fix.
(Plus the renaming and unexporting of the function that I'll add if it
won't be part of the first fix)
[0] https://lore.kernel.org/all/20240908185337.103696-1-hdegoede@redhat.com/
> Fixes: be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()")
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> Cc: stable@vger.kernel.org # 6.11
> ---
> drivers/power/supply/power_supply_sysfs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 3e63d165b2f70..b86e11bdc07ef 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -379,7 +379,8 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,
> int property = psy->desc->properties[i];
>
> if (property == attrno) {
> - if (power_supply_property_is_writeable(psy, property) > 0)
> + if (psy->desc->property_is_writeable &&
> + psy->desc->property_is_writeable(psy, property) > 0)
> mode |= S_IWUSR;
>
> return mode;
> --
> 2.39.2
>
prev parent reply other threads:[~2024-09-14 8:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-14 8:15 Andreas Kemnade
2024-09-14 8:28 ` Thomas Weißschuh [this message]
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=e76a8e70-1a0c-4242-ba96-07590e02c221@t-8ch.de \
--to=linux@weissschuh.net \
--cc=andreas@kemnade.info \
--cc=hdegoede@redhat.com \
--cc=hns@goldelico.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®