]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (corsair-psu) fix possible out-of-bounds access on missing string termination
authorWilken Gottwalt <wilken.gottwalt@posteo.net>
Wed, 5 Aug 2026 07:19:20 +0000 (07:19 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 7 Aug 2026 05:37:38 +0000 (22:37 -0700)
In theory it could be possible that the REPLY_SIZE sized buffers for
holding the vendor and product strings could be end up missing the null
termination (for example by malicious hardware built on purpose)
required by the seq_printf() call. That limits the debugfs printf calls
to a maximum string length of REPLY_SIZE.

Fixes: d115b51e0e567 ("hwmon: add Corsair PSU HID controller driver")
Signed-off-by: Wilken Gottwalt <wilken.gottwalt@posteo.net>
Link: https://lore.kernel.org/r/anLj9gPWRoRDbQBV@monster.localdomain
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/corsair-psu.c

index ce958cdaef58a3062062678fbc97c52e9007e8ca..3c01ae3fc4af224f2be14862653ee3eff3ffc6de 100644 (file)
@@ -701,7 +701,7 @@ static int vendor_show(struct seq_file *seqf, void *unused)
 {
        struct corsairpsu_data *priv = seqf->private;
 
-       seq_printf(seqf, "%s\n", priv->vendor);
+       seq_printf(seqf, "%.*s\n", REPLY_SIZE, priv->vendor);
 
        return 0;
 }
@@ -711,7 +711,7 @@ static int product_show(struct seq_file *seqf, void *unused)
 {
        struct corsairpsu_data *priv = seqf->private;
 
-       seq_printf(seqf, "%s\n", priv->product);
+       seq_printf(seqf, "%.*s\n", REPLY_SIZE, priv->product);
 
        return 0;
 }