eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()
Subsystems (2)
PATCH 1/1 eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()
The simple_write_to_buffer() here is used to copy a string from the user. However the function call will succeed if it manages to read just one byte anywhere within the buffer while we need the whole string to be initialized to avoid using uninitialized data.
--- drivers/misc/eeprom/idt_89hpesx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +6 -8
@@ -909,15 +909,13 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,u32 csraddr, csrval;char *buf; -/* Copy data from User-space */ - buf =kmalloc (count +1 ,GFP_KERNEL ); -if (!buf) -return -ENOMEM ; +if (*offp !=0 ) +return -EINVAL ; - ret =simple_write_to_buffer (buf, count, offp, ubuf, count); -if (ret <0 ) - goto free_buf; - buf[count] =0 ; +/* Copy data from User-space */ + buf =strndup_user (ubuf, count +1 ); +if (IS_ERR (buf)) +return PTR_ERR (buf);/* Find position of colon in the buffer */ colon_ch =strnchr (buf, count,':' );
Signature · 1 line
2.35.1
Quoted 8 lines · Dan Carpenter
The
simple_write_to_buffer()here is used to copy a string from the user. However the function call will succeed if it manages to read just one byte anywhere within the buffer while we need the whole string to be initialized to avoid using uninitialized data.Fixes cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")Signed-off-by Dan Carpenter <[email protected]>---
NAK. The strndup_user() function is too strict. I will resend this using memdup_user() instead.
regards,
dan carpenter
Hi Dan
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Dan Carpenter
The
simple_write_to_buffer()here is used to copy a string from the user. However the function call will succeed if it manages to read just one byte anywhere within the buffer while we need the whole string to be initialized to avoid using uninitialized data.
Quoted 6 lines
Quoted 3 lines
Fixes cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")Signed-off-by Dan Carpenter <[email protected]>---
NAK. The
strndup_user()function is too strict. I will resend this usingmemdup_user()instead.
Thanks for the patch. Ok. I'll wait for v2 to review.
-Sergey
Quoted 4 lines
regards,
dan carpenter