All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Hossu <hossu.alexandru@gmail.com>
To: mlombard@arkamax.eu
Cc: martin.petersen@oracle.com, bvanassche@acm.org, ddiss@suse.de,
	target-devel@vger.kernel.org, linux-scsi@vger.kernel.org,
	stable@vger.kernel.org, hossu.alexandru@gmail.com
Subject: Re: [PATCH v2] scsi: target: iscsi: validate CHAP_R length before base64 decode
Date: Wed, 20 May 2026 09:53:16 -0700 (PDT)	[thread overview]
Message-ID: <6a0de6fc.2d57a604.3a8602.5396@mx.google.com> (raw)
In-Reply-To: <DINMKOIB4PRJ.1Y571RHF6NAQJ@arkamax.eu>

On Wed, May 20, 2026, Maurizio Lombardi <mlombard@arkamax.eu> wrote:
> There is something that doesn't totally convince me about this length check.
> Couldn't chap_r contain those Base64 padding '=' characters that
> would make strlen(chap_r) too big to pass this check?

Correct. For SHA-256, a padded encoding of the 32-byte digest is 44
characters (43 data + one '='), but DIV_ROUND_UP(32 * 4, 3) = 43, so a
legitimate padded response would be incorrectly rejected.

v3 strips trailing '=' before the comparison:

	size_t r_len = strlen(chap_r);

	while (r_len > 0 && chap_r[r_len - 1] == '=')
		r_len--;
	if (r_len > DIV_ROUND_UP(chap->digest_size * 4, 3)) {
		pr_err("Malformed CHAP_R: base64 payload too long\n");
		goto out;
	}

chap_base64_decode() already handles '=' by returning early, so
stripping them from the pre-check does not affect decoding.

v3 below.

Alexandru

  reply	other threads:[~2026-05-20 16:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 12:18 [PATCH] scsi: target: iscsi: validate CHAP_R length before base64 decode Alexandru Hossu
2026-05-18 14:40 ` David Disseldorp
2026-05-18 23:50 ` [PATCH v2] " Alexandru Hossu
2026-05-20 15:56   ` Maurizio Lombardi
2026-05-20 16:53     ` Alexandru Hossu [this message]
2026-05-20 18:02     ` Dmitry Bogdanov
2026-05-21  0:43       ` Alexandru Hossu
2026-05-22  9:53         ` Hannes Reinecke
2026-05-18 23:51 ` [PATCH] " Alexandru Hossu
2026-05-20 16:52 ` [PATCH v3] " Alexandru Hossu
2026-05-21 14:38   ` David Disseldorp
2026-05-22  9:56     ` Hannes Reinecke
2026-05-22 10:37       ` Alexandru Hossu

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=6a0de6fc.2d57a604.3a8602.5396@mx.google.com \
    --to=hossu.alexandru@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=ddiss@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mlombard@arkamax.eu \
    --cc=stable@vger.kernel.org \
    --cc=target-devel@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 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.