From: Dan Carpenter <dan.carpenter@linaro.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Torsten Hilbrich <torsten.hilbrich@secunet.com>,
Nick Dyer <nick@shmanahar.org>
Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Brad Spengler <spender@grsecurity.net>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH] Input: synaptics-rmi4 - fix use after free (more completely)
Date: Thu, 22 Feb 2024 11:53:24 +0300 [thread overview]
Message-ID: <e77756aa-c0f1-44a8-bcd6-a46fe954b195@moroto.mountain> (raw)
From: Brad Spengler <spender@grsecurity.net>
Grsecurity uses memory poisoning and detected a use after free in
rmi_unregister_function(). A fix for this was merged into the
grsecurity patchset. I detected the user after free later using static
analysis and sent a partial fix as commit eb988e46da2e ("Input:
synaptics-rmi4 - fix use after free in rmi_unregister_function()").
However, my patch meant that the grsecurity patchset didn't apply cleanly
and forced everyone to re-visit this issue.
The bug is that we must not call device_del() until after calling
irq_dispose_mapping().
Fixes: 24d28e4f1271 ("Input: synaptics-rmi4 - convert irq distribution to irq_domain")
Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
Closes: https://lore.kernel.org/all/1932038e-2776-04ac-5fcd-b15bb3cd088d@secunet.com/
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=215604
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/input/rmi4/rmi_bus.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 1b45b1d3077d..02acc81b9d3e 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -275,12 +275,11 @@ void rmi_unregister_function(struct rmi_function *fn)
rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n",
fn->fd.function_number);
- device_del(&fn->dev);
- of_node_put(fn->dev.of_node);
-
for (i = 0; i < fn->num_of_irqs; i++)
irq_dispose_mapping(fn->irq[i]);
+ device_del(&fn->dev);
+ of_node_put(fn->dev.of_node);
put_device(&fn->dev);
}
--
2.43.0
next reply other threads:[~2024-02-22 8:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 8:53 Dan Carpenter [this message]
2024-02-22 14:08 ` [PATCH] Input: synaptics-rmi4 - fix use after free (more completely) -- but not fully ;) Mathias Krause
2024-02-22 14:19 ` Mathias Krause
2024-03-08 0:30 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e77756aa-c0f1-44a8-bcd6-a46fe954b195@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nick@shmanahar.org \
--cc=sashal@kernel.org \
--cc=spender@grsecurity.net \
--cc=torsten.hilbrich@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox