mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
leds: uleds: Fix potential buffer overread
commitc19fe864f6upstream. The name string supplied by userspace is not guaranteed to be null-terminated, so using strchr() on it might result in a buffer overread. The same thing will happen when said string is used by the LED class device. Fix this by using strnchr() instead and explicitly check that the name string is properly null-terminated. Cc: stable@vger.kernel.org Fixes:e381322b01("leds: Introduce userspace LED class driver") Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://patch.msgid.link/20260524235553.189134-1-W_Armin@gmx.de Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
30500acfc4
commit
8bf529571c
@@ -102,7 +102,8 @@ static ssize_t uleds_write(struct file *file, const char __user *buffer,
|
||||
|
||||
name = udev->user_dev.name;
|
||||
if (!name[0] || !strcmp(name, ".") || !strcmp(name, "..") ||
|
||||
strchr(name, '/')) {
|
||||
strnchr(name, sizeof(udev->user_dev.name), '/') ||
|
||||
!strnchr(name, sizeof(udev->user_dev.name), '\0')) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user