[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250923075302.591026-8-tzungbi@kernel.org>
Date: Tue, 23 Sep 2025 07:53:02 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Benson Leung <bleung@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>
Cc: Jonathan Corbet <corbet@....net>,
Shuah Khan <shuah@...nel.org>,
Dawid Niedzwiecki <dawidn@...gle.com>,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
chrome-platform@...ts.linux.dev,
linux-kselftest@...r.kernel.org,
tzungbi@...nel.org,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Bartosz Golaszewski <brgl@...ev.pl>,
Wolfram Sang <wsa+renesas@...g-engineering.com>
Subject: [PATCH v4 7/7] platform/chrome: cros_ec_chardev: Secure cros_ec_device via revocable
Miscdevice now supports revocable fops replacement. Use it to secure
the cros_ec_device.
Signed-off-by: Tzung-Bi Shih <tzungbi@...nel.org>
---
PoC patch.
v4:
- New in the series.
drivers/platform/chrome/cros_ec_chardev.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index c9d80ad5b57e..cacc73635d6b 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -166,7 +166,6 @@ static int cros_ec_chardev_open(struct inode *inode, struct file *filp)
if (!priv)
return -ENOMEM;
- priv->ec_dev = ec_dev;
priv->cmd_offset = ec->cmd_offset;
filp->private_data = priv;
INIT_LIST_HEAD(&priv->events);
@@ -370,6 +369,18 @@ static const struct file_operations chardev_fops = {
#endif
};
+static int cros_ec_chardev_rev_try_access(struct revocable *rev, void *data)
+{
+ struct chardev_priv *priv = data;
+
+ priv->ec_dev = revocable_try_access(rev);
+ return priv->ec_dev ? 0 : -ENODEV;
+}
+
+static const struct revocable_operations cros_ec_chardev_rops = {
+ .try_access = cros_ec_chardev_rev_try_access,
+};
+
static int cros_ec_chardev_probe(struct platform_device *pdev)
{
struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
@@ -385,6 +396,8 @@ static int cros_ec_chardev_probe(struct platform_device *pdev)
misc->fops = &chardev_fops;
misc->name = ec_platform->ec_name;
misc->parent = pdev->dev.parent;
+ misc->rp = ec->ec_dev->revocable_provider;
+ misc->rops = &cros_ec_chardev_rops;
dev_set_drvdata(&pdev->dev, misc);
--
2.51.0.534.gc79095c0ca-goog
Powered by blists - more mailing lists