From: sashiko-bot@kernel.org
To: vigneshr@ti.com, "Orgad Shaneh" <orgads@gmail.com>,
miquel.raynal@bootlin.com, tsbogend@alpha.franken.de,
richard@nod.at
Cc: linusw@kernel.org, corbet@lwn.net, linux-mips@vger.kernel.org,
linux-mtd@lists.infradead.org, john@phrozen.org,
kaloz@openwrt.org, ulli.kroll@googlemail.com, nico@fluxnic.net,
dwmw2@infradead.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps
Date: Sat, 10 Oct 2026 17:31:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-166777@kernel.org> (raw)
In-Reply-To: <20261010172142.2138956-3-orgads@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mtd: cfi_cmdset_0002: unbounded TASK_UNINTERRUPTIBLE sleep causes Hung Task Panic
--
commit 97c2e746b1f52c7744c56b40bf00fe410dca196f
Author: Orgad Shaneh <orgads@gmail.com>
mtd: cfi_cmdset_0002: implement point() for simple linear maps
This commit adds point() and unpoint() support for simple linear maps to
the cfi_cmdset_0002 driver. This allows filesystems like jffs2 or cramfs
to scan memory in place without copying every used eraseblock. When a chip
is pointed to, writes, erases, and sync operations wait for the unpoint.
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index 517db2f2707f4..67578fef02bfa 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
[ ... ]
> @@ -960,8 +980,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
> return -EIO;
>
> case FL_POINT:
> - /* Only if there's no operation suspended... */
> - if (mode == FL_READY && chip->oldstate == FL_READY)
> + /*
> + * Only if there's no operation suspended: the chip is in
> + * array mode, so reads, further points and the reboot
> + * reset (which only re-enters array mode) can go ahead.
> + */
> + if ((mode == FL_READY || mode == FL_POINT ||
> + mode == FL_SHUTDOWN) && chip->oldstate == FL_READY)
> return 0;
> fallthrough;
[Severity: High]
Does this logic in get_chip() cause unintended blocking when the chip has a
suspended operation?
If a filesystem like CramFS mounts an MTD partition and calls mtd_point(),
chip->state becomes FL_POINT indefinitely until unmount. If this point
happens while an erase is suspended (chip->oldstate == FL_ERASING),
requests for FL_READY or FL_SHUTDOWN will fail the check for
chip->oldstate == FL_READY.
They will then fall through to the default sleep path. Because the point is
held indefinitely by the filesystem, could this cause the reboot notifier
(FL_SHUTDOWN) to deadlock permanently?
> default:
> sleep:
> set_current_state(TASK_UNINTERRUPTIBLE);
> add_wait_queue(&chip->wq, &wait);
> mutex_unlock(&chip->mutex);
> schedule();
> remove_wait_queue(&chip->wq, &wait);
> mutex_lock(&chip->mutex);
> goto resettime;
[Severity: High]
Is it safe to use TASK_UNINTERRUPTIBLE for unbounded synchronization here?
When chip->state is FL_POINT (held long-term by a mounted filesystem), and
another task initiates a flash write, erase, or sync, get_chip() is called
with FL_WRITING, FL_ERASING, or FL_SYNCING. These modes do not match the
FL_POINT exceptions and fall through directly to this sleep block.
Since FL_POINT won't be released until the filesystem is unmounted, tasks
sleeping here will remain in TASK_UNINTERRUPTIBLE indefinitely. Could this
cause a hung task panic after the standard 120-second timeout, allowing a
local user to crash the system simply by running sync(2) while CramFS is
mounted?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010172142.2138956-1-orgads@gmail.com?part=2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: vigneshr@ti.com, "Orgad Shaneh" <orgads@gmail.com>,
miquel.raynal@bootlin.com, tsbogend@alpha.franken.de,
richard@nod.at
Cc: linusw@kernel.org, corbet@lwn.net, linux-mips@vger.kernel.org,
linux-mtd@lists.infradead.org, john@phrozen.org,
kaloz@openwrt.org, ulli.kroll@googlemail.com, nico@fluxnic.net,
dwmw2@infradead.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps
Date: Sat, 10 Oct 2026 17:31:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-166777@kernel.org> (raw)
In-Reply-To: <20261010172142.2138956-3-orgads@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mtd: cfi_cmdset_0002: unbounded TASK_UNINTERRUPTIBLE sleep causes Hung Task Panic
--
commit 97c2e746b1f52c7744c56b40bf00fe410dca196f
Author: Orgad Shaneh <orgads@gmail.com>
mtd: cfi_cmdset_0002: implement point() for simple linear maps
This commit adds point() and unpoint() support for simple linear maps to
the cfi_cmdset_0002 driver. This allows filesystems like jffs2 or cramfs
to scan memory in place without copying every used eraseblock. When a chip
is pointed to, writes, erases, and sync operations wait for the unpoint.
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index 517db2f2707f4..67578fef02bfa 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
[ ... ]
> @@ -960,8 +980,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
> return -EIO;
>
> case FL_POINT:
> - /* Only if there's no operation suspended... */
> - if (mode == FL_READY && chip->oldstate == FL_READY)
> + /*
> + * Only if there's no operation suspended: the chip is in
> + * array mode, so reads, further points and the reboot
> + * reset (which only re-enters array mode) can go ahead.
> + */
> + if ((mode == FL_READY || mode == FL_POINT ||
> + mode == FL_SHUTDOWN) && chip->oldstate == FL_READY)
> return 0;
> fallthrough;
[Severity: High]
Does this logic in get_chip() cause unintended blocking when the chip has a
suspended operation?
If a filesystem like CramFS mounts an MTD partition and calls mtd_point(),
chip->state becomes FL_POINT indefinitely until unmount. If this point
happens while an erase is suspended (chip->oldstate == FL_ERASING),
requests for FL_READY or FL_SHUTDOWN will fail the check for
chip->oldstate == FL_READY.
They will then fall through to the default sleep path. Because the point is
held indefinitely by the filesystem, could this cause the reboot notifier
(FL_SHUTDOWN) to deadlock permanently?
> default:
> sleep:
> set_current_state(TASK_UNINTERRUPTIBLE);
> add_wait_queue(&chip->wq, &wait);
> mutex_unlock(&chip->mutex);
> schedule();
> remove_wait_queue(&chip->wq, &wait);
> mutex_lock(&chip->mutex);
> goto resettime;
[Severity: High]
Is it safe to use TASK_UNINTERRUPTIBLE for unbounded synchronization here?
When chip->state is FL_POINT (held long-term by a mounted filesystem), and
another task initiates a flash write, erase, or sync, get_chip() is called
with FL_WRITING, FL_ERASING, or FL_SYNCING. These modes do not match the
FL_POINT exceptions and fall through directly to this sleep block.
Since FL_POINT won't be released until the filesystem is unmounted, tasks
sleeping here will remain in TASK_UNINTERRUPTIBLE indefinitely. Could this
cause a hung task panic after the standard 120-second timeout, allowing a
local user to crash the system simply by running sync(2) while CramFS is
mounted?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010172142.2138956-1-orgads@gmail.com?part=2
next prev parent reply other threads:[~2026-10-10 17:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 17:21 [PATCH 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 17:21 ` Orgad Shaneh
2026-10-10 17:21 ` [PATCH 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 17:21 ` Orgad Shaneh
2026-10-10 17:21 ` [PATCH 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 17:21 ` Orgad Shaneh
2026-10-10 17:31 ` sashiko-bot [this message]
2026-10-10 17:31 ` sashiko-bot
2026-10-10 17:21 ` [PATCH 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 17:21 ` Orgad Shaneh
2026-10-10 17:32 ` sashiko-bot
2026-10-10 17:32 ` sashiko-bot
2026-10-10 18:08 ` [PATCH v2 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 18:08 ` Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 18:08 ` Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 18:08 ` Orgad Shaneh
2026-10-10 18:18 ` sashiko-bot
2026-10-10 18:18 ` sashiko-bot
2026-10-10 18:08 ` [PATCH v2 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 18:08 ` Orgad Shaneh
2026-10-10 18:18 ` sashiko-bot
2026-10-10 18:18 ` sashiko-bot
2026-10-11 6:29 ` [PATCH v3 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-11 6:29 ` Orgad Shaneh
2026-10-11 6:29 ` [PATCH v3 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-11 6:29 ` Orgad Shaneh
2026-10-11 6:29 ` [PATCH v3 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-11 6:29 ` Orgad Shaneh
2026-10-11 6:29 ` [PATCH v3 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-11 6:29 ` Orgad Shaneh
2026-10-11 6:39 ` sashiko-bot
2026-10-11 6:39 ` 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-166777@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=corbet@lwn.net \
--cc=dwmw2@infradead.org \
--cc=john@phrozen.org \
--cc=kaloz@openwrt.org \
--cc=linusw@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=nico@fluxnic.net \
--cc=orgads@gmail.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tsbogend@alpha.franken.de \
--cc=ulli.kroll@googlemail.com \
--cc=vigneshr@ti.com \
/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.