Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090017rwb; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5i4Ru1GX0HT4/BGzlc28p6I5Fpw9wn1jkNr9+MGLi0nErDCyPYvkcN/z1I+n5EGGEipueB X-Received: by 2002:a05:6402:331d:b0:43d:9e2e:6966 with SMTP id e29-20020a056402331d00b0043d9e2e6966mr16970986eda.214.1660611186198; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611186; cv=none; d=google.com; s=arc-20160816; b=wvcP3SFlIJDmsPLOf/uOLfE2ELBMQ8yE3n+TP3ayfQb7fCL3M411Ryvjjs/L2XyfJ5 1+4yBaQESJrJlo32CpjsuR6Idqk5usvpC6Nf1Mbu+1iIp7EaWWSPrXxpjVWr5eRSsdd/ +Xp0lKDolb52Hr8twy5q0XQH5ilRQ5pLNSzDVd71Dg1um7PPOZtDNPEWFEd6+RvrZ4Zm Yr78XO8jIYk+fsWwxq4mU+YHsL6HlZp60JRUioOFyNridoyGVwaDLq4fYz5ERP0sGjHp 2V6DLBmMIhHrJZOvGiWzYMXUaf4lKHN2c7JzMevcVIKAQKWBx6EHlfU1STXx0JcXzZfi urAg== 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=8zR53yvA/Dz12CJ7PJGjJsrXic3LONIm4no7nGb/XmA=; b=Uu0A1VasaHWXtXMp/zKTjQ+5M4xTut5FIn8n8Cbdk+d24IlVxccnwDl+5iLAa+RX7w f7VsJyOSGYYpa2nS23N4TIV/L9Jz0z/0bM+1uJRlKzAH2a5ui+Om8u3eUvE8IoVhKQov a/sVsDLa5JK99Z4Jp7aHV/rKRO+uY64REC9f9RXwAePdAB6qdP1zW+YU2xpJNMKRIfc6 P0kWJKNTYhOOWOzXopihj884h0NZH8q4Zds/SESnpMJW3sfokcDOFl3PgpOunoXCPNGr Jmbx/S+U5skRfdr5sSJjUhPiTdDEl1YV0CA39ERRaKc8mfz6tFdF5DDqjm3W8QIkIog8 Pipg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xi8AWGOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a170906975600b007384c1db86fsi3810001ejy.60.2022.08.15.17.52.41; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xi8AWGOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1355927AbiHPABs (ORCPT + 99 others); Mon, 15 Aug 2022 20:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356231AbiHOXx6 (ORCPT ); Mon, 15 Aug 2022 19:53:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33CB2C6B7B; Mon, 15 Aug 2022 13:18:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 724B960DEB; Mon, 15 Aug 2022 20:18:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60EA4C433D7; Mon, 15 Aug 2022 20:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594720; bh=DFT14kIqMWORbQnzYNlTNSiDiYPcQccGBaO8LcqfgVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xi8AWGOWBU30UfuQK91yjwof8IvJ5FZuFdhIOOShoT4UB+sn/cQ4MaC0MnWhduY3j fROjUX1wQqPC/JIPZFiBIYVLr8+FdO1L2yg6rfyaelKjXyQtvu3NLUdxndEF0I5aCw xTcmINAO9jxySScVLRwPsGnGuzcZbuv4qzsjN9Q4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Chaignon , Daniel Borkmann , Nikolay Aleksandrov , Martin KaFai Lau , Sasha Levin Subject: [PATCH 5.19 0537/1157] bpf: Set flow flag to allow any source IP in bpf_tunnel_key Date: Mon, 15 Aug 2022 19:58:13 +0200 Message-Id: <20220815180501.149595269@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Chaignon [ Upstream commit b8fff748521c7178b9a7d32b5a34a81cec8396f3 ] Commit 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"") added support for getting and setting the outer source IP of encapsulated packets via the bpf_skb_{get,set}_tunnel_key BPF helper. This change allows BPF programs to set any IP address as the source, including for example the IP address of a container running on the same host. In that last case, however, the encapsulated packets are dropped when looking up the route because the source IP address isn't assigned to any interface on the host. To avoid this, we need to set the FLOWI_FLAG_ANYSRC flag. Fixes: 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"") Signed-off-by: Paul Chaignon Signed-off-by: Daniel Borkmann Reviewed-by: Nikolay Aleksandrov Acked-by: Martin KaFai Lau Link: https://lore.kernel.org/bpf/76873d384e21288abe5767551a0799ac93ec07fb.1658759380.git.paul@isovalent.com Signed-off-by: Sasha Levin --- net/core/filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/filter.c b/net/core/filter.c index 7950f7520765..5978984b752f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4653,6 +4653,7 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb, } else { info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4); info->key.u.ipv4.src = cpu_to_be32(from->local_ipv4); + info->key.flow_flags = FLOWI_FLAG_ANYSRC; } return 0; -- 2.35.1