All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers
@ 2026-11-23  5:50 ` ping.li
  0 siblings, 0 replies; 66+ messages in thread
From: ping.li @ 2026-11-23  5:50 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr; +Cc: linux-mtd, linux-kernel, Ping Li

From: Ping Li <leeonion.muyu@gmail.com>

While discussing a proposal to also allocate the mtdchar read/write
bounce buffers with kvmalloc() [1], an audit showed that three raw
NAND controllers DMA the buffers handed by the NAND core without
declaring NAND_USES_DMA, so nand_base never bounces non-linear-map
buffers for them (see the use_bounce_buf logic in
nand_do_read_ops()/nand_do_write_ops()).

The exposure predates that proposal: since the MEMREAD/MEMWRITE
ioctls were converted to kvmalloc() (83208e106a8e8), a heavily
fragmented system can already feed a vmalloc'd buffer into their
dma_map_single() calls, which is not a valid input for
non-linear-map addresses.

fsmc and intel have no protection at all; declaring
NAND_USES_DMA lets nand_base bounce through chip->data_buf as
the other DMA-capable controllers (arasan, denali, meson, mtk,
nuvoton...) already do.  r852 has an internal bounce buffer but
only checks alignment; a virt_addr_valid() check extends it to
cover non-linear-map buffers too.

These fixes are independent of the direction taken in [1].

[1] https://lore.kernel.org/linux-mtd/20261119090055.1255028-1-ping.li@horizon.auto/

Ping Li (3):
  mtd: rawnand: fsmc: declare NAND_USES_DMA
  mtd: rawnand: intel: declare NAND_USES_DMA
  mtd: rawnand: r852: bounce non-linear-map buffers

 drivers/mtd/nand/raw/fsmc_nand.c             | 2 +-
 drivers/mtd/nand/raw/intel-nand-controller.c | 1 +
 drivers/mtd/nand/raw/r852.c                  | 4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2026-11-27  2:04 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  5:50 [PATCH 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers ping.li
2026-11-23  5:50 ` ping.li
2026-11-23  5:50 ` [PATCH 1/3] mtd: rawnand: fsmc: declare NAND_USES_DMA ping.li
2026-11-23  5:50   ` ping.li
2026-11-23  6:01   ` sashiko-bot
2026-11-23  7:04     ` Ping Li
2026-11-23  7:04       ` Ping Li
2026-11-23  5:50 ` [PATCH 2/3] mtd: rawnand: intel: " ping.li
2026-11-23  5:50   ` ping.li
2026-11-23  6:01   ` sashiko-bot
2026-11-23  5:50 ` [PATCH 3/3] mtd: rawnand: r852: bounce non-linear-map buffers ping.li
2026-11-23  5:50   ` ping.li
2026-11-23  7:04 ` [PATCH v2 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-23  7:04   ` Ping Li
2026-11-23  7:04   ` [PATCH v2 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-23  7:04     ` Ping Li
2026-11-23  7:04   ` [PATCH v2 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-23  7:04     ` Ping Li
2026-11-23  7:04   ` [PATCH v2 3/3] mtd: rawnand: r852: bounce non-linear-map buffers Ping Li
2026-11-23  7:04     ` Ping Li
2026-11-25  8:55     ` Miquel Raynal
2026-11-25  8:55       ` Miquel Raynal
2026-11-25  9:25       ` Ping Li
2026-11-25  9:25         ` Ping Li
2026-11-25  9:25   ` [PATCH v3 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25  9:25     ` Ping Li
2026-11-25  9:25     ` [PATCH v3 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25  9:25       ` Ping Li
2026-11-25  9:25     ` [PATCH v3 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25  9:25       ` Ping Li
2026-11-25  9:25     ` [PATCH v3 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25  9:25       ` Ping Li
2026-11-25  9:48       ` Miquel Raynal
2026-11-25  9:48         ` Miquel Raynal
2026-11-25 11:50         ` Ping Li
2026-11-25 11:50           ` Ping Li
2026-11-25 11:51     ` [PATCH v4 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25 11:51       ` Ping Li
2026-11-25 11:51       ` [PATCH v4 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25 11:51         ` Ping Li
2026-11-25 11:51       ` [PATCH v4 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25 11:51         ` Ping Li
2026-11-25 11:51       ` [PATCH v4 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 11:51         ` Ping Li
2026-11-25 12:10         ` sashiko-bot
2026-11-25 12:20           ` Miquel Raynal
2026-11-25 12:21       ` [PATCH v5 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25 12:21         ` Ping Li
2026-11-25 12:21         ` [PATCH v5 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25 12:21           ` Ping Li
2026-11-25 12:21         ` [PATCH v5 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25 12:21           ` Ping Li
2026-11-25 12:21         ` [PATCH v5 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 12:21           ` Ping Li
2026-11-25 12:55           ` Miquel Raynal
2026-11-25 12:55             ` Miquel Raynal
2026-11-26  6:02             ` Ping Li
2026-11-26  6:02               ` Ping Li
2026-11-26 11:03               ` Miquel Raynal
2026-11-26 11:03                 ` Miquel Raynal
2026-11-26 11:24                 ` Ping Li
2026-11-26 11:24                   ` Ping Li
2026-11-26 13:28                   ` Miquel Raynal
2026-11-26 13:28                     ` Miquel Raynal
2026-11-27  2:04                     ` Ping Li
2026-11-27  2:04                       ` Ping Li

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.