linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] wil6210: debugfs: fix info leak in wil_write_file_wmi()
@ 2022-07-08 13:49 Dan Carpenter
  2022-07-18 10:04 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-07-08 13:49 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Paolo Abeni, Johannes Berg, Vladimir Kondratiev,
	John W. Linville, linux-wireless, kernel-janitors

The simple_write_to_buffer() function will succeed if even a single
byte is initialized.  However, we need to initialize the whole buffer
to prevent information leaks.  Just use memdup_user().

Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2:  In v1 this was part of a two patch series.  The second patch was a
     cleanup path and it introduced a bug.  Just drop patch 2.

 drivers/net/wireless/ath/wil6210/debugfs.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 64d6c98174c8..fe84362718de 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1012,18 +1012,12 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 	u16 cmdid;
 	int rc, rc1;
 
-	if (cmdlen < 0)
+	if (cmdlen < 0 || *ppos != 0)
 		return -EINVAL;
 
-	wmi = kmalloc(len, GFP_KERNEL);
-	if (!wmi)
-		return -ENOMEM;
-
-	rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
-	if (rc < 0) {
-		kfree(wmi);
-		return rc;
-	}
+	wmi = memdup_user(buf, len);
+	if (IS_ERR(wmi))
+		return PTR_ERR(wmi);
 
 	cmd = (cmdlen > 0) ? &wmi[1] : NULL;
 	cmdid = le16_to_cpu(wmi->command_id);
-- 
2.35.1


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

* Re: [PATCH v2] wil6210: debugfs: fix info leak in wil_write_file_wmi()
  2022-07-08 13:49 [PATCH v2] wil6210: debugfs: fix info leak in wil_write_file_wmi() Dan Carpenter
@ 2022-07-18 10:04 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2022-07-18 10:04 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Paolo Abeni, Johannes Berg, Vladimir Kondratiev,
	John W. Linville, linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The simple_write_to_buffer() function will succeed if even a single
> byte is initialized.  However, we need to initialize the whole buffer
> to prevent information leaks.  Just use memdup_user().
> 
> Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

7a4836560a61 wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/Ysg14NdKAZF/hcNG@kili/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2022-07-18 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 13:49 [PATCH v2] wil6210: debugfs: fix info leak in wil_write_file_wmi() Dan Carpenter
2022-07-18 10:04 ` Kalle Valo

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).