From: David Disseldorp <ddiss@suse.de>
To: target-devel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org, David Disseldorp <ddiss@suse.de>
Subject: [PATCH 2/2] scsi: target: use constant-time crypto_memneq for CHAP digests
Date: Fri, 5 Jun 2026 22:16:48 +1000 [thread overview]
Message-ID: <20260605122019.24146-3-ddiss@suse.de> (raw)
In-Reply-To: <20260605122019.24146-1-ddiss@suse.de>
A constant-time memory comparison is more suitable than plain memcmp()
for authentication digest comparison.
CHAP digests use an authenticator-provided random challenge, so any
timing side-channel shouldn't be easily exploitable.
Reported-by: Sashiko (gemini/gemini-3.1-pro-preview)
Link: https://sashiko.dev/#/patchset/20260521151121.808477-1-hossu.alexandru%40gmail.com
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
drivers/target/iscsi/iscsi_target_auth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index 5858cc3089796..f3c0cdd318300 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -9,6 +9,7 @@
******************************************************************************/
#include <crypto/hash.h>
+#include <crypto/utils.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/err.h>
@@ -408,7 +409,7 @@ static int chap_server_compute_hash(
pr_debug("[server] %s Server Digest: %s\n",
chap->digest_name, response);
- if (memcmp(server_digest, client_digest, chap->digest_size) != 0) {
+ if (crypto_memneq(server_digest, client_digest, chap->digest_size)) {
pr_debug("[server] %s Digests do not match!\n\n",
chap->digest_name);
goto out;
--
2.51.0
next prev parent reply other threads:[~2026-06-05 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 12:16 [PATCH 0/2] scsi: target: minor CHAP fixes David Disseldorp
2026-06-05 12:16 ` [PATCH 1/2] scsi: target: fix hexadecimal CHAP_I handling David Disseldorp
2026-06-05 16:02 ` Lee Duncan
2026-06-08 15:12 ` John Garry
2026-06-05 12:16 ` David Disseldorp [this message]
2026-06-05 16:04 ` [PATCH 2/2] scsi: target: use constant-time crypto_memneq for CHAP digests Lee Duncan
2026-06-09 1:38 ` [PATCH 0/2] scsi: target: minor CHAP fixes Martin K. Petersen
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=20260605122019.24146-3-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=linux-scsi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox