All of lore.kernel.org
 help / color / mirror / Atom feed
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, linux-sound@vger.kernel.org,
	dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 24/31] driver core: Cover trust authorization and binding with KUnit
Date: Thu, 19 Nov 2026 19:29:43 +0000	[thread overview]
Message-ID: <sashiko-outbox-223910@kernel.org> (raw)
In-Reply-To: <20261118-device-trust-core-v3-24-d655875c4bfb@nvidia.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] driver core: unawaited kobject release in
  device_trust_no_iommu_bind_test()
- [Low] driver core: unexported device_trust_attr_group used in modular
  KUnit test
--

commit dfca1229adeb2c0936d6f6bd4451a35161f0f99d
Author: Leon Romanovsky <leon@kernel.org>

driver core: Cover trust authorization and binding with KUnit

This commit adds KUnit test suites covering device trust authorization,
driver binding serialization, and boot policy precedence.

> diff --git a/drivers/base/test/device-trust-test.c b/drivers/base/test/device-trust-test.c
> new file mode 100644
> index 0000000000000..c78eec9424f4f
> --- /dev/null
> +++ b/drivers/base/test/device-trust-test.c
> @@ -0,0 +1,2461 @@

[ ... ]

> +static void device_trust_test_sysfs_release(struct kobject *kobj)
> +{
> +	const struct device_trust_test_sysfs *sysfs =
> +		container_of(kobj->ktype, struct device_trust_test_sysfs, type);
> +	const struct kobj_type *original = sysfs->original;
> +
> +	kobj->ktype = original;
> +	kfree(sysfs);
> +	original->release(kobj);
> +}
> +
> +static int device_trust_test_isolate_sysfs(struct device *dev)
> +{
> +	struct device_trust_test_sysfs *sysfs;
> +
> +	sysfs = kzalloc_obj(*sysfs);
> +	if (!sysfs)
> +		return -ENOMEM;
> +	sysfs->original = dev->kobj.ktype;
> +	sysfs->type = *sysfs->original;
> +	sysfs->ops = *sysfs->original->sysfs_ops;
> +	sysfs->ops.store = device_trust_test_sysfs_store;
> +	sysfs->type.sysfs_ops = &sysfs->ops;
> +	sysfs->type.release = device_trust_test_sysfs_release;
> +	dev->kobj.ktype = &sysfs->type;
> +	return 0;
> +}

[ ... ]

> +static void device_trust_no_iommu_bind_test(struct kunit *test)
> +{
> +	struct platform_device *pdev;
> +	struct platform_driver *drv;
> +
> +	drv = kunit_kzalloc(test, sizeof(*drv), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_NULL(test, drv);
> +	drv->driver.name = test->name;
> +	drv->driver.probe_type = PROBE_FORCE_SYNCHRONOUS;
> +	drv->driver.suppress_bind_attrs = true;
> +	drv->probe = device_trust_platform_probe;
> +	pdev = kunit_platform_device_alloc(test, test->name, PLATFORM_DEVID_NONE);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
> +	KUNIT_ASSERT_EQ(test, device_trust_test_isolate_sysfs(&pdev->dev), 0);
> +	KUNIT_ASSERT_EQ(test, device_set_driver_override(&pdev->dev, "none"), 0);
> +	pdev->dev.trust_policy = DEVICE_TRUST_POLICY_BLOCKED;
> +	KUNIT_ASSERT_EQ(test, kunit_platform_device_add(test, pdev), 0);

[Severity: Medium]
Can device_trust_test_sysfs_release() run after the test module is
unloaded?

device_trust_test_isolate_sysfs() sets pdev->dev.kobj.ktype->release to
device_trust_test_sysfs_release().  Unlike
device_trust_test_device_unregister(), kunit_platform_device_add()'s
teardown calls platform_device_unregister(pdev) without waiting for the
kobject release callback to finish.  When CONFIG_DM_KUNIT_TEST=m and
kobject release is delayed (for example, under
CONFIG_DEBUG_KOBJECT_RELEASE=y), unloading the module allows
kobject_delayed_cleanup() to call into unmapped module memory.

[ ... ]

> +static bool device_trust_unrestricted_test_boot_rules(struct kunit *test,
> +						      bool *driver_rules,
> +						      enum device_trust_policy *default_policy)
> +{
> +#if IS_BUILTIN(CONFIG_DM_KUNIT_TEST)
> +	return device_trust_test_parse_boot_rules(test, saved_command_line,
> +						  driver_rules, default_policy);
> +#else
> +	kunit_skip(test, "boot policy coverage requires built-in tests");
> +	return false;
> +#endif
> +}

[ ... ]

> +static void device_trust_sysfs_boot_policy_test(struct kunit *test)
> +{
> +	struct device_trust_test_context *ctx;
> +	struct device_attribute *attr = NULL;
> +	struct attribute **attrs;
> +	enum device_trust_policy policy, target, default_policy;
> +	const char *value;
> +	bool configured, driver_rules, allowed, override;
> +	ssize_t ret;
> +
> +	configured = device_trust_unrestricted_test_boot_rules(test, &driver_rules,
> +							     &default_policy);
> +	ctx = device_trust_unrestricted_test_register(test, &device_trust_test_plain_bus, NULL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> +	policy = ctx->dev.trust_policy;
> +	override = ctx->dev.p->trust_policy_override;
> +	for (attrs = device_trust_attr_group.attrs; *attrs; attrs++) {

[Severity: Low]
Can referencing device_trust_attr_group fail modpost when
CONFIG_DM_KUNIT_TEST=m?

device_trust_attr_group in drivers/base/trust.c is not exported with
EXPORT_SYMBOL_IF_KUNIT().  When CONFIG_DM_KUNIT_TEST=m, avoiding an
undefined symbol reference here relies on the compiler inlining
device_trust_unrestricted_test_boot_rules() and eliminating the code after
kunit_skip().  Either exporting device_trust_attr_group with
EXPORT_SYMBOL_IF_KUNIT() or guarding device_trust_sysfs_boot_policy_test()
with #if IS_BUILTIN(CONFIG_DM_KUNIT_TEST) (like
device_trust_unrestricted_boot_policy_test()) would avoid this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-device-trust-core-v3-0-d655875c4bfb@nvidia.com?part=24

  reply	other threads:[~2026-11-19 19:29 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 19:26 [PATCH v3 00/31] driver core: Authorize device trust before driver binding Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 01/31] wifi: mac80211_hwsim: lock device for manual " Leon Romanovsky
2026-11-19  0:32   ` driver core: Authorize device trust before " bluez.test.bot
2026-11-19 19:29   ` [PATCH v3 01/31] wifi: mac80211_hwsim: lock device for manual " sashiko-bot
2026-11-18 19:26 ` [PATCH v3 02/31] Bluetooth: btusb: Fix MediaTek ISO claim locking Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 03/31] USB: Lock interfaces during manual driver binding Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 04/31] USB: serial: Register USB drivers with their owning module Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 05/31] USB: Reject claims of DT-disabled interfaces Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 06/31] USB: Release interface claims according to binding state Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 07/31] USB: Reject claims after interface registration failure Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 08/31] ALSA: usb-audio: Release interface claims when probe fails Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 09/31] USB: Pin modules for unregistered interface claims Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 10/31] USB: Add helpers to release unpublished " Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 11/31] USB: Unwind interface claims after registration or binding failure Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 12/31] PNP: Attach card devices through the driver core Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 13/31] cdx: Propagate DMA configuration errors Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 14/31] driver core: Report deferred probes through sysfs drivers_probe Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 15/31] driver core: Add a compatibility API for manual driver attachment Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 16/31] Input: gameport - use the compatibility driver attachment API Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 17/31] Input: serio " Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 18/31] net: phy: Use " Leon Romanovsky
2026-11-18 20:21   ` Andrew Lunn
2026-11-19  7:18     ` Leon Romanovsky
2026-11-19 13:30       ` Andrew Lunn
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 19/31] driver core: Introduce a generic device trust level Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 20/31] driver core: Expose device trust authorization interfaces Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 21/31] driver core: Accept device trust policy on the kernel command line Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 22/31] driver core: Accept device trust policy by driver name Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 23/31] driver core: Expose committed device trust level Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 24/31] driver core: Cover trust authorization and binding with KUnit Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot [this message]
2026-11-18 19:26 ` [PATCH v3 25/31] driver core: Document trust admission and initrd authorization Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 26/31] PCI: Use device trust for platform restrictions Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 27/31] iommu: Use device trust for DMA restrictions Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 28/31] driver core: Allow driver attachment with the device lock held Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 29/31] USB: Retain the result of configuration requests Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:27 ` [PATCH v3 30/31] USB: Authorize interfaces through device trust Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:27 ` [PATCH v3 31/31] USB: Authorize devices " Leon Romanovsky
2026-11-19 19:29   ` 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-223910@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-sound@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.