Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6819002ybi; Mon, 8 Jul 2019 09:09:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7Qf7BXNH30WvRH3GW2dC10Rg0hQR58yFrwQcAnILknzo/KadzLeJyBsGS0VONhE8fzpSD X-Received: by 2002:a17:90a:24ac:: with SMTP id i41mr26634902pje.124.1562602199625; Mon, 08 Jul 2019 09:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562602199; cv=none; d=google.com; s=arc-20160816; b=pnmHS6dMMuFCxIIyPOK5aUlBrWxIO43wZKxIcK6lkJP1OzXrYcCj4emWvv7duZb5Ub r6pK7gnroMiNh7PXJTGqNRSau4wtSUlQLoo8nHrFxsvdtsY+jzvmL7Kaj9coo+LLuit/ GHB/wPZYEXgYW9WSTqy9IhnmO+a55g/xMyimLj7aPST9PiRwBJDPuEkRVcGUBgWoeJXJ +k/cshMsWXtPW+JJx3oPIf0IWBp2ioWX0vNm1LEWKo5n2Et5ETfVT5776jHFsiv9Vv0C bIwzVZu/6oOif8/ZFHt4Z1ECOiSWk+JcV9THVYPwtX7sSALpyPHUF+//jIcYoHled52t SeuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OJlPCh/ve1/3sF+F48+TaicXhaoT/hLZxA6XgwFZ5YI=; b=wfrRKju1rVFli17ztOvRbjHfRv1Rmv7VBLOsBTJmK525vwkFH6PiPLuQ32nGHuf+Ev AYr1Mc+Ac73wYJCYxa9868E8giuUYm/7HZHzSFrdOELDOFT5gp9MwOchVvT93dcKj+rb LIZf+L3vjJpzcXcJZ+QawBBK/47iPL9zMXpMbTt+bm/dcFqn00oTFnfp252NHP61KFNu x5iIlUuGFHdobfBeP4nrNTD1h1tpV1U5MI83ufy49dH5mwRA81WCv68Q5ERoKsX2unpw mhachR5J4wW2g+JPri7jGISAVkqfGDgCkuJPIWXutFtPA17JyG8Ai0MjIJy78QQudM17 fP5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YgTErJ3m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si15932356pgg.228.2019.07.08.09.09.44; Mon, 08 Jul 2019 09:09:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YgTErJ3m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387517AbfGHPVV (ORCPT + 99 others); Mon, 8 Jul 2019 11:21:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387499AbfGHPVT (ORCPT ); Mon, 8 Jul 2019 11:21:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 23B2821734; Mon, 8 Jul 2019 15:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599278; bh=aSmWjpJ16O8U2JtLY5LrHCNx1acy5VZ7PDfAG+fXiIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YgTErJ3mWjEhh8RbxR4LojbwtltXvyyOYYoSinBMnYxcKn34NayDqjWPlwrSZrI4V DY2roAVMVpLFgvI1xt21f8lqMzTTEr2iII3MGfoeZwIPSVVfo+RSTTG8KOQui+JkJj lh9ktaZnaznGzqW7kyhFAKPY61dGaSSdCUcmiMjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Craig Gallek , Martin KaFai Lau , Song Liu , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 4.9 063/102] bpf: udp: ipv6: Avoid running reuseports bpf_prog from __udp6_lib_err Date: Mon, 8 Jul 2019 17:12:56 +0200 Message-Id: <20190708150529.714551171@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin KaFai Lau commit 4ac30c4b3659efac031818c418beb51e630d512d upstream. __udp6_lib_err() may be called when handling icmpv6 message. For example, the icmpv6 toobig(type=2). __udp6_lib_lookup() is then called which may call reuseport_select_sock(). reuseport_select_sock() will call into a bpf_prog (if there is one). reuseport_select_sock() is expecting the skb->data pointing to the transport header (udphdr in this case). For example, run_bpf_filter() is pulling the transport header. However, in the __udp6_lib_err() path, the skb->data is pointing to the ipv6hdr instead of the udphdr. One option is to pull and push the ipv6hdr in __udp6_lib_err(). Instead of doing this, this patch follows how the original commit 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF") was done in IPv4, which has passed a NULL skb pointer to reuseport_select_sock(). Fixes: 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF") Cc: Craig Gallek Signed-off-by: Martin KaFai Lau Acked-by: Song Liu Acked-by: Craig Gallek Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -479,7 +479,7 @@ void __udp6_lib_err(struct sk_buff *skb, struct net *net = dev_net(skb->dev); sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source, - inet6_iif(skb), udptable, skb); + inet6_iif(skb), udptable, NULL); if (!sk) { __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);