Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2957176pxb; Mon, 18 Apr 2022 11:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOpSQfKbJkj2Y4msBdDA6j4F/NTlMblS/Nrqch2aJRTWcyazkk+Fcl1cVbavQPNmfQOy9z X-Received: by 2002:a63:2a96:0:b0:398:7865:d650 with SMTP id q144-20020a632a96000000b003987865d650mr10870158pgq.223.1650308244695; Mon, 18 Apr 2022 11:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650308244; cv=none; d=google.com; s=arc-20160816; b=QInkECGzDwdAR6s1MZTpVCYjTN6uXZrMLUYiWUlPKvI/phl+7ppq93x5wUY8rn+BpI ORaLw87/u7VPnkzxCOELZ6vZrkboDf6UqVxfRwLu4cBaymD3hcs9CmF/kKf4W+v3lro3 Z8UZPw83bEKT6Bv9S350DJm5j6tlYPvVwyKwNPov47nm5NhV5FxoSoMmJtwS80JwNS/V s7kLy3o2wFECzjcgl5IFvhayJLXC5ZW0BEfh5ykqvVVn8mL+Xo/v+qq1YllNAVLX80jf 5E7js5HfCKn44zC9682V0BdwNyLUWbEl4fzahtb9DlbOp/TyJTbEfRsACDKDHT+VRjtD JMPQ== 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=io7cg7hlrtWpIyp0b3/y94yMS756zIktRYXdsDfeGuo=; b=fa8ibk0Aq/npBqzEwYXXx5M9MwUObJ0hAjlmV3FKm1df3emf1VbJTpJWfjikZjgRPJ xD2w5zNfcCSb/pa80k3S1Ky+9FxtvqpnGl4EZin0P98Q15FReVyUgHMzB7/wRWiFRGFt GIeHdH7WrGS9s7dAQXQxSgIMuOUUtfeYSFUbU7aXPCJnNP0OzE02IjwBuc8TTbeVLGU5 hK3GJesv8suj+nUvsLVa/vR8sJKso9WjyhRm48yanA9g4WMnHFmkNBqyzwS1ZMYtiMZM K6CH27PmL2eP0dFQ9A+BDKBE1GWJqCevoxgcc787RxoMwVO1WRxWyWBe4CnKNX8K96df mHUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CeuRRLWB; 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 ob17-20020a17090b391100b001c680dc9e6asi99378pjb.61.2022.04.18.11.57.09; Mon, 18 Apr 2022 11:57:24 -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=CeuRRLWB; 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 S239067AbiDRM1m (ORCPT + 99 others); Mon, 18 Apr 2022 08:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238781AbiDRM0O (ORCPT ); Mon, 18 Apr 2022 08:26:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A86E089; Mon, 18 Apr 2022 05:20:11 -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 83D0E60F0C; Mon, 18 Apr 2022 12:20:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9400AC385A7; Mon, 18 Apr 2022 12:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284410; bh=G++U9rtoxfQSlDamiCXkUBLmwjBH2Lkb15OC1vNC2oE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeuRRLWBSVLYllrUnpR27u/pllWMc0yLo5FpXFCIw/da3O/OX4RLrq8/XrOYoWgQN rCtoyOzoZZoX50UVPEOnunHlz9w4gdsXgrNciv6b4UWqcxJcG/x/oKSSDOLlGCSnJC M1d/JolXB7hLiwEtpWFbj0EJjqLs7GVJ47SW0u6A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Topi Miettinen , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.17 089/219] netfilter: nft_socket: make cgroup match work in input too Date: Mon, 18 Apr 2022 14:10:58 +0200 Message-Id: <20220418121209.039001224@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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: Florian Westphal [ Upstream commit 05ae2fba821c4d122ab4ba3e52144e21586c4010 ] cgroupv2 helper function ignores the already-looked up sk and uses skb->sk instead. Just pass sk from the calling function instead; this will make cgroup matching work for udp and tcp in input even when edemux did not set skb->sk already. Fixes: e0bb96db96f8 ("netfilter: nft_socket: add support for cgroupsv2") Signed-off-by: Florian Westphal Tested-by: Topi Miettinen Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_socket.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c index d601974c9d2e..b8f011145765 100644 --- a/net/netfilter/nft_socket.c +++ b/net/netfilter/nft_socket.c @@ -36,12 +36,11 @@ static void nft_socket_wildcard(const struct nft_pktinfo *pkt, #ifdef CONFIG_SOCK_CGROUP_DATA static noinline bool -nft_sock_get_eval_cgroupv2(u32 *dest, const struct nft_pktinfo *pkt, u32 level) +nft_sock_get_eval_cgroupv2(u32 *dest, struct sock *sk, const struct nft_pktinfo *pkt, u32 level) { - struct sock *sk = skb_to_full_sk(pkt->skb); struct cgroup *cgrp; - if (!sk || !sk_fullsock(sk) || !net_eq(nft_net(pkt), sock_net(sk))) + if (!sk_fullsock(sk)) return false; cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); @@ -108,7 +107,7 @@ static void nft_socket_eval(const struct nft_expr *expr, break; #ifdef CONFIG_SOCK_CGROUP_DATA case NFT_SOCKET_CGROUPV2: - if (!nft_sock_get_eval_cgroupv2(dest, pkt, priv->level)) { + if (!nft_sock_get_eval_cgroupv2(dest, sk, pkt, priv->level)) { regs->verdict.code = NFT_BREAK; return; } -- 2.35.1