mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 20:14:06 +02:00
HID: rate-limit hid_warn to prevent log flooding
Syzkaller can create many uhid devices that trigger repeated warnings like: "hid-generic xxxx: unknown main item tag 0x0" These messages can flood the system log, especially if a crash occurs (e.g., with a slow UART console, leading to soft lockups). To mitigate this, convert `hid_warn()` to use `dev_warn_ratelimited()`. This helps reduce log noise and improves system stability under fuzzing or faulty device scenarios. Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
37a9acb971
commit
4051ead998
|
|
@ -659,9 +659,9 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
|
|||
default:
|
||||
if (item->tag >= HID_MAIN_ITEM_TAG_RESERVED_MIN &&
|
||||
item->tag <= HID_MAIN_ITEM_TAG_RESERVED_MAX)
|
||||
hid_warn(parser->device, "reserved main item tag 0x%x\n", item->tag);
|
||||
hid_warn_ratelimited(parser->device, "reserved main item tag 0x%x\n", item->tag);
|
||||
else
|
||||
hid_warn(parser->device, "unknown main item tag 0x%x\n", item->tag);
|
||||
hid_warn_ratelimited(parser->device, "unknown main item tag 0x%x\n", item->tag);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1239,6 +1239,8 @@ void hid_quirks_exit(__u16 bus);
|
|||
dev_notice(&(hid)->dev, fmt, ##__VA_ARGS__)
|
||||
#define hid_warn(hid, fmt, ...) \
|
||||
dev_warn(&(hid)->dev, fmt, ##__VA_ARGS__)
|
||||
#define hid_warn_ratelimited(hid, fmt, ...) \
|
||||
dev_warn_ratelimited(&(hid)->dev, fmt, ##__VA_ARGS__)
|
||||
#define hid_info(hid, fmt, ...) \
|
||||
dev_info(&(hid)->dev, fmt, ##__VA_ARGS__)
|
||||
#define hid_dbg(hid, fmt, ...) \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user