[PATCH 1/2] bitmap: add sanity check function for find_bit()

Linus Torvalds torvalds at linux-foundation.org
Sun Oct 23 15:19:24 PDT 2022


On Wed, Oct 19, 2022 at 8:24 PM Yury Norov <yury.norov at gmail.com> wrote:
>
> This patch adds runtime check for the pointers to be aligned.

No. Don't add pointless things like this. It only adds code, with no advantage.

The bitmap ops all operate on 'unsigned long', and if a bitmap isn't
aligned, we'll take a fault on the architectures that don't do
unaligned accesses natively.

And the find-bit functions simply aren't special enough to have this
kind of random testing, when the *basic* bitmap functions like
"set_bit()" and friends all do the accesses without any alignment
checks.

The fact that filesystem code often uses bitmap functions with a cast
from 'char *' is immaterial. Those things are already aligned
(typically they are a whole disk block). They just weren't an array of
'unsigned long'.

                  Linus



More information about the linux-arm-kernel mailing list