Linux wireless drivers development
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 3/3] wifi: carl9170: NUL terminate string in debugfs
Date: Thu, 1 Oct 2026 10:37:50 +0300	[thread overview]
Message-ID: <674270ab4aeefa1982362c0ea4132427e14f15eb.1790839793.git.error27@gmail.com> (raw)
In-Reply-To: <cover.1790839793.git.error27@gmail.com>

The "buf" buffer comes from the user.  We use it to store a number or
two so it doesn't need to be large.  It gets passed to sscanf() in the
write functions such as carl9170_debugfs_erp_write().  Ensure that
buffer is NUL terminated.

This is debugfs so it's root only.

Fixes: 00c4da27a421 ("carl9170: firmware parser and debugfs code")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/net/wireless/ath/carl9170/debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
index 0498df2a2160..bc6c8e0b1d16 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -119,7 +119,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (!count)
 		return 0;
 
-	if (count > PAGE_SIZE)
+	if (count >= PAGE_SIZE)
 		return -E2BIG;
 
 	ar = file->private_data;
@@ -131,7 +131,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (!dfops->write)
 		return -ENOSYS;
 
-	buf = vmalloc(count);
+	buf = vmalloc(count + 1);
 	if (!buf)
 		return -ENOMEM;
 
@@ -139,6 +139,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 		err = -EFAULT;
 		goto out_free;
 	}
+	buf[count] = '\0';
 
 	if (mutex_trylock(&ar->mutex) == 0) {
 		err = -EAGAIN;
-- 
2.53.0


  parent reply	other threads:[~2026-10-01  7:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01  7:37 [PATCH 0/3] wifi: NULL terminate some user strings Dan Carpenter
2026-10-01  7:37 ` [PATCH 1/3] wifi: b43: don't pass unterminated string to sscanf() Dan Carpenter
2026-10-01  7:37 ` [PATCH 2/3] wifi: b43legacy: debugfs: NUL terminate string in debugfs Dan Carpenter
2026-10-01  7:37 ` Dan Carpenter [this message]
2026-10-01 17:58   ` [PATCH 3/3] wifi: carl9170: " Christian Lamparter
2026-10-01 18:31     ` Dan Carpenter
2026-10-03 22:49   ` Jeff Johnson

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=674270ab4aeefa1982362c0ea4132427e14f15eb.1790839793.git.error27@gmail.com \
    --to=error27@gmail.com \
    --cc=chunkeey@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    /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