mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Peter Collingbourne <peter@pcc.me.uk>
Cc: Qiliang Yuan <odys.yuan@gmail.com>, Kees Cook <kees@kernel.org>,
	Andy Shevchenko <andy@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	kasan-dev@googlegroups.com
Subject: Re: [PATCH] string: instrument the word loads in sized_strscpy()
Date: Sat, 17 Oct 2026 23:19:09 -0700	[thread overview]
Message-ID: <20261017231909.c9fa8474da8fc1079f112891@linux-foundation.org> (raw)
In-Reply-To: <CAPQLkRhXZwozmfhNd_PEx1ihwdH1_5qthP6PANYJ_m-v9vfQTw@mail.gmail.com>

On Sat, 17 Oct 2026 22:05:03 -0700 Peter Collingbourne <peter@pcc.me.uk> wrote:

> > --- a/lib/string.c
> > +++ b/lib/string.c
> > @@ -19,6 +19,7 @@
> >  #include <linux/bug.h>
> >  #include <linux/ctype.h>
> >  #include <linux/errno.h>
> > +#include <linux/instrumented.h>
> >  #include <linux/limits.h>
> >  #include <linux/linkage.h>
> >  #include <linux/minmax.h>
> > @@ -132,6 +133,12 @@ ssize_t sized_strscpy(char *dest, const char *src, size_t count)
> >                 unsigned long c, data;
> >
> >  #ifdef CONFIG_DCACHE_WORD_ACCESS
> > +               /*
> > +                * Unlike read_word_at_a_time(), load_unaligned_zeropad() is
> > +                * not instrumented. Check the first byte, which must be
> > +                * readable, as read_word_at_a_time() does.
> > +                */
> > +               instrument_read(src + res, 1);
> >                 c = load_unaligned_zeropad(src+res);
> 
> It looks like at least some of the other callers of
> load_unaligned_zeropad() have the same problem. Would it be better to
> add the instrument_read() call to load_unaligned_zeropad()?

Well, with this setup (Kconfig-time and runtime), does our user
actually care about performance?  Can we simply use plain old C code in
these situations and not compromise the runtime checking?

I'm not sure why we have the assembly thing, really.  If the kernel is
spending significant amounts of time doing string copies then why the
heck?

      reply	other threads:[~2026-10-18  6:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18  4:53 Qiliang Yuan
2026-10-18  5:05 ` Peter Collingbourne
2026-10-18  6:19   ` Andrew Morton [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=20261017231909.c9fa8474da8fc1079f112891@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=andy@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=odys.yuan@gmail.com \
    --cc=peter@pcc.me.uk \
    --cc=ryabinin.a.a@gmail.com \
    --cc=vincenzo.frascino@arm.com \
    /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

all inboxes | Powered by JetHome®