platform/x86: intel_pmc_core: Uninitialized data in pmc_core_lpm_latch_mode_write()
The simple_write_to_buffer() can return success if even a single byte
is copied from user space. In this case it can result in using
uninitalized data if the buf[] array is not fully initialized. Really
we should only succeed if the whole buffer is copied.
Just using copy_from_user() is simpler and more appropriate.
Fixes: 8074a79fad
("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YIBCf+G9Ef8wrGJw@mwanda
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Родитель
f75bf693c9
Коммит
37bd59d3ce
|
@ -1360,17 +1360,13 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
|
|||
struct pmc_dev *pmcdev = s->private;
|
||||
bool clear = false, c10 = false;
|
||||
unsigned char buf[8];
|
||||
ssize_t ret;
|
||||
int idx, m, mode;
|
||||
u32 reg;
|
||||
|
||||
if (count > sizeof(buf) - 1)
|
||||
return -EINVAL;
|
||||
|
||||
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf, count);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (copy_from_user(buf, userbuf, count))
|
||||
return -EFAULT;
|
||||
buf[count] = '\0';
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче