From: Nathan Chancellor <nathan@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: stable@vger.kernel.org, kernel test robot <lkp@intel.com>,
Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-bluetooth@vger.kernel.org, Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Manish Mandlik <mmandlik@google.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls
Date: Tue, 15 Apr 2025 09:19:20 -0700 [thread overview]
Message-ID: <20250415161920.GA1692211@ax162> (raw)
In-Reply-To: <20250415161518.work.889-kees@kernel.org>
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
>
next prev parent reply other threads:[~2025-04-15 16:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 16:15 [PATCH] Bluetooth: vhci: Avoid needless snprintf() calls Kees Cook
2025-04-15 16:19 ` Nathan Chancellor [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250415161920.GA1692211@ax162 \
--to=nathan@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=mmandlik@google.com \
--cc=morbo@google.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.