public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dev/parport: fix the array out-of-bounds risk
@ 2024-06-26  2:11 tuhaowen
  2024-07-04 10:07 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: tuhaowen @ 2024-06-26  2:11 UTC (permalink / raw)
  To: sudipm.mukherjee, alexander.deucher, gregkh
  Cc: linux-kernel, huangbibo, wangyuli, tuhaowen

The array buffer size is 20 bytes.
When executing code in a 64-bit CPU environment, up to 42 bytes of
data will be written into this array
(the size of "%lu\t%lu\n" is 20 + 1 + 20 + 1).

In fact, this line of code for 32-bit CPUs also has the risk of
crossing the boundary, but it can exceed 2 bytes at most. With good
luck, it is local variables that are damaged, and there are no serious
consequences.

Signed-off-by: tuhaowen <tuhaowen@uniontech.com>
---
 drivers/parport/procfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index bd388560ed59..9f501d5fa1ec 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -117,7 +117,7 @@ static int do_hardware_base_addr(struct ctl_table *table, int write,
 				 void *result, size_t *lenp, loff_t *ppos)
 {
 	struct parport *port = (struct parport *)table->extra1;
-	char buffer[20];
+	char buffer[64];
 	int len = 0;
 
 	if (*ppos) {
-- 
2.20.1


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

end of thread, other threads:[~2024-07-08  8:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26  2:11 [PATCH] dev/parport: fix the array out-of-bounds risk tuhaowen
2024-07-04 10:07 ` Greg KH
2024-07-05  6:36   ` tuhaowen
2024-07-05  6:45     ` Greg KH
2024-07-05  8:58       ` tuhaowen
2024-07-05  9:42         ` Greg KH
2024-07-08  2:33           ` tuhaowen
2024-07-08  7:18             ` Greg KH
2024-07-08  8:04               ` [PATCH v2] " tuhaowen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox