From: sashiko-bot@kernel.org
To: "Nathan Lynch" <nathan.lynch@amd.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH 4/4] dmaengine: dmatest: Optionally make test errors fatal
Date: Wed, 22 Jul 2026 16:33:26 +0000 [thread overview]
Message-ID: <20260722163327.20F1F1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260722-dmatest-fixes-and-fatal-errors-v1-4-8287709987ea@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A Time-of-Check to Time-of-Use (TOCTOU) race condition on `info->params.fatal_errors` can cause an unintended kernel panic when the parameter is concurrently set to 0 ('never panic').
--
--- Patch [4]: [PATCH 4/4] dmaengine: dmatest: Optionally make test errors fatal ---
commit 289cdfd12c204ee46d7f18f6c08608f36bd53956
Author: Nathan Lynch <nathan.lynch@amd.com>
dmaengine: dmatest: Optionally make test errors fatal
This commit adds a module parameter fatal_errors to dmatest. When set to a
non-zero value, the kernel will panic after accumulating that many test errors
during a run.
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 0d7752c2451a9..a070ce6f2fa94 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
[ ... ]
> @@ -487,6 +497,24 @@ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
> dbg_result(err, n, src_off, dst_off, len, data);\
> })
>
> +/*
> + * Record a test error whose details were just logged via result(). When
> + * fatal_errors is set, panic once that many errors have accumulated in the
> + * current run.
> + */
> +static void dmatest_note_error(struct dmatest_info *info)
> +{
> + unsigned int errors;
> +
> + if (!info->params.fatal_errors)
> + return;
> +
> + errors = atomic_inc_return(&info->error_count);
> + if (errors >= info->params.fatal_errors)
> + panic("dmatest: fatal_errors=%u and %u error(s) encountered\n",
> + info->params.fatal_errors, errors);
[Severity: High]
Can a concurrent modification of the fatal_errors parameter cause a spurious
kernel panic here?
If a user modifies the fatal_errors parameter to 0 (meaning 'never panic') via
sysfs while test threads are executing, info->params.fatal_errors could be
concurrently overwritten with 0 via add_threaded_test().
If this happens between the initial check and the second read:
CPU1 in dmatest_note_error()
if (!info->params.fatal_errors) // reads > 0
return;
errors = atomic_inc_return(&info->error_count); // acts as a barrier
CPU2 modifying sysfs
info->params.fatal_errors = 0;
CPU1 in dmatest_note_error()
if (errors >= info->params.fatal_errors) // reads 0
Will the condition errors >= 0 evaluate to true and inadvertently trigger the
panic? Could we read info->params.fatal_errors into a local variable once to
prevent this race?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com?part=4
next prev parent reply other threads:[~2026-07-22 16:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 15:47 [PATCH 0/4] dmatest: shared channel fixes and fatal errors option Nathan Lynch via B4 Relay
2026-07-22 15:47 ` [PATCH 1/4] dmaengine: dmatest: Don't forcibly terminate channel in polled mode Nathan Lynch via B4 Relay
2026-07-22 15:57 ` sashiko-bot
2026-07-22 15:47 ` [PATCH 2/4] dmaengine: dmatest: Suppress bogus failures when stopping a run Nathan Lynch via B4 Relay
2026-07-22 16:09 ` sashiko-bot
2026-07-22 15:47 ` [PATCH 3/4] dmaengine: dmatest: Terminate channel before freeing threads Nathan Lynch via B4 Relay
2026-07-22 16:23 ` sashiko-bot
2026-07-22 15:47 ` [PATCH 4/4] dmaengine: dmatest: Optionally make test errors fatal Nathan Lynch via B4 Relay
2026-07-22 16:33 ` sashiko-bot [this message]
2026-07-22 19:58 ` Tycho Andersen
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=20260722163327.20F1F1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=nathan.lynch@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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