mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+837ba09d9db969068367@syzkaller.appspotmail.com
Cc: johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org,
	linux-kernel@vger.kernel.org, luiz.dentz@gmail.com,
	marcel@holtmann.org, syzkaller-bugs@googlegroups.com,
	netdev@vger.kernel.org
Subject: [PATCH] Bluetooth: fix oob in hci_sock_setsockopt
Date: Tue,  9 Apr 2024 21:42:51 +0800	[thread overview]
Message-ID: <tencent_EDCC88A7DB46D3D2F7C64449976EC56EE006@qq.com> (raw)
In-Reply-To: <0000000000007558ae061553f41b@google.com>

If len < sizeof(opt) it will trigger oob, so take the min of them.

Reported-by: syzbot+837ba09d9db969068367@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 net/bluetooth/hci_sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 4ee1b976678b..cee7ec1adbd2 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1946,7 +1946,7 @@ static int hci_sock_setsockopt_old(struct socket *sock, int level, int optname,
 
 	switch (optname) {
 	case HCI_DATA_DIR:
-		if (copy_from_sockptr(&opt, optval, sizeof(opt))) {
+		if (copy_from_sockptr(&opt, optval, min_t(int, sizeof(opt), len))) {
 			err = -EFAULT;
 			break;
 		}
-- 
2.43.0


  parent reply	other threads:[~2024-04-09 13:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  6:56 [syzbot] [bluetooth?] KASAN: slab-out-of-bounds Read " syzbot
2024-04-05  9:27 ` Edward Adam Davis
2024-04-06  5:09   ` syzbot
2024-04-05  9:49 ` Hillf Danton
2024-04-06  5:22   ` syzbot
2024-04-09 13:42 ` Edward Adam Davis [this message]
2024-04-09 14:13   ` [PATCH] Bluetooth: fix oob " Luiz Augusto von Dentz
2024-05-08  1:11 ` [syzbot] [bluetooth?] KASAN: slab-out-of-bounds Read " 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_EDCC88A7DB46D3D2F7C64449976EC56EE006@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=netdev@vger.kernel.org \
    --cc=syzbot+837ba09d9db969068367@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®