Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Myungho Jung <mhjungk@gmail.com>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_uart: Add a local variable to store the result of h4_recv_buf()
Date: Mon, 21 Jan 2019 15:48:34 +0100	[thread overview]
Message-ID: <B40DFD24-B4F9-4C2D-BAB0-4DA04BCA4352@holtmann.org> (raw)
In-Reply-To: <20190120094459.GA22129@myunghoj-Precision-5530>

Hi Myungho,

>>>> In h4_recv(), if h4_recv_buf() returns error and h4_recv() is
>>>> asynchronously called again before setting rx_skb to NULL, ERR_PTR will
>>>> be dereferenced in h4_recv_buf(). Check return value in a local variable
>>>> before writing to rx_skb.
>>>> 
>>>> Reported-by: syzbot+017a32f149406df32703@syzkaller.appspotmail.com
>>>> Signed-off-by: Myungho Jung <mhjungk@gmail.com>
>>>> ---
>>>> drivers/bluetooth/hci_h4.c | 11 +++++++----
>>>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>> 
>>> patch has been applied to bluetooth-next tree.
>>> 
>>> Can you actually fix all callers of h4_recv_buf since they all suffer from the same issue.
>>> 
>>> Regards
>>> 
>>> Marcel
>>> 
>> 
>> Hi Marcel,
>> 
>> Sure, let me check other callers and fix them if applicable.
>> 
>> Thanks,
>> Myungho
>> 
> 
> Hi Marcel,
> 
> I found there are many callers that need to be fixed. So, how about checking
> error code in h4_recv_buf() instead?
> 
> diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
> index fb97a3bf069b..dea48090d2dc 100644
> --- a/drivers/bluetooth/hci_h4.c
> +++ b/drivers/bluetooth/hci_h4.c
> @@ -174,6 +174,10 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
> 	struct hci_uart *hu = hci_get_drvdata(hdev);
> 	u8 alignment = hu->alignment ? hu->alignment : 1;
> 
> +	/* Check if socket buffer is not reset yet from previous error */
> +	if (IS_ERR(skb))
> +		skb = NULL;
> +
> 	while (count) {
> 		int i, len;
> 
> 
> It is tested and verified by syzbot. The previous commit is no more needed if
> this looks better. 

please send a proper patch for this and also don’t forget drivers/bluetooth/h4_recv.h since these two are not yet consolidated.

Regards

Marcel


      reply	other threads:[~2019-01-21 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11  6:55 [PATCH] Bluetooth: hci_uart: Add a local variable to store the result of h4_recv_buf() Myungho Jung
2019-01-18  9:19 ` Marcel Holtmann
2019-01-19  8:19   ` Myungho Jung
2019-01-20  9:45     ` Myungho Jung
2019-01-21 14:48       ` Marcel Holtmann [this message]

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=B40DFD24-B4F9-4C2D-BAB0-4DA04BCA4352@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhjungk@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