mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: luiz.dentz@gmail.com
Cc: eadavis@qq.com, johan.hedberg@gmail.com,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	marcel@holtmann.org,
	syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] Bluetooth: hci_core: remove acl hdr handle error message
Date: Wed,  9 Oct 2024 09:07:40 +0800	[thread overview]
Message-ID: <tencent_68B1AEF2EEC20C9C27C246DAD2F2C6568906@qq.com> (raw)
In-Reply-To: <CABBYNZKiNBxqZbS7hcBrpiwHRRwAe9gXvHWNvi63qBfykR=SVg@mail.gmail.com>

On Tue, 8 Oct 2024 10:12:34 -0400, Luiz Augusto von Dentz wrote:
> On Tue, Oct 8, 2024 at 6:47 AM Edward Adam Davis <eadavis@qq.com> wrote:
> >
> > Syzbot reported a uninit-value in hci_rx_work.This is because l2cap didn't
> > execute the corresponding connection request to call l2cap_send_cmd() or
> > l2cap_do_send(), and ultimately called hci_add_acl_hdr() to set hdr->handle.
> 
> What are you talking about here, what these functions have to do with
> a local handle variable?
> 
> > Therefore, when calling the thread callback function hci_rx_work() to call
> > hci_acldata_packet, hdr->handle should not be used directly.
> 
> It is not being used directly, the handle is a local variable which
> get assigned:
> 
>     handle = __le16_to_cpu(hdr->handle);
> 
> If what you are saying is that there is no guarantee that skb->len >=
> HCI_ACL_HDR_SIZE then we probably want to replace skb_pull with
> skb_pull_data.
You are right, skb->len is too small.
But, skb_pull is ok, maybe just need to add a check.

#syz test

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d6976db02c06..cfb828452a13 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3769,7 +3769,11 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_conn *conn;
 	__u16 handle, flags;
 
-	skb_pull(skb, HCI_ACL_HDR_SIZE);
+	if (!skb_pull(skb, HCI_ACL_HDR_SIZE)) {
+		BT_ERR("ACL data packet %d, smaller than ACL HEADER Size %d\n",
+			skb->len, HCI_ACL_HDR_SIZE);
+		goto out;
+	}
 
 	handle = __le16_to_cpu(hdr->handle);
 	flags  = hci_flags(handle);
@@ -3795,6 +3799,7 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 			   handle);
 	}
 
+out:
 	kfree_skb(skb);
 }
 


  parent reply	other threads:[~2024-10-09  1:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 21:07 [syzbot] [bluetooth?] KMSAN: uninit-value in hci_rx_work syzbot
2024-10-07 10:05 ` syzbot
2024-10-07 10:53   ` Edward Adam Davis
2024-10-07 13:01     ` syzbot
2024-10-08  3:40   ` Edward Adam Davis
2024-10-08  4:29     ` syzbot
2024-10-08  9:30   ` Edward Adam Davis
2024-10-08 10:03     ` syzbot
2024-10-08 10:47   ` [PATCH] Bluetooth: hci_core: remove acl hdr handle error message Edward Adam Davis
2024-10-08 14:12     ` Luiz Augusto von Dentz
2024-10-08 14:30       ` Luiz Augusto von Dentz
2024-10-08 14:58         ` [syzbot] [bluetooth?] KMSAN: uninit-value in hci_rx_work syzbot
2024-10-09  1:07       ` Edward Adam Davis [this message]
2024-10-09  1:36         ` syzbot

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=tencent_68B1AEF2EEC20C9C27C246DAD2F2C6568906@qq.com \
    --to=eadavis@qq.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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

all inboxes | Powered by JetHome®