From: sashiko-bot@kernel.org
To: "Leon Romanovsky" <leon@kernel.org>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
linux-pci@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 16/19] driver core: Cover trust authorization and binding with KUnit
Date: Tue, 10 Nov 2026 07:35:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-206516@kernel.org> (raw)
In-Reply-To: <20261109-device-trust-core-v2-16-3b12d9a9f861@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] driver core: unskipped driver boot rules in device-trust-full
KUnit tests
--
commit 8b5fffad66e1e6c0223d2943cea1b5d209f585ac
Author: Leon Romanovsky <leon@kernel.org>
driver core: Cover trust authorization and binding with KUnit
This commit adds KUnit test suites covering device trust policy parsing,
authorization, driver binding, and full-only manual attachment.
> diff --git a/drivers/base/test/device-trust-test.c b/drivers/base/test/device-trust-test.c
> new file mode 100644
> index 0000000000000..b6ad3b0c1b536
> --- /dev/null
> +++ b/drivers/base/test/device-trust-test.c
[ ... ]
> +static void device_trust_full_boot_policy_test(struct kunit *test)
> +{
> +#if IS_BUILTIN(CONFIG_DM_KUNIT_TEST)
> + struct device_trust_test_context *ctx;
> + enum device_trust_policy policy;
> + bool allowed;
> + int ret;
> +
> + ctx = device_trust_full_test_register(test, &device_trust_test_plain_bus, NULL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> + policy = ctx->dev.trust_policy;
> + allowed = device_trust_test_global_full(test) &&
> + (policy == DEVICE_TRUST_POLICY_DEFAULT || policy == DEVICE_TRUST_POLICY_FULL) &&
> + (!device_trust_full_test_driver_rules(test) ||
> + ctx->dev.p->trust_policy_override);
> +
> + ret = device_driver_attach_full(&ctx->drv, &ctx->dev);
> + KUNIT_ASSERT_EQ(test, ret, allowed ? 0 : -EPERM);
> + KUNIT_EXPECT_EQ(test, device_is_bound(&ctx->dev), allowed);
> + KUNIT_EXPECT_EQ(test, ctx->probe_count, allowed ? 1 : 0);
> + KUNIT_EXPECT_EQ(test, ctx->configure_count, 0);
> + KUNIT_EXPECT_EQ(test, ctx->dev.trust_policy, policy);
> + KUNIT_EXPECT_EQ(test, device_get_trust_level(&ctx->dev),
> + allowed ? DEVICE_TRUST_FULL : DEVICE_TRUST_DISABLED);
> + KUNIT_EXPECT_EQ(test, device_get_committed_trust_level(&ctx->dev),
> + allowed ? DEVICE_TRUST_FULL : DEVICE_TRUST_DISABLED);
> + if (!allowed)
> + KUNIT_EXPECT_PTR_EQ(test, ctx->dev.driver, NULL);
> +#else
> + kunit_skip(test, "boot policy coverage requires built-in tests");
> +#endif
> +}
> +
> +static void device_trust_full_attach_test(struct kunit *test)
> +{
> + struct device_trust_test_context *ctx;
> + struct device *parent;
> + int ret;
> +
> + if (!device_trust_test_global_full(test))
> + kunit_skip(test, "requires device_trust.default=full");
> + parent = root_device_register(test->name);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent);
> + ret = kunit_add_action_or_reset(test,
> + device_trust_test_parent_unregister, parent);
> + KUNIT_ASSERT_EQ(test, ret, 0);
> + ctx = device_trust_full_test_register(test, &device_trust_test_plain_bus, parent);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> +
> + device_lock(parent);
> + device_lock(&ctx->dev);
> + ret = device_driver_attach_full(&ctx->drv, &ctx->dev);
> + device_unlock(&ctx->dev);
> + device_unlock(parent);
> + KUNIT_ASSERT_EQ(test, ret, 0);
[ ... ]
> +static void device_trust_full_probe_failure_test(struct kunit *test)
> +{
> + static const int errors[] = { -EIO, -EPROBE_DEFER };
> + static const int expected[] = { -EIO, -EAGAIN };
> + struct device_trust_test_context *ctx;
> + int i;
> +
> + if (!device_trust_test_global_full(test))
> + kunit_skip(test, "requires device_trust.default=full");
> + ctx = device_trust_full_test_register(test, &device_trust_test_plain_bus, NULL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> + ctx->drv.probe = device_trust_full_test_probe;
> +
> + for (i = 0; i < ARRAY_SIZE(errors); i++) {
> + ctx->probe_ret = errors[i];
> + KUNIT_ASSERT_EQ(test, device_driver_attach_full(&ctx->drv, &ctx->dev),
> + expected[i]);
[Severity: Low]
Should device_trust_full_attach_test() and
device_trust_full_probe_failure_test() also skip when device_trust.driver=
boot rules disallow full attachment?
Unlike device_trust_full_boot_policy_test(), both tests only check
device_trust_test_global_full(), which inspects device_trust_init() on a
stub device. When the kernel is booted with both device_trust.default=full
and a device_trust.driver= rule, device_trust_prepare_full() rejects the
unoverridden test device with -EPERM, causing the device_driver_attach_full()
assertions in both tests to fail instead of skipping.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-device-trust-core-v2-0-3b12d9a9f861@nvidia.com?part=16
next prev parent reply other threads:[~2026-11-10 7:35 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 7:33 [PATCH v2 00/19] driver core: Authorize device trust before driver binding Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 01/19] Input: gameport - attach manual drivers through the driver core Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 02/19] wifi: mac80211_hwsim: lock device for manual driver binding Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 03/19] USB: Lock registered interfaces during " Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 14:19 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 04/19] USB: Release interface claims refused during registration Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 14:23 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 05/19] PNP: Attach card devices through the driver core Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 06/19] cdx: Propagate DMA configuration errors Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 07/19] driver core: Report deferred probes through sysfs drivers_probe Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 08/19] driver core: Add a compatibility API for manual driver attachment Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 09/19] Input: serio - use the compatibility driver attachment API Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 14:29 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 10/19] net: phy: Use " Leon Romanovsky
2026-11-09 13:45 ` Andrew Lunn
2026-11-10 7:39 ` Leon Romanovsky
2026-11-10 14:31 ` Andrew Lunn
2026-11-10 14:58 ` Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 11/19] driver core: Introduce a generic device trust level Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 15:12 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 12/19] driver core: Expose device trust authorization interfaces Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 13/19] driver core: Accept device trust policy on the kernel command line Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 14/19] driver core: Accept device trust policy by driver name Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 15/19] driver core: Expose committed device trust level Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 16/19] driver core: Cover trust authorization and binding with KUnit Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot [this message]
2026-11-09 7:33 ` [PATCH v2 17/19] driver core: Document trust admission and initrd authorization Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 18/19] PCI: Replace untrusted state with device trust Leon Romanovsky
2026-11-09 13:53 ` Robin Murphy
2026-11-10 12:22 ` Leon Romanovsky
2026-11-10 14:25 ` Jason Gunthorpe
2026-11-10 14:34 ` Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 19/19] USB: Authorize devices and interfaces through " Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
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=sashiko-outbox-206516@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=leon@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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