Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3924920pxb; Tue, 2 Mar 2021 02:00:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJygJEdEH280QImxBqbnsTckhSYzORblJkOTCwpjdI2FwZ/XtWmwdMzuc88+YI1bL6g9lyeC X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr20218013ejo.247.1614679205879; Tue, 02 Mar 2021 02:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614679205; cv=none; d=google.com; s=arc-20160816; b=F18y1+GnkFa6/rq1MoDtm8fFLHqgWe44wi5Q8jgjaxvqz8KnX2E7L6yiqjIEWrWp+D I5nwemcIBbQiJ6dPS2Hsupwjbm53OWJiKGptrpybhSwT4x6M+X/JLe1zo8nQt2t+R3Lt h/BjIdDd938WHVBu4C7xYEUS9Qm7Y8a17GbX9V0zSl+8DwpVtgEqi1XhuAAkFl2ARjUW fRb3Y3nVqMkztQOC4n5D6a1aFv7VtcrgEqzIIr1YKppCMsStQG4+LofXx8L5zodnn4IM WT/5rzyFemniIGcwG9b+jndOTXpfN632NYW2bW2LfM8N3Qp9uKv6wuWu5vp/+zl9XOJN A9Hw== 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=gog71IIzlR4yZDkpj8MuGl22Kc+y2WrS7G5tIZof5mYtpkED+J4xj3mkkwEb9i+ARk tRg3+m40PTz51zEJ5B+g8Wxl1Bd/AsVjfNDi9W2GwMHviBSCO2Np/JyH55dnDkEiAg0h 6OB2ay4p4NAWa+BsGpOOEvrIITofF72euLaD83v2epJB+HIWLI4JjMz9ZFr8BsSYheAB KtXNQlFK2ZXijXVBpFWk3GiWPsu9TMBFOdDRAc5KFk3XVq20jKB9ZT+iRV8eAoh56KZN 7c/ITEpDFQ9xDgHv7nIbiww7TMX5pdD+wZEFnCAt6w6RrvaeXD9gRCEf0ynBDA+zERsR wo9g== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 z4si9520839ejj.20.2021.03.02.01.59.39; Tue, 02 Mar 2021 02:00:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1379330AbhCBB1s (ORCPT + 99 others); Mon, 1 Mar 2021 20:27:48 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; } -- 2.27.0