mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tuhaowen <tuhaowen@uniontech.com>
To: sudipm.mukherjee@gmail.com, alexander.deucher@amd.com,
	gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, huangbibo@uniontech.com,
	wangyuli@uniontech.com, tuhaowen <tuhaowen@uniontech.com>
Subject: [PATCH] dev/parport: fix the array out-of-bounds risk
Date: Wed, 26 Jun 2024 10:11:36 +0800	[thread overview]
Message-ID: <20240626021136.12282-1-tuhaowen@uniontech.com> (raw)

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


             reply	other threads:[~2024-06-26  2:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  2:11 tuhaowen [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2024-05-27  7:23 [PATCH] " tuhaowen

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=20240626021136.12282-1-tuhaowen@uniontech.com \
    --to=tuhaowen@uniontech.com \
    --cc=alexander.deucher@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=huangbibo@uniontech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=wangyuli@uniontech.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®