From: Len Baker <len.baker@gmx.com>
To: Adam Sampson <ats@offog.org>
Cc: Len Baker <len.baker@gmx.com>, 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: Sat, 24 Jul 2021 14:22:21 +0200 [thread overview]
Message-ID: <20210724112139.GC4709@titan> (raw)
In-Reply-To: <y2awnpnfvnc.fsf@offog.org>
Hi,
On Sun, Jul 18, 2021 at 05:12:55PM +0100, Adam Sampson wrote:
> 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)?
Apologies. I will work on it and I will send a new version for review.
Thanks for the feedback.
>
> Thanks,
>
> --
> Adam Sampson <ats@offog.org> <http://offog.org/>
Regards,
Len
prev parent reply other threads:[~2021-07-24 12:22 UTC|newest]
Thread overview: 3+ 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:12 ` Adam Sampson
2021-07-24 12:22 ` Len Baker [this message]
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=20210724112139.GC4709@titan \
--to=len.baker@gmx.com \
--cc=ats@offog.org \
--cc=johan.hedberg@gmail.com \
--cc=keescook@chromium.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).