Patch "eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()" has been added to the 5.18-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()

to the 5.18-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     eeprom-idt_89hpesx-uninitialized-data-in-idt_dbgfs_c.patch
and it can be found in the queue-5.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a73164fa167fe0ea571c824308d8de8bfbfb31e5
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Fri Jul 8 16:46:38 2022 +0300

    eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()
    
    [ Upstream commit 71d46f1ff2212ced4852c7e77c5176382a1bdcec ]
    
    The simple_write_to_buffer() function will return positive/success if it
    is able to write a single byte anywhere within the buffer.  However that
    potentially leaves a lot of the buffer uninitialized.
    
    In this code it's better to return 0 if the offset is non-zero.  This
    code is not written to support partial writes.  And then return -EFAULT
    if the buffer is not completely initialized.
    
    Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
    Reviewed-by: Serge Semin <fancer.lancer@xxxxxxxxx>
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/Ysg1Pu/nzSMe3r1q@kili
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index b0cff4b152da..7f430742ce2b 100644
--- a/drivers/misc/eeprom/idt_89hpesx.c
+++ b/drivers/misc/eeprom/idt_89hpesx.c
@@ -909,14 +909,18 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
 	u32 csraddr, csrval;
 	char *buf;
 
+	if (*offp)
+		return 0;
+
 	/* Copy data from User-space */
 	buf = kmalloc(count + 1, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
-	ret = simple_write_to_buffer(buf, count, offp, ubuf, count);
-	if (ret < 0)
+	if (copy_from_user(buf, ubuf, count)) {
+		ret = -EFAULT;
 		goto free_buf;
+	}
 	buf[count] = 0;
 
 	/* Find position of colon in the buffer */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux