* [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls
@ 2025-04-15 16:15 Kees Cook
2025-04-15 16:19 ` Nathan Chancellor
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Kees Cook @ 2025-04-15 16:15 UTC (permalink / raw)
To: stable
Cc: Kees Cook, kernel test robot, Marcel Holtmann,
Luiz Augusto von Dentz, Josh Poimboeuf, Nathan Chancellor,
Peter Zijlstra, linux-bluetooth, Bill Wendling, Justin Stitt,
Manish Mandlik, linux-kernel, llvm, linux-hardening
Avoid double-copying of string literals. Use a "const char *" for each
string instead of copying from .rodata into stack and then into the skb.
We can go directly from .rodata to the skb.
This also works around a Clang bug (that has since been fixed[1]).
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401250927.1poZERd6-lkp@intel.com/
Fixes: ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")
Link: https://github.com/llvm/llvm-project/commit/ea2e66aa8b6e363b89df66dc44275a0d7ecd70ce [1]
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-bluetooth@vger.kernel.org
---
drivers/bluetooth/hci_vhci.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 7651321d351c..9ac22e4a070b 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_dev *hdev)
static void vhci_coredump_hdr(struct hci_dev *hdev, struct sk_buff *skb)
{
- char buf[80];
+ const char *buf;
- snprintf(buf, sizeof(buf), "Controller Name: vhci_ctrl\n");
+ buf = "Controller Name: vhci_ctrl\n";
skb_put_data(skb, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Firmware Version: vhci_fw\n");
+ buf = "Firmware Version: vhci_fw\n";
skb_put_data(skb, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Driver: vhci_drv\n");
+ buf = "Driver: vhci_drv\n";
skb_put_data(skb, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Vendor: vhci\n");
+ buf = "Vendor: vhci\n";
skb_put_data(skb, buf, strlen(buf));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
@ 2025-04-15 16:19 ` Nathan Chancellor
2025-04-15 16:29 ` Josh Poimboeuf
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-04-15 16:19 UTC (permalink / raw)
To: Kees Cook
Cc: stable, kernel test robot, Marcel Holtmann,
Luiz Augusto von Dentz, Josh Poimboeuf, Peter Zijlstra,
linux-bluetooth, Bill Wendling, Justin Stitt, Manish Mandlik,
linux-kernel, llvm, linux-hardening
On Tue, Apr 15, 2025 at 09:15:19AM -0700, Kees Cook wrote:
> Avoid double-copying of string literals. Use a "const char *" for each
> string instead of copying from .rodata into stack and then into the skb.
> We can go directly from .rodata to the skb.
>
> This also works around a Clang bug (that has since been fixed[1]).
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401250927.1poZERd6-lkp@intel.com/
> Fixes: ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")
> Link: https://github.com/llvm/llvm-project/commit/ea2e66aa8b6e363b89df66dc44275a0d7ecd70ce [1]
> Cc: stable@vger.kernel.org
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
> Cc: Josh Poimboeuf <jpoimboe@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: linux-bluetooth@vger.kernel.org
> ---
> drivers/bluetooth/hci_vhci.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
> index 7651321d351c..9ac22e4a070b 100644
> --- a/drivers/bluetooth/hci_vhci.c
> +++ b/drivers/bluetooth/hci_vhci.c
> @@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_dev *hdev)
>
> static void vhci_coredump_hdr(struct hci_dev *hdev, struct sk_buff *skb)
> {
> - char buf[80];
> + const char *buf;
>
> - snprintf(buf, sizeof(buf), "Controller Name: vhci_ctrl\n");
> + buf = "Controller Name: vhci_ctrl\n";
> skb_put_data(skb, buf, strlen(buf));
>
> - snprintf(buf, sizeof(buf), "Firmware Version: vhci_fw\n");
> + buf = "Firmware Version: vhci_fw\n";
> skb_put_data(skb, buf, strlen(buf));
>
> - snprintf(buf, sizeof(buf), "Driver: vhci_drv\n");
> + buf = "Driver: vhci_drv\n";
> skb_put_data(skb, buf, strlen(buf));
>
> - snprintf(buf, sizeof(buf), "Vendor: vhci\n");
> + buf = "Vendor: vhci\n";
> skb_put_data(skb, buf, strlen(buf));
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
2025-04-15 16:19 ` Nathan Chancellor
@ 2025-04-15 16:29 ` Josh Poimboeuf
2025-04-15 17:04 ` bluez.test.bot
2025-04-15 20:20 ` [PATCH] " patchwork-bot+bluetooth
3 siblings, 0 replies; 7+ messages in thread
From: Josh Poimboeuf @ 2025-04-15 16:29 UTC (permalink / raw)
To: Kees Cook
Cc: stable, kernel test robot, Marcel Holtmann,
Luiz Augusto von Dentz, Nathan Chancellor, Peter Zijlstra,
linux-bluetooth, Bill Wendling, Justin Stitt, Manish Mandlik,
linux-kernel, llvm, linux-hardening
On Tue, Apr 15, 2025 at 09:15:19AM -0700, Kees Cook wrote:
> Avoid double-copying of string literals. Use a "const char *" for each
> string instead of copying from .rodata into stack and then into the skb.
> We can go directly from .rodata to the skb.
>
> This also works around a Clang bug (that has since been fixed[1]).
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401250927.1poZERd6-lkp@intel.com/
> Fixes: ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")
> Link: https://github.com/llvm/llvm-project/commit/ea2e66aa8b6e363b89df66dc44275a0d7ecd70ce [1]
> Cc: stable@vger.kernel.org
> Signed-off-by: Kees Cook <kees@kernel.org>
Thanks!
Reviewed-by: Josh Poimboeuf <jpoimboe@kernel.org>
--
Josh
^ permalink raw reply [flat|nested] 7+ messages in thread* RE: Bluetooth: vhci: Avoid needless snprintf() calls
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
2025-04-15 16:19 ` Nathan Chancellor
2025-04-15 16:29 ` Josh Poimboeuf
@ 2025-04-15 17:04 ` bluez.test.bot
2025-04-15 17:16 ` Kees Cook
2025-04-15 20:20 ` [PATCH] " patchwork-bot+bluetooth
3 siblings, 1 reply; 7+ messages in thread
From: bluez.test.bot @ 2025-04-15 17:04 UTC (permalink / raw)
To: linux-bluetooth, kees
[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]
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=953638
---Test result---
Test Summary:
CheckPatch PENDING 0.27 seconds
GitLint PENDING 0.23 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 24.58 seconds
CheckAllWarning PASS 26.80 seconds
CheckSparse PASS 30.60 seconds
BuildKernel32 PASS 24.17 seconds
TestRunnerSetup PASS 463.69 seconds
TestRunner_l2cap-tester PASS 21.37 seconds
TestRunner_iso-tester PASS 32.87 seconds
TestRunner_bnep-tester PASS 4.71 seconds
TestRunner_mgmt-tester FAIL 120.00 seconds
TestRunner_rfcomm-tester PASS 7.85 seconds
TestRunner_sco-tester PASS 12.70 seconds
TestRunner_ioctl-tester PASS 8.43 seconds
TestRunner_mesh-tester PASS 6.25 seconds
TestRunner_smp-tester PASS 7.33 seconds
TestRunner_userchan-tester PASS 5.06 seconds
IncrementalBuild PENDING 0.84 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 483 (98.6%), Failed: 3, Not Run: 4
Failed Test Cases
LL Privacy - Set Flags 2 (Enable RL) Failed 0.147 seconds
LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.183 seconds
LL Privacy - Start Discovery 2 (Disable RL) Failed 0.185 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
` (2 preceding siblings ...)
2025-04-15 17:04 ` bluez.test.bot
@ 2025-04-15 20:20 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2025-04-15 20:20 UTC (permalink / raw)
To: Kees Cook
Cc: stable, lkp, marcel, luiz.dentz, jpoimboe, nathan, peterz,
linux-bluetooth, morbo, justinstitt, mmandlik, linux-kernel, llvm,
linux-hardening
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 15 Apr 2025 09:15:19 -0700 you wrote:
> Avoid double-copying of string literals. Use a "const char *" for each
> string instead of copying from .rodata into stack and then into the skb.
> We can go directly from .rodata to the skb.
>
> This also works around a Clang bug (that has since been fixed[1]).
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401250927.1poZERd6-lkp@intel.com/
> Fixes: ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")
> Link: https://github.com/llvm/llvm-project/commit/ea2e66aa8b6e363b89df66dc44275a0d7ecd70ce [1]
> Cc: stable@vger.kernel.org
> Signed-off-by: Kees Cook <kees@kernel.org>
>
> [...]
Here is the summary with links:
- Bluetooth: vhci: Avoid needless snprintf() calls
https://git.kernel.org/bluetooth/bluetooth-next/c/3b32759328e9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-15 20:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
2025-04-15 16:19 ` Nathan Chancellor
2025-04-15 16:29 ` Josh Poimboeuf
2025-04-15 17:04 ` bluez.test.bot
2025-04-15 17:16 ` Kees Cook
2025-04-15 19:11 ` Luiz Augusto von Dentz
2025-04-15 20:20 ` [PATCH] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox