[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240522073607.15076-1-huanglei814@163.com>
Date: Wed, 22 May 2024 15:36:07 +0800
From: huanglei814 <huanglei814@....com>
To: sudipm.mukherjee@...il.com
Cc: linux-kernel@...r.kernel.org,
huanglei <huanglei@...inos.cn>
Subject: [PATCH] parport: Increase buffer max length to avoid memory out of bounds overflow
From: huanglei <huanglei@...inos.cn>
Most of the time,will use 64 bit address.
such as port->base=0xffffffc010e21280 and then use
len += sprintf (buffer, "%lu\t%lu\n", port->base, port->base_hi),
port->base convert to string is "18446743799114896000" add
port->base_hi is "0" and "\t" "\n" len will be 23.
But buffer the original max length is 20, length 23 is out of buffer.
So to make sure 64 bit address will not experience buffer overflow,
need increase buffer size to 32.
Signed-off-by: huanglei <huanglei@...inos.cn>
---
drivers/parport/procfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index bd388560ed59..6722ae620b68 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[32];
int len = 0;
if (*ppos) {
@@ -171,7 +171,7 @@ static int do_hardware_dma(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[32];
int len = 0;
if (*ppos) {
--
2.17.1
Powered by blists - more mailing lists