public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Marco Elver <elver@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	will@kernel.org, linux-arm-kernel@lists.infradead.org,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH] arm64: fix strlen() with CONFIG_KASAN_HW_TAGS
Date: Mon, 12 Jul 2021 12:19:06 +0100	[thread overview]
Message-ID: <20210712111905.GA1992@arm.com> (raw)
In-Reply-To: <CANpmjNNhpFX_TrT5_WVLhW28tj842UTgQX_NE_WgU82ceu19Kg@mail.gmail.com>

On Mon, Jul 12, 2021 at 11:24:14AM +0200, Marco Elver wrote:
> On Mon, 12 Jul 2021 at 11:00, Mark Rutland <mark.rutland@arm.com> wrote:
> > diff --git a/arch/arm64/lib/strlen.S b/arch/arm64/lib/strlen.S
> > index 35fbdb7d6e1a..1648790e91b3 100644
> > --- a/arch/arm64/lib/strlen.S
> > +++ b/arch/arm64/lib/strlen.S
> > @@ -8,6 +8,7 @@
> >
> >  #include <linux/linkage.h>
> >  #include <asm/assembler.h>
> > +#include <asm/mte-def.h>
> >
> >  /* Assumptions:
> >   *
> > @@ -42,7 +43,16 @@
> >  #define REP8_7f 0x7f7f7f7f7f7f7f7f
> >  #define REP8_80 0x8080808080808080
> >
> > +/*
> > + * When KASAN_HW_TAGS is in use, memory is checked at MTE_GRANULE_SIZE
> > + * (16-byte) granularity, and we must ensure that no access straddles this
> > + * alignment boundary.
> > + */
> > +#ifdef CONFIG_KASAN_HW_TAGS
> > +#define MIN_PAGE_SIZE MTE_GRANULE_SIZE
> > +#else
> >  #define MIN_PAGE_SIZE 4096
> > +#endif
> >
> >         /* Since strings are short on average, we check the first 16 bytes
> >            of the string for a NUL character.  In order to do an unaligned ldp
> 
> Glancing at the code below this hunk, I see some hard coded 16,
> presumably referencing the comment here. Is the algorithm tolerant to
> MIN_PAGE_SIZE<16? I suppose that's only an issue if the granule size
> might become less than 16 for some config in future.

It's probably not tolerant as we have a cmp with MIN_PAGE_SIZE - 16. But
I'm not worried, the architecture won't go below this without some
explicit opt-in. Anyway, we can add an #error MTE_GRANULE_SIZE < 16,
just in case anyone plays with this macro.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-07-12 11:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12  9:00 [PATCH] arm64: fix strlen() with CONFIG_KASAN_HW_TAGS Mark Rutland
2021-07-12  9:24 ` Marco Elver
2021-07-12 11:19   ` Catalin Marinas [this message]
2021-07-12 14:03     ` Mark Rutland
2021-07-12 14:23       ` Robin Murphy
2021-07-12 11:38 ` Catalin Marinas
2021-07-12 12:27 ` Robin Murphy
2021-07-12 12:50 ` Will Deacon
2021-07-13 18:04 ` Andrey Konovalov

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=20210712111905.GA1992@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=andreyknvl@gmail.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=will@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