“4a588548d5eb8496e6e531869541786b1800059f”上不存在“...classes/git@gitcode.net:openanolis/dragonwell8_jdk.git”
提交 a418baf8 编写于 作者: P Pietro Borrello 提交者: Yongqiang Liu

HID: asus: use spinlock to safely schedule workers

mainline inclusion
from mainline-v6.2
commit 4ab3a086
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6I7U9
CVE: CVE-2023-1079

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4ab3a086d10eeec1424f2e8a968827a6336203df

--------------------------------

Use spinlocks to deal with workers introducing a wrapper
asus_schedule_work(), and several spinlock checks.
Otherwise, asus_kbd_backlight_set() may schedule led->work after the
structure has been freed, causing a use-after-free.

Fixes: af22a610 ("HID: asus: support backlight on USB keyboards")
Signed-off-by: NPietro Borrello <borrello@diag.uniroma1.it>
Link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v4-5-7860c5763c38@diag.uniroma1.itSigned-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: NYuyao Lin <linyuyao1@huawei.com>
Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 28cadeae
...@@ -314,6 +314,16 @@ static int asus_kbd_get_functions(struct hid_device *hdev, ...@@ -314,6 +314,16 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
return ret; return ret;
} }
static void asus_schedule_work(struct asus_kbd_leds *led)
{
unsigned long flags;
spin_lock_irqsave(&led->lock, flags);
if (!led->removed)
schedule_work(&led->work);
spin_unlock_irqrestore(&led->lock, flags);
}
static void asus_kbd_backlight_set(struct led_classdev *led_cdev, static void asus_kbd_backlight_set(struct led_classdev *led_cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
...@@ -325,7 +335,7 @@ static void asus_kbd_backlight_set(struct led_classdev *led_cdev, ...@@ -325,7 +335,7 @@ static void asus_kbd_backlight_set(struct led_classdev *led_cdev,
led->brightness = brightness; led->brightness = brightness;
spin_unlock_irqrestore(&led->lock, flags); spin_unlock_irqrestore(&led->lock, flags);
schedule_work(&led->work); asus_schedule_work(led);
} }
static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev) static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
...@@ -349,9 +359,6 @@ static void asus_kbd_backlight_work(struct work_struct *work) ...@@ -349,9 +359,6 @@ static void asus_kbd_backlight_work(struct work_struct *work)
int ret; int ret;
unsigned long flags; unsigned long flags;
if (led->removed)
return;
spin_lock_irqsave(&led->lock, flags); spin_lock_irqsave(&led->lock, flags);
buf[4] = led->brightness; buf[4] = led->brightness;
spin_unlock_irqrestore(&led->lock, flags); spin_unlock_irqrestore(&led->lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册