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 428662BD033; Mon, 27 Oct 2025 18:43: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=1761590623; cv=none; b=Re73OOKIoU9LQouWAyMxdD4VMhJvnV5VFiUf7UQGe87K7as3p2Tkh/F+nfRZRuq1VoJ3I7foTftBrxj7zIswig53suQmDgMpRYcCWgKQ2N/kMOaBBZa0fCO3c3wYKpRyKRlUeK5ZvQXHAaXR9TfznePBe1m6jTUu8Cjvg+a+dXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761590623; c=relaxed/simple; bh=KIjP9TVSk5j/ST7sYoNtfQH+2AmXJoXZe3O7Z/Keggc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgZomSs8YyoZJySigUiZaB/bYYIUVTaYdK4hj9PVLIdWuiuZVw1qKzNkiFbBvPhZCuZSyCFx0a3EuWR4yXDNFLl3a+uCGLqK64CdaWo7X6PqKDAyp+KBXth3pDTBLXShkpM5bOYuwIWH5QN2mZmZfrObFhVjIaYlZHwtRNBI6Yw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=InzkjAo0; 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="InzkjAo0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9EDEC4CEFD; Mon, 27 Oct 2025 18:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761590623; bh=KIjP9TVSk5j/ST7sYoNtfQH+2AmXJoXZe3O7Z/Keggc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=InzkjAo0AgSscCfaHoxdzV2rqOwoeAt2yLZt5tGohCq5KBlLprIKGqrAubYFl6vF7 3d6Vpi392j72ZqHw/6QmpgprKfhUDOViT85CTnSvcv5FNyfKUn3UMSgrWEzOzJal+2 /ONlocoyknPBc6ZwOZPFoRDUQJL1QQ27rN8tXOFA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Biggers , Jakub Kicinski Subject: [PATCH 5.4 115/224] sctp: Fix MAC comparison to be constant-time Date: Mon, 27 Oct 2025 19:34:21 +0100 Message-ID: <20251027183512.065687429@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183508.963233542@linuxfoundation.org> References: <20251027183508.963233542@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 5.4-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 @@ -1758,7 +1759,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 @@ -4303,7 +4304,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; }