From: "F.A.Sulaiman" <asha.16@itfac.mrt.ac.lk>
To: jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: "F.A.Sulaiman" <asha.16@itfac.mrt.ac.lk>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
paskripkin@gmail.com
Subject: [PATCH] fix slab-out-of-bounds Write in betop_probe
Date: Tue, 17 Aug 2021 01:45:44 +0530 [thread overview]
Message-ID: <20210816201544.26405-1-asha.16@itfac.mrt.ac.lk> (raw)
This patch resolves the bug 'KASAN: slab-out-of-bounds Write in betop_probe' reported by Syzbot.
This checkes hid_device's input is non empty before it's been used.
Signed-off-by: F.A. SULAIMAN <asha.16@itfac.mrt.ac.lk>
---
drivers/hid/hid-betopff.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/hid/hid-betopff.c b/drivers/hid/hid-betopff.c
index 467d789f9bc2..27b57aef9a0a 100644
--- a/drivers/hid/hid-betopff.c
+++ b/drivers/hid/hid-betopff.c
@@ -121,8 +121,18 @@ static int betopff_init(struct hid_device *hid)
static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
+ struct hid_input *hidinput;
+ struct input_dev *dev;
int ret;
+ if (list_empty(&hdev->inputs)) {
+ hid_err(hdev, "no inputs found\n");
+ return -ENODEV;
+ }
+
+ hidinput = list_first_entry(&hdev->inputs, struct hid_input, list);
+ dev = hidinput->input;
+
if (id->driver_data)
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
--
2.17.1
next reply other threads:[~2021-08-16 20:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 20:15 F.A.Sulaiman [this message]
2021-08-17 0:05 ` [PATCH] fix slab-out-of-bounds Write in betop_probe kernel test robot
2021-08-17 0:35 ` kernel test robot
2021-08-17 20:58 ` kernel test robot
2021-08-19 18:47 ` Jiri Kosina
2021-08-22 13:43 ` [PATCH v2] HID: betop: " F.A.Sulaiman
2021-08-22 16:01 ` Pavel Skripkin
2021-08-24 15:07 ` [PATCH v3] " F.A.Sulaiman
2021-08-24 15:12 ` Pavel Skripkin
2021-09-15 14:31 ` Jiri Kosina
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=20210816201544.26405-1-asha.16@itfac.mrt.ac.lk \
--to=asha.16@itfac.mrt.ac.lk \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paskripkin@gmail.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;
as well as URLs for NNTP newsgroup(s).