Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
94109c9f
Commit
94109c9f
authored
Feb 22, 2023
by
Benjamin Tissoires
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-6.3/asus' into for-linus
UAF protection in work struct (Pietro Borrello)
parents
06db2af3
4ab3a086
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
drivers/hid/hid-asus.c
drivers/hid/hid-asus.c
+32
-5
No files found.
drivers/hid/hid-asus.c
View file @
94109c9f
...
@@ -98,6 +98,7 @@ struct asus_kbd_leds {
...
@@ -98,6 +98,7 @@ struct asus_kbd_leds {
struct
hid_device
*
hdev
;
struct
hid_device
*
hdev
;
struct
work_struct
work
;
struct
work_struct
work
;
unsigned
int
brightness
;
unsigned
int
brightness
;
spinlock_t
lock
;
bool
removed
;
bool
removed
;
};
};
...
@@ -490,21 +491,42 @@ static int rog_nkey_led_init(struct hid_device *hdev)
...
@@ -490,21 +491,42 @@ static int rog_nkey_led_init(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
)
{
{
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
cdev
);
cdev
);
unsigned
long
flags
;
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
led
->
brightness
=
brightness
;
led
->
brightness
=
brightness
;
schedule_work
(
&
led
->
work
);
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
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
)
{
{
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
cdev
);
cdev
);
enum
led_brightness
brightness
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
brightness
=
led
->
brightness
;
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
return
led
->
brightness
;
return
brightness
;
}
}
static
void
asus_kbd_backlight_work
(
struct
work_struct
*
work
)
static
void
asus_kbd_backlight_work
(
struct
work_struct
*
work
)
...
@@ -512,11 +534,11 @@ static void asus_kbd_backlight_work(struct work_struct *work)
...
@@ -512,11 +534,11 @@ static void asus_kbd_backlight_work(struct work_struct *work)
struct
asus_kbd_leds
*
led
=
container_of
(
work
,
struct
asus_kbd_leds
,
work
);
struct
asus_kbd_leds
*
led
=
container_of
(
work
,
struct
asus_kbd_leds
,
work
);
u8
buf
[]
=
{
FEATURE_KBD_REPORT_ID
,
0xba
,
0xc5
,
0xc4
,
0x00
};
u8
buf
[]
=
{
FEATURE_KBD_REPORT_ID
,
0xba
,
0xc5
,
0xc4
,
0x00
};
int
ret
;
int
ret
;
unsigned
long
flags
;
if
(
led
->
removed
)
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
return
;
buf
[
4
]
=
led
->
brightness
;
buf
[
4
]
=
led
->
brightness
;
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
ret
=
asus_kbd_set_report
(
led
->
hdev
,
buf
,
sizeof
(
buf
));
ret
=
asus_kbd_set_report
(
led
->
hdev
,
buf
,
sizeof
(
buf
));
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -584,6 +606,7 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
...
@@ -584,6 +606,7 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
drvdata
->
kbd_backlight
->
cdev
.
brightness_set
=
asus_kbd_backlight_set
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_set
=
asus_kbd_backlight_set
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_get
=
asus_kbd_backlight_get
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_get
=
asus_kbd_backlight_get
;
INIT_WORK
(
&
drvdata
->
kbd_backlight
->
work
,
asus_kbd_backlight_work
);
INIT_WORK
(
&
drvdata
->
kbd_backlight
->
work
,
asus_kbd_backlight_work
);
spin_lock_init
(
&
drvdata
->
kbd_backlight
->
lock
);
ret
=
devm_led_classdev_register
(
&
hdev
->
dev
,
&
drvdata
->
kbd_backlight
->
cdev
);
ret
=
devm_led_classdev_register
(
&
hdev
->
dev
,
&
drvdata
->
kbd_backlight
->
cdev
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -1119,9 +1142,13 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
...
@@ -1119,9 +1142,13 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
static
void
asus_remove
(
struct
hid_device
*
hdev
)
static
void
asus_remove
(
struct
hid_device
*
hdev
)
{
{
struct
asus_drvdata
*
drvdata
=
hid_get_drvdata
(
hdev
);
struct
asus_drvdata
*
drvdata
=
hid_get_drvdata
(
hdev
);
unsigned
long
flags
;
if
(
drvdata
->
kbd_backlight
)
{
if
(
drvdata
->
kbd_backlight
)
{
spin_lock_irqsave
(
&
drvdata
->
kbd_backlight
->
lock
,
flags
);
drvdata
->
kbd_backlight
->
removed
=
true
;
drvdata
->
kbd_backlight
->
removed
=
true
;
spin_unlock_irqrestore
(
&
drvdata
->
kbd_backlight
->
lock
,
flags
);
cancel_work_sync
(
&
drvdata
->
kbd_backlight
->
work
);
cancel_work_sync
(
&
drvdata
->
kbd_backlight
->
work
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment