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 4D0E932C928; Fri, 17 Oct 2025 15:00:43 +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=1760713243; cv=none; b=b76gqPrVIZqkHxLtiQ3/EztApFrzLexXDU88jXbqIbSf1+6PqYuClnwIsW9UHRhzJ8uIzEBG2K1iP9d3IJClkZWrmdMhXetMKynpo68bj9e6M4qOe+g4KWt2j8L1lRzYsTYynx1UQz8mr5xAed9ADWWLn3PXxIx6EOLxAcTL+Mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760713243; c=relaxed/simple; bh=raonOP+7J0NoKdfl8JtMkHFPUU4KY3Izu6ik9DmYGqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ELMjxISEXVRotgr3trVWtb0CBGcY2nJ54p9o2zIlfxiYxQoSwvnQ2Q9jZDcTzfM7qFuzzggMMTmrx7raCxQwWGL8INp3lrM6S2cbJisoXBzoSfPQbo8FOKXU8+8/LhOf3UQOK/2CgWgx4ifSEqk8FR8sl7sMaMdmoQQv16k/zcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PofqZSf6; 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="PofqZSf6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA624C4CEFE; Fri, 17 Oct 2025 15:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760713243; bh=raonOP+7J0NoKdfl8JtMkHFPUU4KY3Izu6ik9DmYGqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PofqZSf6nkDjyPnm2D+sAG2gpMHoFM64emKjlVj0uIKAuR/estYiewHeoGxZiBkRr eetWyl+96FQ8lQJg0tYgEPDbT+E2Mdg7vMJF0Qeei2eeWTIPc1YPLA4hvYTjNPG10p Q2+CBF3jWmvkpbMvCOBtJuIFiNFHRbOcacHeFxdY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Biggers , Jakub Kicinski Subject: [PATCH 6.1 098/168] sctp: Fix MAC comparison to be constant-time Date: Fri, 17 Oct 2025 16:52:57 +0200 Message-ID: <20251017145132.638082525@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145129.000176255@linuxfoundation.org> References: <20251017145129.000176255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit dd91c79e4f58fbe2898dac84858033700e0e99fb upstream. To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this. Fixes: bbd0d59809f9 ("[SCTP]: Implement the receive and verification of AUTH chunk") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Link: https://patch.msgid.link/20250818205426.30222-3-ebiggers@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sctp/sm_make_chunk.c | 3 ++- net/sctp/sm_statefuns.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -31,6 +31,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -1796,7 +1797,7 @@ struct sctp_association *sctp_unpack_coo } } - if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) { + if (crypto_memneq(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) { *error = -SCTP_IERROR_BAD_SIG; goto fail; } --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -30,6 +30,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -4418,7 +4419,7 @@ static enum sctp_ierror sctp_sf_authenti sh_key, GFP_ATOMIC); /* Discard the packet if the digests do not match */ - if (memcmp(save_digest, digest, sig_len)) { + if (crypto_memneq(save_digest, digest, sig_len)) { kfree(save_digest); return SCTP_IERROR_BAD_SIG; }