Linux-Hardening mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Kees Cook' <keescook@chromium.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Hsin-Yu.Chen <harry021633@gmail.com>,
	"andy@kernel.org" <andy@kernel.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-hardening@vger.kernel.org"
	<linux-hardening@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 2/2] string: improve strlen performance
Date: Sun, 5 May 2024 13:38:48 +0000	[thread overview]
Message-ID: <7c1565516531425c8f7cf5ffd5582741@AcuMS.aculab.com> (raw)
In-Reply-To: <202405020809.C8973634BF@keescook>

From: Kees Cook
> Sent: 02 May 2024 16:11
> 
> On Thu, May 02, 2024 at 06:03:04PM +0300, Andy Shevchenko wrote:
> > On Thu, May 2, 2024 at 5:59 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > > On Thu, May 2, 2024 at 5:14 PM Hsin-Yu.Chen <harry021633@gmail.com> wrote:
> >
> > And on top of that, check what this code will do on the architectures
> > that do not support unaligned access. If everything is fine, mention
> > this in the commit message. Btw, your commit message needs
> > elaboration, e.g., pointing to the test case (which is absent in this
> > patch, I assume it's already in the kernel?) and step-by-step
> > instructions on how you got the mentioned results with details of the
> > hardware you used for that.
> 
> I might be worth looking at the implementation of strscpy(), which is
> doing similar multi-byte steps and handles unaligned access.

And x86 really doesn't care about unaligned accesses (for normal registers).
But it is important to not accidentally run off the end of a page.

There is also the whole question of the typical string length.
For short strings you've already lost by the time you've aligned
the address.

On 32bit the whole bit-twiddling may not be worth it at all.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      parent reply	other threads:[~2024-05-05 13:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 14:13 [PATCH 2/2] string: improve strlen performance Hsin-Yu.Chen
2024-05-02 14:59 ` Andy Shevchenko
2024-05-02 15:03   ` Andy Shevchenko
2024-05-02 15:10     ` Kees Cook
2024-05-02 15:38       ` Andy Shevchenko
2024-05-05 13:38       ` David Laight [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=7c1565516531425c8f7cf5ffd5582741@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=harry021633@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).