From patchwork Mon Mar 1 16:11:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388737 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3662268jap; Mon, 1 Mar 2021 12:15:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwHqLrp8cRRnmGeFJfWmEmfvIjSZi0wTkVMyQ1JWOckIifsQ5HXkupErocY5lxkKFAdUwF X-Received: by 2002:a17:906:5797:: with SMTP id k23mr1324734ejq.515.1614629756093; Mon, 01 Mar 2021 12:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614629756; cv=none; d=google.com; s=arc-20160816; b=s0GTyxcQESvJa0RbBHZp9A3LNDrYWJGSwLd/hXojG+FeVULrEyGWtcwnR2I/4O/eaE fCUiY73Zv6rC04lfbYiwHw99agD1i30IGb5GxdNHO/HuXZgUSlWRa7Fdra8SyZPQedRK 3F1CgXQQYYKbsTF47B6mlR1f1eJCB7MruI+KQwQUJ0j73RShSHZ6jkl3LD61Fi2QSvKK KKlI/Kh4Ig5vGGg436Q+BTS/P/ELJlAPxcjbvjM1YLjUSx3kO+Av63j5H4/Asw1Q4tXQ FVMQpxJ5q4s2P55wHu3UUjbOpZbSvRigGxbSRSjD4krnjDDXJuZBqP6jB0Z2RjNdj+M3 +o7A== 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=iR9IQAeeMvI3hQVlmGqWs5JrHPPwWEHJ52gatnA4IFw=; b=xK2JHlYtYPL12n7Z25rLh586DZ7yHcCXD26QoNBhpiPW7xWFogl9mz/eTXsByEVO3/ VvcHcwPWUBZuAjAwzMHEqPRvIEYYVbKd8Tm84xsFgSbEjoO65iY917ZGarfoerouTJ6h qkgdqhXx5j1yGFwMkYA1y0p/IaFUD41SW73hc6BxfTsq+0OeDkoX6dtDuNvII84R51wg DSqkdMQ4xFxfcgVVI3kB0XpbySbYi39TmK+sOp83p6PVuxyrHpvoQ3ACCphMq2iC96nA efCDXEUV0mUi8eQzgAaMEfbzjmyurXatkfpUB60E/3CFNmVn+DGOG8XxJ2d75n6oYA9Y 77vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=viBgC5m2; 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 g12si14730744edj.22.2021.03.01.12.15.55; Mon, 01 Mar 2021 12:15:56 -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=viBgC5m2; 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 S243106AbhCAUOy (ORCPT + 13 others); Mon, 1 Mar 2021 15:14:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:37646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234783AbhCAUFR (ORCPT ); Mon, 1 Mar 2021 15:05:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4F1665074; Mon, 1 Mar 2021 17:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614621510; bh=D4N8CCUdhPlcoRdIszCejWL/nP1kIlsHKmSCT+6rI2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=viBgC5m22/suJFcOZZHYuYxWtR7psZJRLtXxKrlGf3zVPSEVsF/DQZfkGvGxdJzRh 0HsoMzNzgy9pJCt1t3gPb2O0u5N0VCM/lGDEp9PumyYaX62zTsxu+sPYQZO+Tq+zNw njmAHw0jtEINtdlBVcE1YJEPhcyls8Y5sBbQ9N08= 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.11 543/775] wireguard: device: do not generate ICMP for non-IP packets Date: Mon, 1 Mar 2021 17:11:51 +0100 Message-Id: <20210301161228.319027821@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161201.679371205@linuxfoundation.org> References: <20210301161201.679371205@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 a3ed49cd95c31..82ce757c852ee 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; }