Skip to content

Commit

Permalink
wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()
Browse files Browse the repository at this point in the history
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: ff974e4 ("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>
Link: https://lore.kernel.org/r/Ysg14NdKAZF/hcNG@kili
  • Loading branch information
Dan Carpenter authored and kvalo committed Jul 18, 2022
1 parent eaedf62 commit 7a48365
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/net/wireless/ath/wil6210/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7a48365

Please sign in to comment.