From: Vincent Whitchurch <Vincent.Whitchurch@axis.com>
To: "sre@kernel.org" <sre@kernel.org>,
Vincent Whitchurch <Vincent.Whitchurch@axis.com>
Cc: "mazziesaccount@gmail.com" <mazziesaccount@gmail.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
kernel <kernel@axis.com>,
"linus.walleij@linaro.org" <linus.walleij@linaro.org>
Subject: Re: [PATCH] power: supply: Fix info use-after-free
Date: Tue, 19 Sep 2023 07:33:01 +0000 [thread overview]
Message-ID: <11d30081b64935c2c3d45e5197cabbc25082a3fe.camel@axis.com> (raw)
In-Reply-To: <20230918150438.4pliix4fhbpjld3l@mercury.elektranox.org>
On Mon, 2023-09-18 at 17:04 +0200, Sebastian Reichel wrote:
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 06e5b6b0e255..d483a81560ab 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -482,6 +482,13 @@ int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env)
> if (ret)
> return ret;
>
>
> + /*
> + * Kernel generates KOBJ_REMOVE uevent in device removal path, after
> + * resources have been freed. Exit early to avoid use-after-free.
> + */
> + if (psy->removing)
> + return 0;
> +
> prop_buf = (char *)get_zeroed_page(GFP_KERNEL);
> if (!prop_buf)
> return -ENOMEM;
>
> That would also cover the no-parent-device part and avoid the
> device(s) being queried for data at device removal time, which
> wouldn't work if the device removal happens due to a hot-unplug.
Works for me.
Tested-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
next prev parent reply other threads:[~2023-09-19 7:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 7:33 Vincent Whitchurch
2023-09-18 15:04 ` Sebastian Reichel
2023-09-19 7:33 ` Vincent Whitchurch [this message]
2023-09-19 12:27 ` Sebastian Reichel
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=11d30081b64935c2c3d45e5197cabbc25082a3fe.camel@axis.com \
--to=vincent.whitchurch@axis.com \
--cc=kernel@axis.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=sre@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®