From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, syzbot <syzkaller@googlegroups.com>,
Eric Dumazet <edumazet@google.com>,
Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Sasha Levin <sashal@kernel.org>,
Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Subject: [PATCH 5.15 12/24] Bluetooth: SCO: Fix not validating setsockopt user input
Date: Thu, 30 Jan 2025 15:02:04 +0100 [thread overview]
Message-ID: <20250130140127.790745686@linuxfoundation.org> (raw)
In-Reply-To: <20250130140127.295114276@linuxfoundation.org>
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
commit 51eda36d33e43201e7a4fd35232e069b2c850b01 upstream.
syzbot reported sco_sock_setsockopt() is copying data without
checking user input length.
BUG: KASAN: slab-out-of-bounds in copy_from_sockptr_offset
include/linux/sockptr.h:49 [inline]
BUG: KASAN: slab-out-of-bounds in copy_from_sockptr
include/linux/sockptr.h:55 [inline]
BUG: KASAN: slab-out-of-bounds in sco_sock_setsockopt+0xc0b/0xf90
net/bluetooth/sco.c:893
Read of size 4 at addr ffff88805f7b15a3 by task syz-executor.5/12578
Fixes: ad10b1a48754 ("Bluetooth: Add Bluetooth socket voice option")
Fixes: b96e9c671b05 ("Bluetooth: Add BT_DEFER_SETUP option to sco socket")
Fixes: 00398e1d5183 ("Bluetooth: Add support for BT_PKT_STATUS CMSG data for SCO connections")
Fixes: f6873401a608 ("Bluetooth: Allow setting of codec for HFP offload use case")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/net/bluetooth/bluetooth.h | 9 +++++++++
net/bluetooth/sco.c | 19 ++++++++-----------
2 files changed, 17 insertions(+), 11 deletions(-)
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -487,6 +487,15 @@ static inline struct sk_buff *bt_skb_sen
return skb;
}
+static inline int bt_copy_from_sockptr(void *dst, size_t dst_size,
+ sockptr_t src, size_t src_size)
+{
+ if (dst_size > src_size)
+ return -EINVAL;
+
+ return copy_from_sockptr(dst, src, dst_size);
+}
+
int bt_to_errno(u16 code);
void hci_sock_set_flag(struct sock *sk, int nr);
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -829,7 +829,7 @@ static int sco_sock_setsockopt(struct so
sockptr_t optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
- int len, err = 0;
+ int err = 0;
struct bt_voice voice;
u32 opt;
@@ -845,10 +845,9 @@ static int sco_sock_setsockopt(struct so
break;
}
- if (copy_from_sockptr(&opt, optval, sizeof(u32))) {
- err = -EFAULT;
+ err = bt_copy_from_sockptr(&opt, sizeof(opt), optval, optlen);
+ if (err)
break;
- }
if (opt)
set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
@@ -865,11 +864,10 @@ static int sco_sock_setsockopt(struct so
voice.setting = sco_pi(sk)->setting;
- len = min_t(unsigned int, sizeof(voice), optlen);
- if (copy_from_sockptr(&voice, optval, len)) {
- err = -EFAULT;
+ err = bt_copy_from_sockptr(&voice, sizeof(voice), optval,
+ optlen);
+ if (err)
break;
- }
/* Explicitly check for these values */
if (voice.setting != BT_VOICE_TRANSPARENT &&
@@ -882,10 +880,9 @@ static int sco_sock_setsockopt(struct so
break;
case BT_PKT_STATUS:
- if (copy_from_sockptr(&opt, optval, sizeof(u32))) {
- err = -EFAULT;
+ err = bt_copy_from_sockptr(&opt, sizeof(opt), optval, optlen);
+ if (err)
break;
- }
if (opt)
sco_pi(sk)->cmsg_mask |= SCO_CMSG_PKT_STATUS;
next prev parent reply other threads:[~2025-01-30 14:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 14:01 [PATCH 5.15 00/24] 5.15.178-rc1 review Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 01/24] ASoC: wm8994: Add depends on MFD core Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 02/24] ASoC: samsung: Add missing selects for MFD_WM8994 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 03/24] seccomp: Stub for !CONFIG_SECCOMP Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 04/24] scsi: iscsi: Fix redundant response for ISCSI_UEVENT_GET_HOST_STATS request Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 05/24] irqchip/sunxi-nmi: Add missing SKIP_WAKE flag Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 06/24] ASoC: samsung: Add missing depends on I2C Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 5.15 07/24] regmap: detach regmap from dev on regmap_exit Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 08/24] mptcp: dont always assume copied data in mptcp_cleanup_rbuf() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 09/24] gfs2: Truncate address space when flipping GFS2_DIF_JDATA flag Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 10/24] net: sched: fix ets qdisc OOB Indexing Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 11/24] vfio/platform: check the bounds of read/write syscalls Greg Kroah-Hartman
2025-01-30 14:02 ` Greg Kroah-Hartman [this message]
2025-01-30 14:02 ` [PATCH 5.15 13/24] Bluetooth: RFCOMM: Fix not validating setsockopt user input Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 14/24] fs/ntfs3: Additional check in ntfs_file_release Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 15/24] platform/chrome: cros_ec_typec: Check for EC driver Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 16/24] ipv4: ip_tunnel: Fix suspicious RCU usage warning in ip_tunnel_find() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 17/24] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 18/24] wifi: iwlwifi: add a few rate index validity checks Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 19/24] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 20/24] Revert "usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 21/24] ALSA: usb-audio: Add delay quirk for USB Audio Device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 22/24] Input: atkbd - map F23 key to support default copilot shortcut Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 23/24] Input: xpad - add unofficial Xbox 360 wireless receiver clone Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 5.15 24/24] Input: xpad - add support for wooting two he (arm) Greg Kroah-Hartman
2025-01-30 18:47 ` [PATCH 5.15 00/24] 5.15.178-rc1 review Mark Brown
2025-01-30 21:11 ` Florian Fainelli
2025-01-31 5:38 ` Jon Hunter
2025-01-31 14:04 ` Ron Economos
2025-01-31 15:23 ` Naresh Kamboju
2025-01-31 17:01 ` Muhammad Usama Anjum
2025-02-01 6:30 ` Vijayendra Suman
2025-02-01 8:14 ` [PATCH 5.15] " Hardik Garg
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=20250130140127.790745686@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=edumazet@google.com \
--cc=keerthana.kalyanasundaram@broadcom.com \
--cc=luiz.von.dentz@intel.com \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzkaller@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.