diff --git a/patches.kernel.org/6.2.1-005-HID-mcp-2221-prevent-UAF-in-delayed-work.patch b/patches.kernel.org/6.2.1-005-HID-mcp-2221-prevent-UAF-in-delayed-work.patch new file mode 100644 index 0000000..a68c37c --- /dev/null +++ b/patches.kernel.org/6.2.1-005-HID-mcp-2221-prevent-UAF-in-delayed-work.patch @@ -0,0 +1,44 @@ +From: Benjamin Tissoires +Date: Thu, 16 Feb 2023 11:22:58 +0100 +Subject: [PATCH] HID: mcp-2221: prevent UAF in delayed work +References: bsc#1012628 +Patch-mainline: 6.2.1 +Git-commit: 47e91fdfa511139f2549687edb0d8649b123227b + +commit 47e91fdfa511139f2549687edb0d8649b123227b upstream. + +If the device is plugged/unplugged without giving time for mcp_init_work() +to complete, we might kick in the devm free code path and thus have +unavailable struct mcp_2221 while in delayed work. + +Canceling the delayed_work item is enough to solve the issue, because +cancel_delayed_work_sync will prevent the work item to requeue itself. + +Fixes: 960f9df7c620 ("HID: mcp2221: add ADC/DAC support via iio subsystem") +CC: stable@vger.kernel.org +Acked-by: Jiri Kosina +Link: https://lore.kernel.org/r/20230215-wip-mcp2221-v2-1-109f71fd036e@redhat.com +Signed-off-by: Benjamin Tissoires +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +--- + drivers/hid/hid-mcp2221.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c +index e61dd039..f74a977c 100644 +--- a/drivers/hid/hid-mcp2221.c ++++ b/drivers/hid/hid-mcp2221.c +@@ -922,6 +922,9 @@ static void mcp2221_hid_unregister(void *ptr) + /* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */ + static void mcp2221_remove(struct hid_device *hdev) + { ++ struct mcp2221 *mcp = hid_get_drvdata(hdev); ++ ++ cancel_delayed_work_sync(&mcp->init_work); + } + + #if IS_REACHABLE(CONFIG_IIO) +-- +2.35.3 + diff --git a/series.conf b/series.conf index b13adaa..cf1d8b0 100644 --- a/series.conf +++ b/series.conf @@ -31,6 +31,7 @@ patches.kernel.org/6.2.1-002-x86-alternatives-Introduce-int3_emulate_jcc.patch patches.kernel.org/6.2.1-003-x86-alternatives-Teach-text_poke_bp-to-patch-Jc.patch patches.kernel.org/6.2.1-004-x86-static_call-Add-support-for-Jcc-tail-calls.patch + patches.kernel.org/6.2.1-005-HID-mcp-2221-prevent-UAF-in-delayed-work.patch ######################################################## # Build fixes that apply to the vanilla kernel too.