All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+b71011ec0a23f4d15625@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, netdev@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: [PATCH] Bluetooth: fix oob in sco_sock_setsockopt
Date: Tue,  9 Apr 2024 21:49:12 +0800	[thread overview]
Message-ID: <tencent_D423A78448F764177A26CAB3716365096705@qq.com> (raw)
In-Reply-To: <000000000000b0848f061553f0d5@google.com>

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

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

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 43daf965a01e..815646d9e72b 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -890,7 +890,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 		break;
 
 	case BT_PKT_STATUS:
-		if (copy_from_sockptr(&opt, optval, sizeof(u32))) {
+		if (copy_from_sockptr(&opt, optval, min_t(int, sizeof(u32), optlen))) {
 			err = -EFAULT;
 			break;
 		}
-- 
2.43.0


  parent reply	other threads:[~2024-04-09 14:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  6:55 [syzbot] [bluetooth?] KASAN: slab-out-of-bounds Read in sco_sock_setsockopt syzbot
2024-04-05 10:20 ` [syzbot] [bluetooth?] KASAN: slab-out-of-bounds Read in l2cap_sock_setsockopt Edward Adam Davis
2024-04-06 13:41   ` [syzbot] [bluetooth?] KASAN: slab-out-of-bounds Read in sco_sock_setsockopt syzbot
2024-04-09 13:49 ` Edward Adam Davis [this message]
2024-04-09 14:13   ` [PATCH] Bluetooth: fix oob " Luiz Augusto von Dentz
2024-04-09 14:38   ` bluez.test.bot

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_D423A78448F764177A26CAB3716365096705@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+b71011ec0a23f4d15625@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.