linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Fix potential out-of-bounds error in some drivers
@ 2025-05-08 13:06 Markus Burri
  2025-05-08 13:06 ` [PATCH v4 1/6] iio: backend: fix out-of-bound write Markus Burri
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Markus Burri @ 2025-05-08 13:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Markus Burri, Mahesh J Salgaonkar, Oliver O'Halloran,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, Jacek Lawrynowicz,
	Maciej Falkowski, Oded Gabbay, Linus Walleij, Bartosz Golaszewski,
	Nuno Sa, Olivier Moysan, Jonathan Cameron, Lars-Peter Clausen,
	linuxppc-dev, dri-devel, linux-gpio, linux-iio, Markus Burri

Several drivers are using debugfs and follow the same pattern.

A buffer is created on the stack with a limited size to copy the given data
from user space. The copy is performed using simple_write_to_buffer.
This function limits the input according to the specified buffer size, but
it does not write a string terminator if the buffer is truncated.
Therefore, the driver adds this zero terminator afterward.
Unfortunately, the original buffer size is used as an index, which can lead
to an out-of-bounds error.

This patch set fixes this issue in all the drivers I have detected so far.
The fix is to return an error in case of an unexpectedly long buffer being
received and to use the effective written size for the zero terminator for 
consistency.

Changes in V4:
* Revert the decrement of accepted size by one character
* Added patches for drivers with the same pattern

Changes in V3:
* Decrement accepted size by one character according to feedback

Changes in V2:
* Use effective written size as index instead of original size

---
[V3] https://lore.kernel.org/lkml/20250505203830.5117-1-markus.burri@mt.com/
[V2] https://lore.kernel.org/lkml/20250505045346.29647-1-markus.burri@mt.com/
[V1] https://lore.kernel.org/lkml/20250501063240.25295-1-markus.burri@mt.com/

Markus Burri (6):
  iio: backend: fix out-of-bound write
  accel/ivpu: Use effective buffer size for zero terminator
  iio: fix potential out-of-bound write
  gpio: fix potential out-of-bound write
  powerpc/eeh: fix potential OoB
  powerpc/eeh-powernv: fix potential OoB

 arch/powerpc/kernel/eeh.c                    |  7 ++++++-
 arch/powerpc/platforms/powernv/eeh-powernv.c |  7 ++++++-
 drivers/accel/ivpu/ivpu_debugfs.c            |  2 +-
 drivers/gpio/gpio-virtuser.c                 | 12 ++++++++++--
 drivers/iio/industrialio-backend.c           |  5 ++++-
 drivers/iio/industrialio-core.c              |  5 ++++-
 6 files changed, 31 insertions(+), 7 deletions(-)


base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e
-- 
2.39.5

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

end of thread, other threads:[~2025-05-25  9:27 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 13:06 [PATCH v4 0/6] Fix potential out-of-bounds error in some drivers Markus Burri
2025-05-08 13:06 ` [PATCH v4 1/6] iio: backend: fix out-of-bound write Markus Burri
2025-05-11 14:27   ` Jonathan Cameron
2025-05-25  9:19     ` Jonathan Cameron
2025-05-08 13:06 ` [PATCH v4 2/6] accel/ivpu: Use effective buffer size for zero terminator Markus Burri
2025-05-12 10:32   ` Jacek Lawrynowicz
2025-05-12 13:15   ` Jacek Lawrynowicz
2025-05-08 13:06 ` [PATCH v4 3/6] iio: fix potential out-of-bound write Markus Burri
2025-05-25  9:23   ` Jonathan Cameron
2025-05-25  9:26   ` Jonathan Cameron
2025-05-08 13:06 ` [PATCH v4 4/6] gpio: " Markus Burri
2025-05-09  9:37   ` kernel test robot
2025-05-09 12:40   ` Bartosz Golaszewski
2025-05-08 13:06 ` [PATCH v4 5/6] powerpc/eeh: fix potential OoB Markus Burri
2025-05-20  3:16   ` Mahesh J Salgaonkar
2025-05-08 13:06 ` [PATCH v4 6/6] powerpc/eeh-powernv: " Markus Burri
2025-05-20  3:18   ` Mahesh J Salgaonkar
2025-05-09 10:21 ` [PATCH v4 0/6] Fix potential out-of-bounds error in some drivers Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).