Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Jeremy Erazo <mendozayt13@gmail.com>
Cc: security@kernel.org, Christoph Hellwig <hch@infradead.org>,
	Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Hannes Reinecke <hare@suse.de>, Jens Axboe <axboe@kernel.dk>,
	linux-nvme@lists.infradead.org, stable@vger.kernel.org
Subject: Re: nvmet: pre-auth heap OOB read in DH-HMAC-CHAP authentication (data->hl unchecked in nvmet_auth_reply)
Date: Tue, 2 Jun 2026 09:50:38 +0100	[thread overview]
Message-ID: <ah6ZXmX1anVLrr76@kbusch-mbp> (raw)
In-Reply-To: <6a1e4ed5.f18a29c3.bfe2b.5229@mx.google.com>

On Mon, Jun 01, 2026 at 08:32:37PM -0700, Jeremy Erazo wrote:
>   @@ -119,6 +120,16 @@ static u8 nvmet_auth_reply(struct nvmet_req *req, void *d)
>                     __func__, ctrl->cntlid, req->sq->qid,
>                     data->hl, data->cvalid, dhvlen);
> 
>   +        /* Confirm the transferred length actually contains the
>   +         * rval payload the message body advertises. The host
>   +         * response is hl bytes; with cvalid set, hl more bytes
>   +         * of challenge follow; with dhvlen set, dhvlen more
>   +         * bytes of DH value follow.
>   +         */
>   +        if (tl < sizeof(*data) + data->hl +
>   +                 (data->cvalid ? data->hl : 0) + dhvlen)
>   +                return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD;
>   +

I think the fix should change the ternary condition from data->cvalid to
(data->cvalid || dhvlen):

  if (tl < sizeof(*data) + data->hl +
           ((data->cvalid || dhvlen) ? data->hl : 0) + dhvlen)
          return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD;

But this is a bit of an eye-sore, so let's make this easier to read by
lifting the ternary computation outside the 'if' section and store the
result in a temporary variable.


  parent reply	other threads:[~2026-06-02  8:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02  3:32 nvmet: pre-auth heap OOB read in DH-HMAC-CHAP authentication (data->hl unchecked in nvmet_auth_reply) Jeremy Erazo
2026-06-02  6:23 ` Greg KH
2026-06-02  8:50 ` Keith Busch [this message]
2026-06-02  8:56   ` Keith Busch
  -- strict thread matches above, loose matches on Subject: below --
2026-06-02  3:32 Jeremy Erazo

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=ah6ZXmX1anVLrr76@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=kch@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=mendozayt13@gmail.com \
    --cc=sagi@grimberg.me \
    --cc=security@kernel.org \
    --cc=stable@vger.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