Skip to contentSkip to conversation

ath9k: fix tx99 potential info leak

PATCH In review [email protected] 3 participants 4 messages Sep 27, 2017 – Oct 13, 2017 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: fix tx99 potential info leak

From: Miaoqing Pan <[email protected]>

When the user sets count to zero the string buffer would remain completely uninitialized which causes the kernel to parse its own stack data, potentially leading to an info leak. In addition to that, the string might be not terminated properly when the user data does not contain a 0-terminator.

---
 drivers/net/wireless/ath/ath9k/tx99.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/tx99.c +5 -0
index 49ed1af..fe3a826 100644
@@ -179,6 +179,9 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	ssize_t len;
 	int r;
 
+	if (count < 1)
+		return -EINVAL;
+
 	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;
 
@@ -186,6 +189,8 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	if (copy_from_user(buf, user_buf, len))
 		return -EFAULT;
 
+	buf[len] = '\0';
+
 	if (strtobool(buf, &start))
 		return -EINVAL;
 
Signature · 1 line
1.9.1
#1 lore raw

Am 27. September 2017 03:13:34 MESZ schrieb [email protected]:

Quoted 30 lines

From: Miaoqing Pan <[email protected]>

When the user sets count to zero the string buffer would remain completely uninitialized which causes the kernel to parse its own stack data, potentially leading to an info leak. In addition to that, the string might be not terminated properly when the user data does not contain a 0-terminator.

---
drivers/net/wireless/ath/ath9k/tx99.c | 5 +++++

1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/tx99.c +3 -0
index 49ed1af..fe3a826 100644
@@ -179,6 +179,9 @@ static ssize_t write_file_tx99(struct file *file,
 const char __user *user_buf,
 	ssize_t len;
 	int r;
 
+	if (count < 1)
+		return -EINVAL;
+
 	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;

drivers/net/wireless/ath/ath9k/tx99.c static ssize_t write_file_tx99(struct file *file, · line 194

Quoted 6 lines
drivers/net/wireless/ath/ath9k/tx99.c +2 -0
@@ -186,6 +189,8 @@ static ssize_t write_file_tx99(struct file *file,
 const char __user *user_buf,
 	if (copy_from_user(buf, user_buf, len))
 		return -EFAULT;
 
+	buf[len] = '\0';
+

I think it would be more appropriate here to check if buf[len] == '\0' and return an error otherwise.

Quoted 5 lines
drivers/net/wireless/ath/ath9k/tx99.c +0 -0
 	if (strtobool(buf, &start))
 		return -EINVAL;
Signature · 2 lines
-- 
1.9.1

--
Regards,
Christoph

#2 lore raw
Quoted 6 lines

drivers/net/wireless/ath/ath9k/tx99.c static ssize_t write_file_tx99(struct file *file, const char __user *user_buf, · line 193

Quoted 4 lines
drivers/net/wireless/ath/ath9k/tx99.c +2 -0
+	buf[len] = '\0';
+

I think it would be more appropriate here to check if buf[len] == '\0' and return an error otherwise.

Nevermind, I just had a closer look and I actually think your approach is fine. I hadn't considered the possibility of someone deliberately passing a non-null-terminated string with a specific length.

Quoted 1 line
Quoted 1 line
Signature · 2 lines
Regards,
Christoph
#3 lore raw
In reply to [email protected]
Quoted 9 lines · miaoqing pan

When the user sets count to zero the string buffer would remain completely uninitialized which causes the kernel to parse its own stack data, potentially leading to an info leak. In addition to that, the string might be not terminated properly when the user data does not contain a 0-terminator.

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

ee0a47186e2f ath9k: fix tx99 potential info leak

Signature · 3 lines
https://patchwork.kernel.org/patch/9972889/

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