From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 997423B0AF1; Mon, 23 Mar 2026 14:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774276836; cv=none; b=WdLe8gtkGFbePTPtBKs8Hr8wqj8SmWzJAPEGz9eXSYQ5U8IGDRg+1n38P1K5RFcfTRy9xOT0pyKCcmf9AowJdk5UVGZfSxK6Z5SD3yfcxLHnWBHPRoj1fooEimWhgv/TrI2oOMqUW28KEKMqxMVTfY28yCUI6tiZlm4Qk80iQqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774276836; c=relaxed/simple; bh=IY3HOV3IuyNTsc6/SvGD8i7MRf3Zxo8l8fvH0K5atkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NO6DsF5USympmmZFoRDyWWerscjF1y8P0CaHilzO3qqPjApLL5kP0tkdsn6E0VsG+YBREzWbg8LzlgXOJNVNidVVxLTcDDUiJD1cfxxvNxksOsgPfdsjg7pA0FaOQM3JzSEg3qmHGPWsdT0+hyzEMe2pRa8zdHC1MOONvKX6xrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xfihHu07; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xfihHu07" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9FE2C4CEF7; Mon, 23 Mar 2026 14:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774276836; bh=IY3HOV3IuyNTsc6/SvGD8i7MRf3Zxo8l8fvH0K5atkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xfihHu07JFxNaUavFc6koPFmyWeOQ0Nok6NoQwX47D2oo6oc1cFD6dS8CZ6sefipA UVleWnzuJCX9Aw4hCwS+DyHZt9UMeq7zr2BTamPc1jc+jlSmd7cy3QaMmY8Qi7icyt gGUAVgZrS8Rzu7fSwkc3Nzxrz7Kbwxfa7/A0LBvI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Paulo Alcantara (Red Hat)" , Eric Biggers , Steve French Subject: [PATCH 6.12 221/460] smb: client: Compare MACs in constant time Date: Mon, 23 Mar 2026 14:43:37 +0100 Message-ID: <20260323134531.929588608@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134526.647552166@linuxfoundation.org> References: <20260323134526.647552166@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 26bc83b88bbbf054f0980a4a42047a8d1e210e4c upstream. To prevent timing attacks, MAC comparisons need to be constant-time. Replace the memcmp() with the correct function, crypto_memneq(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Acked-by: Paulo Alcantara (Red Hat) Signed-off-by: Eric Biggers Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/cifsencrypt.c | 3 ++- fs/smb/client/smb2transport.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) --- a/fs/smb/client/cifsencrypt.c +++ b/fs/smb/client/cifsencrypt.c @@ -24,6 +24,7 @@ #include #include "../common/arc4.h" #include +#include static size_t cifs_shash_step(void *iter_base, size_t progress, size_t len, void *priv, void *priv2) @@ -257,7 +258,7 @@ int cifs_verify_signature(struct smb_rqs /* cifs_dump_mem("what we think it should be: ", what_we_think_sig_should_be, 16); */ - if (memcmp(server_response_sig, what_we_think_sig_should_be, 8)) + if (crypto_memneq(server_response_sig, what_we_think_sig_should_be, 8)) return -EACCES; else return 0; --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "cifsglob.h" #include "cifsproto.h" #include "smb2proto.h" @@ -732,7 +733,8 @@ smb2_verify_signature(struct smb_rqst *r if (rc) return rc; - if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) { + if (crypto_memneq(server_response_sig, shdr->Signature, + SMB2_SIGNATURE_SIZE)) { cifs_dbg(VFS, "sign fail cmd 0x%x message id 0x%llx\n", shdr->Command, shdr->MessageId); return -EACCES;