All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 v5.15.y 0/2] Backporting the patches to fix CVE-2024-35966
@ 2025-01-24  5:33 Keerthana K
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Keerthana K
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 2/2] Bluetooth: RFCOMM: " Keerthana K
  0 siblings, 2 replies; 5+ messages in thread
From: Keerthana K @ 2025-01-24  5:33 UTC (permalink / raw)
  To: stable, gregkh
  Cc: marcel, johan.hedberg, luiz.dentz, davem, kuba, linux-bluetooth,
	netdev, linux-kernel, ajay.kaher, alexey.makhalov,
	vasavi.sirnapalli, Keerthana K

Diff from v1:
Adding a dependant patch [PATCH 1/2].
Link of v1:
https://lore.kernel.org/stable/2025012010-manager-dreamlike-b5c1@gregkh/

Backporting 2 patches to fix CVE-2024-35966

Luiz Augusto von Dentz (2):
  Bluetooth: SCO: Fix not validating setsockopt user input
  Bluetooth: RFCOMM: Fix not validating setsockopt user input

 include/net/bluetooth/bluetooth.h |  9 +++++++++
 net/bluetooth/rfcomm/sock.c       | 14 +++++---------
 net/bluetooth/sco.c               | 19 ++++++++-----------
 3 files changed, 22 insertions(+), 20 deletions(-)

-- 
2.39.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input
  2025-01-24  5:33 [PATCH v2 v5.15.y 0/2] Backporting the patches to fix CVE-2024-35966 Keerthana K
@ 2025-01-24  5:33 ` Keerthana K
  2025-01-24  5:39   ` Backporting the patches to fix CVE-2024-35966 bluez.test.bot
  2025-01-24 19:52   ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Sasha Levin
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 2/2] Bluetooth: RFCOMM: " Keerthana K
  1 sibling, 2 replies; 5+ messages in thread
From: Keerthana K @ 2025-01-24  5:33 UTC (permalink / raw)
  To: stable, gregkh
  Cc: marcel, johan.hedberg, luiz.dentz, davem, kuba, linux-bluetooth,
	netdev, linux-kernel, ajay.kaher, alexey.makhalov,
	vasavi.sirnapalli, Luiz Augusto von Dentz, syzbot, Eric Dumazet,
	Sasha Levin, Keerthana K

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 51eda36d33e43201e7a4fd35232e069b2c850b01 ]

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>
---
 include/net/bluetooth/bluetooth.h |  9 +++++++++
 net/bluetooth/sco.c               | 19 ++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 9125effbf448..49926a4aa16c 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -420,6 +420,15 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
 	return NULL;
 }
 
+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);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 98a881586512..b1a905b195fe 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -822,7 +822,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 			       sockptr_t optval, unsigned int optlen)
 {
 	struct sock *sk = sock->sk;
-	int len, err = 0;
+	int err = 0;
 	struct bt_voice voice;
 	u32 opt;
 
@@ -838,10 +838,9 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 			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);
@@ -858,11 +857,10 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 
 		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 &&
@@ -875,10 +873,9 @@ 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))) {
-			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;
-- 
2.39.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 v5.15.y 2/2] Bluetooth: RFCOMM: Fix not validating setsockopt user input
  2025-01-24  5:33 [PATCH v2 v5.15.y 0/2] Backporting the patches to fix CVE-2024-35966 Keerthana K
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Keerthana K
@ 2025-01-24  5:33 ` Keerthana K
  1 sibling, 0 replies; 5+ messages in thread
From: Keerthana K @ 2025-01-24  5:33 UTC (permalink / raw)
  To: stable, gregkh
  Cc: marcel, johan.hedberg, luiz.dentz, davem, kuba, linux-bluetooth,
	netdev, linux-kernel, ajay.kaher, alexey.makhalov,
	vasavi.sirnapalli, Luiz Augusto von Dentz, syzbot, Eric Dumazet,
	Sasha Levin, Keerthana K

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit a97de7bff13b1cc825c1b1344eaed8d6c2d3e695 ]

syzbot reported rfcomm_sock_setsockopt_old() 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 rfcomm_sock_setsockopt_old
net/bluetooth/rfcomm/sock.c:632 [inline]
BUG: KASAN: slab-out-of-bounds in rfcomm_sock_setsockopt+0x893/0xa70
net/bluetooth/rfcomm/sock.c:673
Read of size 4 at addr ffff8880209a8bc3 by task syz-executor632/5064

Fixes: 9f2c8a03fbb3 ("Bluetooth: Replace RFCOMM link mode with security level")
Fixes: bb23c0ab8246 ("Bluetooth: Add support for deferring RFCOMM connection setup")
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>
---
 net/bluetooth/rfcomm/sock.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 2c95bb58f901..47e2fd38b2e3 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -657,7 +657,7 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname,
 
 	switch (optname) {
 	case RFCOMM_LM:
-		if (copy_from_sockptr(&opt, optval, sizeof(u32))) {
+		if (bt_copy_from_sockptr(&opt, sizeof(opt), optval, optlen)) {
 			err = -EFAULT;
 			break;
 		}
@@ -692,7 +692,6 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname,
 	struct sock *sk = sock->sk;
 	struct bt_security sec;
 	int err = 0;
-	size_t len;
 	u32 opt;
 
 	BT_DBG("sk %p", sk);
@@ -714,11 +713,9 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname,
 
 		sec.level = BT_SECURITY_LOW;
 
-		len = min_t(unsigned int, sizeof(sec), optlen);
-		if (copy_from_sockptr(&sec, optval, len)) {
-			err = -EFAULT;
+		err = bt_copy_from_sockptr(&sec, sizeof(sec), optval, optlen);
+		if (err)
 			break;
-		}
 
 		if (sec.level > BT_SECURITY_HIGH) {
 			err = -EINVAL;
@@ -734,10 +731,9 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname,
 			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);
-- 
2.39.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: Backporting the patches to fix CVE-2024-35966
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Keerthana K
@ 2025-01-24  5:39   ` bluez.test.bot
  2025-01-24 19:52   ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Sasha Levin
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-01-24  5:39 UTC (permalink / raw)
  To: linux-bluetooth, keerthana.kalyanasundaram

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: include/net/bluetooth/bluetooth.h:420
error: include/net/bluetooth/bluetooth.h: patch does not apply
error: patch failed: net/bluetooth/sco.c:822
error: net/bluetooth/sco.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input
  2025-01-24  5:33 ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Keerthana K
  2025-01-24  5:39   ` Backporting the patches to fix CVE-2024-35966 bluez.test.bot
@ 2025-01-24 19:52   ` Sasha Levin
  1 sibling, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-01-24 19:52 UTC (permalink / raw)
  To: stable; +Cc: Keerthana K, Sasha Levin

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: 51eda36d33e43201e7a4fd35232e069b2c850b01

WARNING: Author mismatch between patch and upstream commit:
Backport author: Keerthana K<keerthana.kalyanasundaram@broadcom.com>
Commit author: Luiz Augusto von Dentz<luiz.von.dentz@intel.com>


Status in newer kernel trees:
6.12.y | Present (exact SHA1)
6.6.y | Present (different SHA1: 72473db90900)
6.1.y | Present (different SHA1: 7bc65d23ba20)
5.15.y | Not found

Note: The patch differs from the upstream commit:
---
Failed to apply patch cleanly, falling back to interdiff...
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-5.15.y       |  Failed     |  N/A       |

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-24 19:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24  5:33 [PATCH v2 v5.15.y 0/2] Backporting the patches to fix CVE-2024-35966 Keerthana K
2025-01-24  5:33 ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Keerthana K
2025-01-24  5:39   ` Backporting the patches to fix CVE-2024-35966 bluez.test.bot
2025-01-24 19:52   ` [PATCH v2 v5.15.y 1/2] Bluetooth: SCO: Fix not validating setsockopt user input Sasha Levin
2025-01-24  5:33 ` [PATCH v2 v5.15.y 2/2] Bluetooth: RFCOMM: " Keerthana K

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.