From patchwork Mon Mar 1 16:11:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 388714 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3625780jap; Mon, 1 Mar 2021 11:20:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNFjz7N9BZRVFCISol15TEBzpBz0ZceNxTqK9jGTJZtcf9qDpjHKMi8o8fnhbLhRKtS+t2 X-Received: by 2002:aa7:d1c2:: with SMTP id g2mr17327479edp.46.1614626446766; Mon, 01 Mar 2021 11:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614626446; cv=none; d=google.com; s=arc-20160816; b=R78DtAyoRdXu/yKvDHqmhHg+zdCAUyUgcTunwZuanl5smEK1T6HNvRJmz2l5F45rvG htKYLQTOeQU/mZeyiCUJOdKpO3PmsQgwNv2e+sHelyEyGpR9OujP+qnSoyFfBMkmTUlu n7CrHaM0ceNPDtAfBcG9EjzAfJpoT5DwQcqeUmPMJg5226vyP1mUpWoX+RmR0/hmin3e 41eZEeN1ByrSQ1E5vGHZnePPlPwBO3nJ4bT24PtJ2c5meoExnVuTOhJnBEmFT3tAgFfj LCSNGxGROiuDs9RvS5MbYfmThVkACHGTrOcimJAcDOzCbKhy6iY/NkXVSn9vtuIXf8DN RZhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7xktmkKLq7LOeXQdztp3ceq1D8sfTBUwOoUqQDATe9A=; b=p3K9sR619OjLCsSfgbE0e7CB1CnpI8fK7QuqY6JlRsK+geREu/7vl9E+qKLoopLHBh aQ/tQUApUGzOPyR1fGmlZL5tBoN+2MYfd6sNj2bbF45n8/W49pKOKj7nRyP06qQaYQmx FHZj+lknA2T6wrBACPblaEUz0C9fnPUq0q4kWba5fUN6koGfpCqsH/Sd0vg2xfEVqgZA HXv7iLLeDGPxoF0+d0jzRhhK5BqloeePnHKx9SNLmTso1MFBRaflMHX8GRLALk3Wcmm0 L+sgQSNlbwuEfhwlpaF4XLsJUfFrZsuCi/oueLdNFddmsBbKS8ZB00CnFqnc4qU4+qpt XmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qArYeMwV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si8513951ejj.20.2021.03.01.11.20.46; Mon, 01 Mar 2021 11:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qArYeMwV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240449AbhCATTK (ORCPT + 13 others); Mon, 1 Mar 2021 14:19:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:43894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241249AbhCATPX (ORCPT ); Mon, 1 Mar 2021 14:15:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76EAA6506A; Mon, 1 Mar 2021 17:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619439; bh=rUGtxYsV0xaAxa5VF/jXvKRKx7OfzZR/KK2xzGjZlwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qArYeMwVNdfCQyPKpVZitlmuRC810/1oSiH0O3NskVYIMFar+0r73Udc7cO3yUDNI CFVZULEV5pGAunYYR0gxZlX+y8vHIOyAVGf0yYNB2gMus2x60qOsSgfhU/OQ3G5MO7 j6blb5uF2tYRvzOiULPCMwApZIcXkzDM4BZecDyY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 453/663] wireguard: device: do not generate ICMP for non-IP packets Date: Mon, 1 Mar 2021 17:11:41 +0100 Message-Id: <20210301161204.304229512@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jason A. Donenfeld [ Upstream commit 99fff5264e7ab06f45b0ad60243475be0a8d0559 ] If skb->protocol doesn't match the actual skb->data header, it's probably not a good idea to pass it off to icmp{,v6}_ndo_send, which is expecting to reply to a valid IP packet. So this commit has that early mismatch case jump to a later error label. Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/wireguard/device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.27.0 diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c index c9f65e96ccb04..c1fd3e04dd3ba 100644 --- a/drivers/net/wireguard/device.c +++ b/drivers/net/wireguard/device.c @@ -138,7 +138,7 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev) else if (skb->protocol == htons(ETH_P_IPV6)) net_dbg_ratelimited("%s: No peer has allowed IPs matching %pI6\n", dev->name, &ipv6_hdr(skb)->daddr); - goto err; + goto err_icmp; } family = READ_ONCE(peer->endpoint.addr.sa_family); @@ -201,12 +201,13 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev) err_peer: wg_peer_put(peer); -err: - ++dev->stats.tx_errors; +err_icmp: if (skb->protocol == htons(ETH_P_IP)) icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); else if (skb->protocol == htons(ETH_P_IPV6)) icmpv6_ndo_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0); +err: + ++dev->stats.tx_errors; kfree_skb(skb); return ret; }