All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Baker <len.baker@gmx.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Len Baker <len.baker@gmx.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Phil Reid <preid@electromag.com.au>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"open list:FRAMEBUFFER LAYER" <linux-fbdev@vger.kernel.org>,
	linux-staging@lists.linux.dev,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging/fbtft: Remove all strcpy() uses
Date: Sat, 24 Jul 2021 13:09:31 +0200	[thread overview]
Message-ID: <20210724110931.GA4709@titan> (raw)
In-Reply-To: <CAHp75VeEA0=KFsfdjCnBm-b9+F+NnFWJ38nkh+qtb85XdXVWog@mail.gmail.com>

Hi,

On Sun, Jul 18, 2021 at 10:42:42PM +0300, Andy Shevchenko wrote:
> On Sun, Jul 18, 2021 at 4:43 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() but in
> > this case it is simpler to add NULL to the first position since we want
> > to empty the string.
>
> > This is a previous step in the path to remove the strcpy() function.
>
> Any document behind this (something to read on the site(s) more or
> less affiliated with what is going to happen in the kernel) to read
> background?

This is a task of the KSPP (kernel self protection project) [1]

[1] https://github.com/KSPP/linux/issues/88

>
> ...
>
> >                 case -1:
> >                         i++;
> >                         /* make debug message */
> > -                       strcpy(msg, "");
> > +                       msg[0] = 0;
>
> Strictly speaking it should be '\0'.

Ok, understood.

>
> >                         j = i + 1;
> >                         while (par->init_sequence[j] >= 0) {
> >                                 sprintf(str, "0x%02X ", par->init_sequence[j]);
>
>
> --
> With Best Regards,
> Andy Shevchenko

Thanks for the feedback,
Len

WARNING: multiple messages have this Message-ID (diff)
From: Len Baker <len.baker@gmx.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "open list:FRAMEBUFFER LAYER" <linux-fbdev@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Len Baker <len.baker@gmx.com>,
	Phil Reid <preid@electromag.com.au>
Subject: Re: [PATCH] staging/fbtft: Remove all strcpy() uses
Date: Sat, 24 Jul 2021 13:09:31 +0200	[thread overview]
Message-ID: <20210724110931.GA4709@titan> (raw)
In-Reply-To: <CAHp75VeEA0=KFsfdjCnBm-b9+F+NnFWJ38nkh+qtb85XdXVWog@mail.gmail.com>

Hi,

On Sun, Jul 18, 2021 at 10:42:42PM +0300, Andy Shevchenko wrote:
> On Sun, Jul 18, 2021 at 4:43 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() but in
> > this case it is simpler to add NULL to the first position since we want
> > to empty the string.
>
> > This is a previous step in the path to remove the strcpy() function.
>
> Any document behind this (something to read on the site(s) more or
> less affiliated with what is going to happen in the kernel) to read
> background?

This is a task of the KSPP (kernel self protection project) [1]

[1] https://github.com/KSPP/linux/issues/88

>
> ...
>
> >                 case -1:
> >                         i++;
> >                         /* make debug message */
> > -                       strcpy(msg, "");
> > +                       msg[0] = 0;
>
> Strictly speaking it should be '\0'.

Ok, understood.

>
> >                         j = i + 1;
> >                         while (par->init_sequence[j] >= 0) {
> >                                 sprintf(str, "0x%02X ", par->init_sequence[j]);
>
>
> --
> With Best Regards,
> Andy Shevchenko

Thanks for the feedback,
Len

  parent reply	other threads:[~2021-07-24 11:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-18 13:39 [PATCH] staging/fbtft: Remove all strcpy() uses Len Baker
2021-07-18 13:39 ` Len Baker
2021-07-18 19:42 ` Andy Shevchenko
2021-07-18 19:42   ` Andy Shevchenko
2021-07-19  7:53   ` Geert Uytterhoeven
2021-07-19  7:53     ` Geert Uytterhoeven
2021-07-24 11:15     ` Len Baker
2021-07-24 11:15       ` Len Baker
2021-07-24 11:09   ` Len Baker [this message]
2021-07-24 11:09     ` 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=20210724110931.GA4709@titan \
    --to=len.baker@gmx.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=preid@electromag.com.au \
    /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.