From: Adam Sampson <ats@offog.org>
To: Len Baker <len.baker@gmx.com>
Cc: Kees Cook <keescook@chromium.org>,
Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] drivers/bluetooth: Remove all strcpy() uses
Date: Sun, 18 Jul 2021 17:12:55 +0100 [thread overview]
Message-ID: <y2awnpnfvnc.fsf@offog.org> (raw)
In-Reply-To: <20210718153626.18382-1-len.baker@gmx.com> (Len Baker's message of "Sun, 18 Jul 2021 17:36:26 +0200")
Len Baker <len.baker@gmx.com> writes:
> strcpy() performs no bounds checking on the destination buffer. This
> could result in linear overflows beyond the end of the buffer, leading
> to all kinds of misbehaviors. The safe replacement is strscpy() but in
> this case it is better to use the scnprintf to simplify the arithmetic.
>
> This is a previous step in the path to remove the strcpy() function
> entirely from the kernel.
>
> Signed-off-by: Len Baker <len.baker@gmx.com>
> ---
> drivers/bluetooth/btmrvl_sdio.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
> index cddd350beba3..d6674b367e05 100644
> --- a/drivers/bluetooth/btmrvl_sdio.c
> +++ b/drivers/bluetooth/btmrvl_sdio.c
> @@ -1350,6 +1350,7 @@ static void btmrvl_sdio_coredump(struct device *dev)
> u8 *dbg_ptr, *end_ptr, *fw_dump_data, *fw_dump_ptr;
[...]
> + size += scnprintf(fw_dump_ptr + size,
> + sizeof(fw_dump_ptr) - size,
[...]
> + size += scnprintf(fw_dump_ptr + size,
> + sizeof(fw_dump_ptr) - size,
sizeof(fw_dump_ptr) there looks wrong -- you want the size of the buffer
it points to (fw_dump_len + 1)?
Thanks,
--
Adam Sampson <ats@offog.org> <http://offog.org/>
next prev parent reply other threads:[~2021-07-18 16:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-18 15:36 [PATCH] drivers/bluetooth: Remove all strcpy() uses Len Baker
2021-07-18 16:11 ` bluez.test.bot
2021-07-18 16:12 ` Adam Sampson [this message]
2021-07-24 12:22 ` [PATCH] " Len Baker
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=y2awnpnfvnc.fsf@offog.org \
--to=ats@offog.org \
--cc=johan.hedberg@gmail.com \
--cc=keescook@chromium.org \
--cc=len.baker@gmx.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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.