From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>,
Guan-Chun Wu <409411716@gms.tku.edu.tw>,
Andrew Morton <akpm@linux-foundation.org>,
ebiggers@kernel.org, tytso@mit.edu, jaegeuk@kernel.org,
xiubli@redhat.com, idryomov@gmail.com, kbusch@kernel.org,
axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
home7438072@gmail.com, linux-nvme@lists.infradead.org,
linux-fscrypt@vger.kernel.org, ceph-devel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users
Date: Tue, 4 Nov 2025 10:21:40 +0200 [thread overview]
Message-ID: <aQm3lHgM-M7ZRdVT@smile.fi.intel.com> (raw)
In-Reply-To: <20251103223255.3de9f9d7@pumpkin>
On Mon, Nov 03, 2025 at 10:32:55PM +0000, David Laight wrote:
> On Mon, 3 Nov 2025 21:37:17 +0200
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > On Mon, Nov 03, 2025 at 07:29:08PM +0000, David Laight wrote:
> > > On Mon, 3 Nov 2025 20:16:46 +0200
> > > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > > On Mon, Nov 03, 2025 at 04:41:41PM +0200, Andy Shevchenko wrote:
> > > > > On Mon, Nov 03, 2025 at 01:22:13PM +0000, David Laight wrote:
...
> > > > > Pragma will be hated.
> > >
> > > They have been used in a few other places.
> > > and to disable more 'useful' warnings.
> >
> > You can go with pragma, but even though it just hides the potential issues.
> > Not my choice.
>
> In this case you really want the version that has '[ 0 .. 255 ] = -1,',
> everything else is unreadable and difficult to easily verify.
No, if it's a generated via a helper script.
> > > > > I believe there is a better way to do what you want. Let me cook a PoC.
> > > >
> > > > I tried locally several approaches and the best I can come up with is the pre-generated
> > > > (via Python script) pieces of C code that we can copy'n'paste instead of that shortened
> > > > form. So basically having a full 256 tables in the code is my suggestion to fix the build
> > > > issue. Alternatively we can generate that at run-time (on the first run) in
> > > > the similar way how prime_numbers.c does. The downside of such an approach is loosing
> > > > the const specifier, which I consider kinda important.
> > > >
> > > > Btw, in the future here might be also the side-channel attack concerns appear, which would
> > > > require to reconsider the whole algo to get it constant-time execution.
> > >
> > > The array lookup version is 'reasonably' time constant.
> >
> > The array doesn't fit the cacheline.
>
> Ignoring all the error characters it is 2 (64 byte) cache lines (if aligned
> on a 32 byte boundary).
> They'll both be resident for any sane input, I doubt an attacker can determine
> when the second one is loaded.
> In any case you can load both at the start just to make sure.
> > > One option is to offset all the array entries by 1 and subtract 1 after reading the entry.
> >
> > Yes, I was thinking of it, but found a bit weird.
> >
> > > That means that the 'error' characters have zero in the array (not -1).
> > > At least the compiler won't error that!
> > > The extra 'subtract 1' is probably just measurable.
> >
> > > But I'd consider raising a bug on gcc :-)
> >
> > And clang? :-)
>
> clang is probably easier to get fixed.
> The warning can be disabled for 'old' compilers - only one build 'tool'
> needs to detect errors.
>
> One solution is to disable the warnings in the compilers, but get sparse
> (which I think is easier to change?) to do a sane check that allows
> the entire array to default to non-zero while still checking for
> other errors.
>
> > > One of the uses of ranged designated initialisers for arrays is to change the
> > > default value - as been done here.
> > > It shouldn't cause a warning.
> >
> > This is prone to mistakes when it's not the default rewrite. I fixed already
> > twice such an issue in drivers/hid in the past few months.
>
> I was thinking that if the first initialiser is [ low ... high ] = value
> then it should be valid to change any value.
> I'm not sure what you fixed, clearly [ 4 ] = 5, [ 4 ] = 6, is an error,
> but it might be sane to allow any update of a 'range' initialiser.
You can check a Git history for that.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-11-04 8:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 10:17 [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users Guan-Chun Wu
2025-10-29 10:20 ` [PATCH v4 1/6] lib/base64: Add support for multiple variants Guan-Chun Wu
2025-10-29 10:20 ` [PATCH v4 2/6] lib/base64: Optimize base64_decode() with reverse lookup tables Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 3/6] lib/base64: rework encode/decode for speed and stricter validation Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 4/6] lib: add KUnit tests for base64 encoding/decoding Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 5/6] fscrypt: replace local base64url helpers with lib/base64 Guan-Chun Wu
2025-10-29 10:22 ` [PATCH v4 6/6] ceph: replace local base64 " Guan-Chun Wu
2025-11-01 4:09 ` [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users Andrew Morton
2025-11-03 10:24 ` Andy Shevchenko
2025-11-03 11:07 ` Kuan-Wei Chiu
2025-11-03 13:22 ` David Laight
2025-11-03 14:41 ` Andy Shevchenko
2025-11-03 18:16 ` Andy Shevchenko
2025-11-03 19:29 ` David Laight
2025-11-03 19:37 ` Andy Shevchenko
2025-11-03 22:32 ` David Laight
2025-11-04 8:21 ` Andy Shevchenko [this message]
2025-11-04 1:27 ` Andrew Morton
2025-11-04 8:22 ` Andy Shevchenko
2025-11-04 9:03 ` David Laight
2025-11-04 9:48 ` Andy Shevchenko
2025-11-05 9:48 ` David Laight
2025-11-05 14:13 ` Andy Shevchenko
2025-11-05 14:38 ` David Laight
2025-11-09 12:36 ` Guan-Chun Wu
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=aQm3lHgM-M7ZRdVT@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=409411716@gms.tku.edu.tw \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=ceph-devel@vger.kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=home7438072@gmail.com \
--cc=idryomov@gmail.com \
--cc=jaegeuk@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=tytso@mit.edu \
--cc=visitorckw@gmail.com \
--cc=xiubli@redhat.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 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.