[lvc-project] [PATCH 6.1.y] Bluetooth: hci_core: Fix possible buffer overflow
Sergey Shtylyov
s.shtylyov at omp.ru
Tue Sep 23 23:33:30 MSK 2025
From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>
[ Upstream commit 81137162bfaa7278785b24c1fd2e9e74f082e8e4 ]
struct hci_dev_info has a fixed size name[8] field so in the event that
hdev->name is bigger than that strcpy would attempt to write past its
size, so this fixes this problem by switching to use strscpy.
Fixes: dcda165706b9 ("Bluetooth: hci_core: Fix build warnings")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>
Signed-off-by: Sasha Levin <sashal at kernel.org>
Signed-off-by: Sergey Shtylyov <s.shtylyov at omp.ru>
---
This patch was applied to 6.1.y but later reverted by Greg Kroah-Hartman:
https://marc.info/?l=linux-stable-commits&m=173158727104658
So I'm only sending this patch to lvc-project, so LVC can decide itself
whether it's needed or not...
net/bluetooth/hci_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-stable/net/bluetooth/hci_core.c
===================================================================
--- linux-stable.orig/net/bluetooth/hci_core.c
+++ linux-stable/net/bluetooth/hci_core.c
@@ -869,7 +869,7 @@ int hci_get_dev_info(void __user *arg)
else
flags = hdev->flags;
- strcpy(di.name, hdev->name);
+ strscpy(di.name, hdev->name, sizeof(di.name));
di.bdaddr = hdev->bdaddr;
di.type = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4);
di.flags = flags;
More information about the lvc-project
mailing list