From patchwork Sat Jun 10 02:59:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9779621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DAB9C60393 for ; Sat, 10 Jun 2017 03:00:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF6C2857D for ; Sat, 10 Jun 2017 03:00:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C047728556; Sat, 10 Jun 2017 03:00:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id C9F4C28556 for ; Sat, 10 Jun 2017 02:59:59 +0000 (UTC) Received: (qmail 26065 invoked by uid 550); 10 Jun 2017 02:59:45 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 24052 invoked from network); 10 Jun 2017 02:59:35 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=mail; bh=m+Ap dyynjEtepmDcTq2sUjvQoEw=; b=3RjIeAkScZ/sQur6YAdx0SIMWIPmqoNccaZk UGspwIEw5f86/I4InASN7D2mk1La99CiGkJgzxBzCTjY/sm58w70yt1PYLK6YTS4 Ro7fpHheHhjVeic5radq4GdZW9X6z/n52sRSK/fo71dRfRWzjNPkLDv4n2b8Ntod RH3QiblyzrkHiGbpnFPvqJoYhwU5PwNF7TzFWAC9Mfe/IfHJvrVn0vViwD9HYgFj a+Di5LAaFExZmlAigQjtCkPEpWA7oFU59N/oHwR11GXBAyloetwibvjD76dL1eJF R1b20MuLWtMy84iy4JFSgqzG1jXqlc12igyiNtTQBZOCRuYWUw== From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: "Jason A. Donenfeld" , "David S. Miller" , netdev@vger.kernel.org, stable@vger.kernel.org Date: Sat, 10 Jun 2017 04:59:08 +0200 Message-Id: <20170610025912.6499-3-Jason@zx2c4.com> In-Reply-To: <20170610025912.6499-1-Jason@zx2c4.com> References: <20170610025912.6499-1-Jason@zx2c4.com> Subject: [kernel-hardening] [PATCH 2/6] net/ipv6: use constant time memory comparison for mac X-Virus-Scanned: ClamAV using ClamSMTP Otherwise, we enable a MAC forgery via timing attack. Signed-off-by: Jason A. Donenfeld Cc: "David S. Miller" Cc: netdev@vger.kernel.org Cc: stable@vger.kernel.org --- net/ipv6/seg6_hmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c index f950cb53d5e3..54213c83b44e 100644 --- a/net/ipv6/seg6_hmac.c +++ b/net/ipv6/seg6_hmac.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -274,7 +275,7 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb) if (seg6_hmac_compute(hinfo, srh, &ipv6_hdr(skb)->saddr, hmac_output)) return false; - if (memcmp(hmac_output, tlv->hmac, SEG6_HMAC_FIELD_LEN) != 0) + if (crypto_memneq(hmac_output, tlv->hmac, SEG6_HMAC_FIELD_LEN)) return false; return true;