Re: [GIT PULL] Block driver changes for 5.20-rc1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 31, 2022 at 8:03 AM Jens Axboe <axboe@xxxxxxxxx> wrote:
>
> On top of the core block changes, here are the block driver changes for
> 5.20-rc1. In detail:

No.

I pulled, and I ended up immediately unpulling again.

Why?

This is pure garbage that doesn't even compile:

> - NVMe pull request via Christoph
>         - add support for In-Band authentication (Hannes Reinecke)

because it is  testing the address of an array member (NOT a pointer!)
being NULL.

Lookie here:

  static struct nvme_auth_dhgroup_map {
          const char name[16];
          const char kpp[16];
  } dhgroup_map[] = {
        ...

  const char *nvme_auth_dhgroup_name(u8 dhgroup_id)
  {
        if ((dhgroup_id > ARRAY_SIZE(dhgroup_map)) ||
            !dhgroup_map[dhgroup_id].name ||
            !strlen(dhgroup_map[dhgroup_id].name))
                return NULL;
        return dhgroup_map[dhgroup_id].name;
  }


That test of "name" being NULL is complete garbage, because "name[]"
is not a pointer, it's a member of the struct, so the address is
simply *within* the struct, and testing for NULL is nonsensical.

As a result, gcc quite reasonably complains

    drivers/nvme/common/auth.c: In function ‘nvme_auth_dhgroup_name’:
    drivers/nvme/common/auth.c:59:13: error: the comparison will
always evaluate as ‘true’ for the address of ‘name’ will never be NULL
[-Werror=address]
       59 |             !dhgroup_map[dhgroup_id].name ||
          |             ^

and the exact same completely broken pattern ends up existing about
five more times in that same source file with other structures and
other structure members (ie there another case of exactly the same
thing, except with 'kpp[]', and then there are other cases of the same
thing except with the 'hash_map[]' structure etc.

This code cannot have gotten much testing at all.

Sure, it's possible that the warnings are compiler version dependent,
but I have two completely different compilers that both complain about
this thing.

Clang just has a slightly different error string, and says

    drivers/nvme/common/auth.c:59:31: error: address of array
'dhgroup_map[dhgroup_id].name' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]
                !dhgroup_map[dhgroup_id].name ||
                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

instead.

And no, I don't want some "fix up broken code after the fact" commit
on top. I want that code excised, and I don't want to see another pull
request before it's (a) gone and (b) somebody has looked at where the
testing of this COMPLETELY failed.

                   Linus




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux