summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2024-02-28 10:49:26 -0500
committerSasha Levin <sashal@kernel.org>2024-03-26 18:22:36 -0400
commit6d5a9d4a7bcbb7534ce45a18a52e7bd23e69d8ac (patch)
treeec2fbf391c15bafd71a6bcf098d243c08e9dd6b0
parent6e960390709966929a29eaec8bca710237a54f24 (diff)
downloadlinux-stable-6d5a9d4a7bcbb7534ce45a18a52e7bd23e69d8ac.tar.gz
linux-stable-6d5a9d4a7bcbb7534ce45a18a52e7bd23e69d8ac.tar.bz2
linux-stable-6d5a9d4a7bcbb7534ce45a18a52e7bd23e69d8ac.zip
Bluetooth: hci_core: Fix possible buffer overflow
[ 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@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/bluetooth/hci_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index f455a503f5b0..47f1eec0eb35 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2074,7 +2074,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;