Skip to contentSkip to conversation

Bluetooth: bnep: refactor deprecated strcpy

PATCH Applied Ajith P V 3 participants 3 messages Aug 11

Subsystems (2)
lore
Share & tools
lore

Ajith P V

author
#0 lore raw

PATCH 1/1 Bluetooth: bnep: refactor deprecated strcpy

The strcpy() function is deprecated across the kernel tree and moving towards complete elimination. It provides no verification limits against buffer overflows and does not guarantee strict boundary restrictions [1][2].

Replace instances of strcpy() in net/bluetooth/bnep/core.c with the safer strscpy() alternative. Since both target destination blocks are statically allocated fixed-size arrays within their structure definitions, leverage the compile time sizeof() operator to explicitly pass the destination buffer capacities.

---
 net/bluetooth/bnep/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/bnep/core.c +2 -2
index f7d88c33e23e..0dde82e9a085 100644
@@ -670,7 +670,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
 		goto failed;
 	}
 
-	strcpy(req->device, dev->name);
+	strscpy(req->device, dev->name, sizeof(req->device));
 	up_write(&bnep_session_sem);
 	return 0;
 
@@ -712,7 +712,7 @@ static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s)
 
 	memset(ci, 0, sizeof(*ci));
 	memcpy(ci->dst, s->eh.h_source, ETH_ALEN);
-	strcpy(ci->device, s->dev->name);
+	strscpy(ci->device, s->dev->name, sizeof(ci->device));
 	ci->flags = s->flags & valid_flags;
 	ci->state = s->state;
 	ci->role  = s->role;
Signature · 1 line
2.43.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1144013

---Test result---

Test Summary:

CheckPatch                    PASS      0.49 seconds
VerifyFixes                   PASS      0.09 seconds
VerifySignedoff               PASS      3.21 seconds
GitLint                       PASS      3.54 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      21.03 seconds
CheckAllWarning               PASS      23.13 seconds
CheckSparse                   PASS      22.89 seconds
BuildKernel32                 PASS      20.37 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      378.17 seconds
TestRunner_bnep-tester        PASS      16.23 seconds
IncrementalBuild              PASS      22.84 seconds

Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found

https://github.com/bluez/bluetooth-next/pull/571

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Ajith P V
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 5 lines · On Tue, 11 Aug 2026 09:49:32 +0000 you wrote:

The strcpy() function is deprecated across the kernel tree and moving towards complete elimination. It provides no verification limits against buffer overflows and does not guarantee strict boundary restrictions [1][2].

Quoted 7 lines

Replace instances of strcpy() in net/bluetooth/bnep/core.c with the safer strscpy() alternative. Since both target destination blocks are statically allocated fixed-size arrays within their structure definitions, leverage the compile time sizeof() operator to explicitly pass the destination buffer capacities.

[...]

Here is the summary with links:
- Bluetooth: bnep: refactor deprecated strcpy

    https://git.kernel.org/bluetooth/bluetooth-next/c/6d5e3062ef68

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html