linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>, Hannes Reinecke <hare@suse.de>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [GIT PULL] Block driver changes for 5.20-rc1
Date: Tue, 2 Aug 2022 14:18:57 -0700	[thread overview]
Message-ID: <CAHk-=wi+HuC_bs7VMTJSjp0vug9DRMY9+jKcsQryU9Eqofdxbg@mail.gmail.com> (raw)
In-Reply-To: <87f60512-9242-49d1-eae1-394eb7a34760@kernel.dk>

On Sun, Jul 31, 2022 at 8:03 AM Jens Axboe <axboe@kernel.dk> 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

  reply	other threads:[~2022-08-02 21:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-31 15:03 [GIT PULL] Block driver changes for 5.20-rc1 Jens Axboe
2022-08-02 21:18 ` Linus Torvalds [this message]
2022-08-02 21:33   ` Keith Busch
2022-08-02 21:35     ` Jens Axboe
2022-08-02 21:50       ` Linus Torvalds
2022-08-02 22:24         ` Jens Axboe
2022-08-02 22:26           ` Jens Axboe
2022-08-02 22:27           ` Linus Torvalds
2022-08-02 22:33             ` Jens Axboe
2022-08-02 22:48               ` Linus Torvalds
2022-08-02 22:59                 ` Jens Axboe
2022-08-02 23:03                   ` Linus Torvalds
2022-08-02 23:08                     ` Jens Axboe
2022-08-03 15:16                       ` Jens Axboe
2022-08-03 16:26                         ` Linus Torvalds
2022-08-03 16:51                           ` Nick Desaulniers
2022-08-03 16:53                             ` Jens Axboe
2022-08-03 17:00                               ` Linus Torvalds
2022-08-03 17:38                               ` Nick Desaulniers
2022-08-03 17:45                                 ` Jens Axboe
2022-08-03 18:06                                   ` Nick Desaulniers
2022-08-04 16:17                                     ` Jens Axboe
2022-08-03 16:56                             ` Linus Torvalds
2022-08-03 17:30   ` Christoph Hellwig
2022-08-03 17:42     ` Linus Torvalds
2022-08-03 17:49       ` Christoph Hellwig
2022-08-03 17:54         ` Linus Torvalds
2022-08-06  7:44           ` Christoph Hellwig

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='CAHk-=wi+HuC_bs7VMTJSjp0vug9DRMY9+jKcsQryU9Eqofdxbg@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=sagi@grimberg.me \
    /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 NNTP newsgroup(s).