Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinseob Kim" <kimjinseob88@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v10 7/8] iio: osf: add core KUnit tests
Date: Fri, 18 Sep 2026 19:09:53 +0000	[thread overview]
Message-ID: <20260918190954.515801F000FF@smtp.kernel.org> (raw)
In-Reply-To: <6915383a4a73b680e357d1a75106e0cf6e413084.1789753020.git.kimjinseob88@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] kunit: UAF in osf_session_producer due to missing kthread lifecycle action
- [Medium] kunit: mutex re-initialization in osf_test_new_session
--

commit b82aa72688edb8c728c31226b6fec70af9389122
Author: Jinseob Kim <kimjinseob88@gmail.com>

iio: osf: add core KUnit tests

This commit adds core regression test cases for frame handling, sample-cache
admission, and other operations for the Open Sensor Fusion IIO device.
It introduces KUnit configuration and build wiring to exercise these paths.

> diff --git a/drivers/iio/opensensorfusion/osf_core_test.c b/drivers/iio/opensensorfusion/osf_core_test.c
> new file mode 100644
> index 0000000000000..d96753ab2a458
> --- /dev/null
> +++ b/drivers/iio/opensensorfusion/osf_core_test.c

[ ... ]

> +static void osf_test_new_session(struct osf_test_context *ctx)
> +{
> +	osf_test_cleanup(ctx);
> +	osf_core_init(&ctx->osf, ctx->dev);

[Severity: Medium]
Does this code trigger a debugobjects warning by re-initializing an active
mutex?

osf_core_init() performs the following operations:

drivers/iio/opensensorfusion/osf_core.c:osf_core_init() {
	*osf = (struct osf_device) {
		.dev = dev,
	};
	mutex_init(&osf->latest_lock);
}

By wiping the osf_device structure and calling mutex_init() again on
latest_lock without first calling mutex_destroy(), this can cause debugobjects
to emit an init active warning.

Could a cleanup of the old mutex be added, or the re-initialization avoided?

> +	osf_core_start(&ctx->osf);
> +	ctx->indio_dev = NULL;
> +	ctx->buffer = NULL;
> +}

[ ... ]

> +static void osf_session_fault_buffer_race_test(struct kunit *test)
> +{
> +	struct osf_test_context *ctx = test->priv;

[ ... ]

> +	producer = kthread_run(osf_session_producer, race, "osf-session-test");
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, producer);

[Severity: Medium]
Can this kthread leak and cause a use-after-free if the KUnit test is aborted
prematurely?

If the test is aborted due to a KUnit timeout or an unhandled signal, the
manual kthread_stop() at the end of the test will be bypassed. The KUnit
framework will then free the race structure, but osf_session_producer will
continue running in the background.

When the background thread subsequently accesses race->rx_lock or race->ctx,
it will access freed memory and potentially crash the kernel.

Could kunit_add_action() be used to guarantee the termination of the kthread
during test cleanup?

> +	KUNIT_EXPECT_NE(test, wait_for_completion_timeout(&race->started, HZ), 0UL);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789753020.git.kimjinseob88@gmail.com?part=7

  reply	other threads:[~2026-09-18 19:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 18:24 [PATCH v10 0/8] iio: add Open Sensor Fusion UART support Jinseob Kim
2026-09-18 18:24 ` [PATCH v10 1/8] dt-bindings: iio: add Open Sensor Fusion device Jinseob Kim
2026-09-18 18:34   ` sashiko-bot
2026-09-20  1:14   ` Jonathan Cameron
2026-09-20  4:01     ` Kim Jinseob
2026-09-18 18:24 ` [PATCH v10 2/8] Documentation: iio: add Open Sensor Fusion driver overview Jinseob Kim
2026-09-20  1:12   ` Jonathan Cameron
2026-09-20  3:57     ` Kim Jinseob
2026-09-18 18:24 ` [PATCH v10 3/8] iio: osf: add protocol decoding Jinseob Kim
2026-09-20  1:27   ` Jonathan Cameron
2026-09-20  4:12     ` Kim Jinseob
2026-09-18 18:24 ` [PATCH v10 4/8] iio: osf: add validated stream parser Jinseob Kim
2026-09-20  1:30   ` Jonathan Cameron
2026-09-20  4:12     ` Kim Jinseob
2026-09-20 17:09       ` Jonathan Cameron
2026-09-18 18:24 ` [PATCH v10 5/8] iio: osf: add UART transport and core receive path Jinseob Kim
2026-09-20  1:40   ` Jonathan Cameron
2026-09-18 18:24 ` [PATCH v10 6/8] iio: osf: add IIO devices from capability reports Jinseob Kim
2026-09-20  2:03   ` Jonathan Cameron
2026-09-20  4:20     ` Kim Jinseob
2026-09-20  5:07       ` Kim Jinseob
2026-09-20 17:17         ` Jonathan Cameron
2026-09-18 18:24 ` [PATCH v10 7/8] iio: osf: add core KUnit tests Jinseob Kim
2026-09-18 19:09   ` sashiko-bot [this message]
2026-09-20  2:12   ` Jonathan Cameron
2026-09-18 18:24 ` [PATCH v10 8/8] iio: osf: add IIO " Jinseob Kim
2026-09-18 19:28   ` sashiko-bot
2026-09-20  2:18   ` Jonathan Cameron
2026-09-20  2:05 ` [PATCH v10 0/8] iio: add Open Sensor Fusion UART support Jonathan Cameron
2026-09-20  4:22   ` Kim Jinseob
2026-09-20 17:05     ` Jonathan Cameron

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=20260918190954.515801F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kimjinseob88@gmail.com \
    --cc=robh@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