LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: "F.A.Sulaiman" <asha.16@itfac.mrt.ac.lk>,
	jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] HID: betop: fix slab-out-of-bounds Write in betop_probe
Date: Tue, 24 Aug 2021 18:12:46 +0300	[thread overview]
Message-ID: <e8e7f55a-75dd-6631-13e0-eab350712a38@gmail.com> (raw)
In-Reply-To: <20210824150730.9118-1-asha.16@itfac.mrt.ac.lk>

On 8/24/21 6:07 PM, F.A.Sulaiman wrote:
> Syzbot reported slab-out-of-bounds Write bug in hid-betopff driver.
> The problem is the driver assumes the device must have an input report but
> some malicious devices violate this assumption.
> 
> So this patch checks hid_device's input is non empty before it's been used.
> 
> Reported-by: syzbot+07efed3bc5a1407bd742@syzkaller.appspotmail.com
> Signed-off-by: F.A. SULAIMAN <asha.16@itfac.mrt.ac.lk>


Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>


> ---
>   drivers/hid/hid-betopff.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-betopff.c b/drivers/hid/hid-betopff.c
> index 0790fbd3fc9a..467d789f9bc2 100644
> --- a/drivers/hid/hid-betopff.c
> +++ b/drivers/hid/hid-betopff.c
> @@ -56,15 +56,22 @@ static int betopff_init(struct hid_device *hid)
>   {
>   	struct betopff_device *betopff;
>   	struct hid_report *report;
> -	struct hid_input *hidinput =
> -			list_first_entry(&hid->inputs, struct hid_input, list);
> +	struct hid_input *hidinput;
>   	struct list_head *report_list =
>   			&hid->report_enum[HID_OUTPUT_REPORT].report_list;
> -	struct input_dev *dev = hidinput->input;
> +	struct input_dev *dev;
>   	int field_count = 0;
>   	int error;
>   	int i, j;
>   
> +	if (list_empty(&hid->inputs)) {
> +		hid_err(hid, "no inputs found\n");
> +		return -ENODEV;
> +	}
> +
> +	hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
> +	dev = hidinput->input;
> +
>   	if (list_empty(report_list)) {
>   		hid_err(hid, "no output reports found\n");
>   		return -ENODEV;
> 


  reply	other threads:[~2021-08-24 15:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 20:15 [PATCH] " F.A.Sulaiman
2021-08-17  0:05 ` 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 [this message]
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=e8e7f55a-75dd-6631-13e0-eab350712a38@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=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 \
    --subject='Re: [PATCH v3] HID: betop: fix slab-out-of-bounds Write in betop_probe' \
    /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

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).