From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@google.com>,
"David S. Miller" <davem@davemloft.net>,
Grant Likely <grant.likely@secretlab.ca>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Binbin Zhou" <zhoubinbin@loongson.cn>,
linux-sound@vger.kernel.org,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Grégory Clement" <gregory.clement@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>,
stable@vger.kernel.org
Subject: [PATCH 1/2] driver core: platform: turn pdev->id_auto into pdev->flags
Date: Tue, 18 Feb 2025 12:00:12 +0100 [thread overview]
Message-ID: <20250218-pdev-uaf-v1-1-5ea1a0d3aba0@bootlin.com> (raw)
In-Reply-To: <20250218-pdev-uaf-v1-0-5ea1a0d3aba0@bootlin.com>
struct platform_device->id_auto is the only boolean stored inside the
structure. Remove it and add an u8 flags field. The goal is to allow
more flags (without using more memory).
Cc: <stable@vger.kernel.org>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/base/platform.c | 6 +++---
include/linux/platform_device.h | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6f2a33722c5203ac196a6e36e153648d0fe6c6d4..e2284482c7ba7c12fe2ab3c715e7d1daa3f65021 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -682,7 +682,7 @@ int platform_device_add(struct platform_device *pdev)
if (ret < 0)
return ret;
pdev->id = ret;
- pdev->id_auto = true;
+ pdev->flags |= PLATFORM_DEVICE_FLAG_ID_AUTO;
dev_set_name(dev, "%s.%d.auto", pdev->name, pdev->id);
break;
}
@@ -720,7 +720,7 @@ int platform_device_add(struct platform_device *pdev)
return 0;
failed:
- if (pdev->id_auto) {
+ if (pdev->flags & PLATFORM_DEVICE_FLAG_ID_AUTO) {
ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
@@ -750,7 +750,7 @@ void platform_device_del(struct platform_device *pdev)
if (!IS_ERR_OR_NULL(pdev)) {
device_del(&pdev->dev);
- if (pdev->id_auto) {
+ if (pdev->flags & PLATFORM_DEVICE_FLAG_ID_AUTO) {
ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 074754c23d330c9a099e20eecfeb6cbd5025e04f..d842b21ba3791f974fa62f52bd160ef5820261c1 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -23,7 +23,8 @@ struct platform_device_id;
struct platform_device {
const char *name;
int id;
- bool id_auto;
+ u8 flags;
+#define PLATFORM_DEVICE_FLAG_ID_AUTO BIT(0)
struct device dev;
u64 platform_dma_mask;
struct device_dma_parameters dma_parms;
--
2.48.1
next prev parent reply other threads:[~2025-02-18 11:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 11:00 [PATCH 0/2] driver core: platform: avoid use-after-free on device name Théo Lebrun
2025-02-18 11:00 ` Théo Lebrun [this message]
2025-02-18 11:00 ` [PATCH 2/2] driver core: platform: avoid use-after-free on pdev->name Théo Lebrun
2025-02-20 12:41 ` [PATCH 0/2] driver core: platform: avoid use-after-free on device name Greg Kroah-Hartman
2025-02-20 13:31 ` Théo Lebrun
2025-02-20 14:06 ` Greg Kroah-Hartman
2025-02-20 15:46 ` Théo Lebrun
2025-02-20 16:19 ` Greg Kroah-Hartman
2025-02-20 18:26 ` Théo Lebrun
2025-02-20 18:55 ` Greg Kroah-Hartman
2025-02-21 8:46 ` Thomas Petazzoni
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=20250218-pdev-uaf-v1-1-5ea1a0d3aba0@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=stable@vger.kernel.org \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tiwai@suse.com \
--cc=vladimir.kondratiev@mobileye.com \
--cc=zhoubinbin@loongson.cn \
/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