From: Len Baker <len.baker@gmx.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
Kees Cook <keescook@chromium.org>
Cc: Len Baker <len.baker@gmx.com>,
David Laight <David.Laight@ACULAB.COM>,
Robin Murphy <robin.murphy@arm.com>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Magnus Damm <magnus.damm@gmail.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
linux-hardening@vger.kernel.org,
linux-arm-msm <linux-arm-msm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy()
Date: Sat, 31 Jul 2021 15:59:57 +0200 [thread overview]
Message-ID: <20210731135957.GB1979@titan> (raw)
In-Reply-To: <CAMuHMdUdmv+YmdtjGJV2Lp_Rvar4kN4uSgSTYqXX9CtCJ+qoRw@mail.gmail.com>
Hi,
On Mon, Jul 26, 2021 at 10:03:18AM +0200, Geert Uytterhoeven wrote:
> Hi Len,
>
> On Sun, Jul 25, 2021 at 5:15 PM Len Baker <len.baker@gmx.com> wrote:
> > 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().
> >
> > Signed-off-by: Len Baker <len.baker@gmx.com>
>
> Thanks for your patch!
>
> > ---
> > This is a task of the KSPP [1]
> >
> > [1] https://github.com/KSPP/linux/issues/88
>
> Any chance the almost one year old question in that ticket can be
> answered?
I'm a kernel newbie and I have chosen this task as a starting point. So,
I think that someone with more experience could answer this question.
Kees: Any comments?
>
> > drivers/soc/renesas/rcar-sysc.c | 6 ++++--
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> But please see my comments below...
>
> > --- a/drivers/soc/renesas/r8a779a0-sysc.c
> > +++ b/drivers/soc/renesas/r8a779a0-sysc.c
> > @@ -404,19 +404,21 @@ static int __init r8a779a0_sysc_pd_init(void)
> > for (i = 0; i < info->num_areas; i++) {
> > const struct r8a779a0_sysc_area *area = &info->areas[i];
> > struct r8a779a0_sysc_pd *pd;
> > + size_t area_name_size;
>
> I wouldn't mind a shorter name, like "n".
Ok, I will change this for the next version.
> >
> > if (!area->name) {
> > /* Skip NULLified area */
> > continue;
> > }
> >
> > - pd = kzalloc(sizeof(*pd) + strlen(area->name) + 1, GFP_KERNEL);
> > + area_name_size = strlen(area->name) + 1;
> > + pd = kzalloc(sizeof(*pd) + area_name_size, GFP_KERNEL);
> > if (!pd) {
> > error = -ENOMEM;
> > goto out_put;
> > }
> >
> > - strcpy(pd->name, area->name);
> > + strscpy(pd->name, area->name, area_name_size);
> > pd->genpd.name = pd->name;
> > pd->pdr = area->pdr;
> > pd->flags = area->flags;
> > diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
> > index 53387a72ca00..0eae5ce0eeb0 100644
> > --- a/drivers/soc/renesas/rcar-sysc.c
> > +++ b/drivers/soc/renesas/rcar-sysc.c
> > @@ -396,19 +396,21 @@ static int __init rcar_sysc_pd_init(void)
> > for (i = 0; i < info->num_areas; i++) {
> > const struct rcar_sysc_area *area = &info->areas[i];
> > struct rcar_sysc_pd *pd;
> > + size_t area_name_size;
>
> Likewise.
Ok, understood.
Regards,
Len
WARNING: multiple messages have this Message-ID (diff)
From: Len Baker <len.baker@gmx.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
Kees Cook <keescook@chromium.org>
Cc: Len Baker <len.baker@gmx.com>,
David Laight <David.Laight@ACULAB.COM>,
Robin Murphy <robin.murphy@arm.com>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Magnus Damm <magnus.damm@gmail.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
linux-hardening@vger.kernel.org,
linux-arm-msm <linux-arm-msm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy()
Date: Sat, 31 Jul 2021 15:59:57 +0200 [thread overview]
Message-ID: <20210731135957.GB1979@titan> (raw)
In-Reply-To: <CAMuHMdUdmv+YmdtjGJV2Lp_Rvar4kN4uSgSTYqXX9CtCJ+qoRw@mail.gmail.com>
Hi,
On Mon, Jul 26, 2021 at 10:03:18AM +0200, Geert Uytterhoeven wrote:
> Hi Len,
>
> On Sun, Jul 25, 2021 at 5:15 PM Len Baker <len.baker@gmx.com> wrote:
> > 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().
> >
> > Signed-off-by: Len Baker <len.baker@gmx.com>
>
> Thanks for your patch!
>
> > ---
> > This is a task of the KSPP [1]
> >
> > [1] https://github.com/KSPP/linux/issues/88
>
> Any chance the almost one year old question in that ticket can be
> answered?
I'm a kernel newbie and I have chosen this task as a starting point. So,
I think that someone with more experience could answer this question.
Kees: Any comments?
>
> > drivers/soc/renesas/rcar-sysc.c | 6 ++++--
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> But please see my comments below...
>
> > --- a/drivers/soc/renesas/r8a779a0-sysc.c
> > +++ b/drivers/soc/renesas/r8a779a0-sysc.c
> > @@ -404,19 +404,21 @@ static int __init r8a779a0_sysc_pd_init(void)
> > for (i = 0; i < info->num_areas; i++) {
> > const struct r8a779a0_sysc_area *area = &info->areas[i];
> > struct r8a779a0_sysc_pd *pd;
> > + size_t area_name_size;
>
> I wouldn't mind a shorter name, like "n".
Ok, I will change this for the next version.
> >
> > if (!area->name) {
> > /* Skip NULLified area */
> > continue;
> > }
> >
> > - pd = kzalloc(sizeof(*pd) + strlen(area->name) + 1, GFP_KERNEL);
> > + area_name_size = strlen(area->name) + 1;
> > + pd = kzalloc(sizeof(*pd) + area_name_size, GFP_KERNEL);
> > if (!pd) {
> > error = -ENOMEM;
> > goto out_put;
> > }
> >
> > - strcpy(pd->name, area->name);
> > + strscpy(pd->name, area->name, area_name_size);
> > pd->genpd.name = pd->name;
> > pd->pdr = area->pdr;
> > pd->flags = area->flags;
> > diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
> > index 53387a72ca00..0eae5ce0eeb0 100644
> > --- a/drivers/soc/renesas/rcar-sysc.c
> > +++ b/drivers/soc/renesas/rcar-sysc.c
> > @@ -396,19 +396,21 @@ static int __init rcar_sysc_pd_init(void)
> > for (i = 0; i < info->num_areas; i++) {
> > const struct rcar_sysc_area *area = &info->areas[i];
> > struct rcar_sysc_pd *pd;
> > + size_t area_name_size;
>
> Likewise.
Ok, understood.
Regards,
Len
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-07-31 14:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-25 15:14 [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy() Len Baker
2021-07-25 15:14 ` Len Baker
2021-07-26 8:03 ` Geert Uytterhoeven
2021-07-26 8:03 ` Geert Uytterhoeven
2021-07-28 8:36 ` David Laight
2021-07-28 8:36 ` David Laight
2021-07-28 9:36 ` Robin Murphy
2021-07-28 9:36 ` Robin Murphy
2021-07-31 14:53 ` Len Baker
2021-07-31 14:53 ` Len Baker
2021-07-31 13:59 ` Len Baker [this message]
2021-07-31 13:59 ` 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=20210731135957.GB1979@titan \
--to=len.baker@gmx.com \
--cc=David.Laight@ACULAB.COM \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=geert@linux-m68k.org \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=robin.murphy@arm.com \
--cc=ssantosh@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.