Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3073910rwe; Mon, 29 Aug 2022 05:30:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VEqpM8gVfkw7Q1DF+Z5Y8NMSFbIwJhpPyu1GL8GPFx/FTfXndD38FFhsuQjlYyvDmrpBv X-Received: by 2002:a63:8642:0:b0:42b:7f8e:415c with SMTP id x63-20020a638642000000b0042b7f8e415cmr11772983pgd.203.1661776255912; Mon, 29 Aug 2022 05:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661776255; cv=none; d=google.com; s=arc-20160816; b=jriW17x0mASCdJQYPVHCbVI4pxZI3mdTXf8DodLpEXQr0qkWXF0NzT8fkIvZLcZ1rk L7tUdOy/9hkqSHU29A5dRVvqZ5QM7Z4aIh6jLvUgc+3LHVSQjLkuSoN056F1XFNhrssd t65aakunLnpS+hWbmS7gPOCgGzWdnD5mZMtRhz1Q9cOgC21kf4O1lviYONMaOBntEkkg aOKtJ890zd0yq/3NDHqFB0LNx3ckzAw1tcVMqJI/xniTixyViCXBMFyfG56UrsRkwQNh D1xVzwqNll3ZbpLcoTJ1y63xUkse2hsf1JdaNVoemQuMLfrgPqMrhCpb7H05qhnZAkTw anqg== 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=eueoTZEb1lXFKhJctUTby08pmS/UamF9j57cR1toFXk=; b=L9GVCWgkcvhuMmtZ/gtxaT9dxas+3hEFjCb9pZeyjjq7aKLWl2JuytdacL+MyPO9XW hQgKiPTC5B2APLZyXtMQ039aSsQwoIpoqXnX7N3GVR9vuETqRpa5zH7RhDwvQ5+zwfUt jPd9Uxc2vlnuFje6GnTypnhBGLiwlXVuJm40GxHAzm/VBKF2kfIzYa4K7GbMwHm7ufJn Ft0WvOEzUwdDCcG+gb9q7YA2Itfi/aVuK7PR7HPTqXgkqVJn3CAuy1Z/+LY4wbAMt8td CBYjUwB4J0iYzgEZ7go1W50FAO8q+/cNJubuQylTxMmd1S5EKwNOHsCSEUAWwg50sHGo 0OAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r+duUxt/"; 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 y14-20020a17090abd0e00b001faf855bcb0si8900622pjr.135.2022.08.29.05.30.44; Mon, 29 Aug 2022 05:30:55 -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="r+duUxt/"; 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 S232284AbiH2LaB (ORCPT + 99 others); Mon, 29 Aug 2022 07:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232341AbiH2L2r (ORCPT ); Mon, 29 Aug 2022 07:28:47 -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 72E0A79A6A; Mon, 29 Aug 2022 04:17:16 -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 6B3E6611D6; Mon, 29 Aug 2022 11:06:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73782C433C1; Mon, 29 Aug 2022 11:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771173; bh=gwq1OqMwhb/YuVfl7qY3edF58qVgD9W2LIDU7en9DcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+duUxt//B01OZ3hoFecCGj42YmU+uRwRlRiUNzxS2CofxLkVl/PHMfrwii770on9 mxQmhz+4e5vXDptI+kpH6Crz2Kyyy5RItB8XDxf8kLsEUGviPPfgPW+gDK6PaMzV1n OtPDF24DcdrX2qhO+ST50+5w8hlSbKL+g08oH8xo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 35/86] netfilter: nft_osf: restrict osf to ipv4, ipv6 and inet families Date: Mon, 29 Aug 2022 12:59:01 +0200 Message-Id: <20220829105757.991970415@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105756.500128871@linuxfoundation.org> References: <20220829105756.500128871@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: Pablo Neira Ayuso [ Upstream commit 5f3b7aae14a706d0d7da9f9e39def52ff5fc3d39 ] As it was originally intended, restrict extension to supported families. Fixes: b96af92d6eaf ("netfilter: nf_tables: implement Passive OS fingerprint module in nft_osf") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_osf.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nft_osf.c b/net/netfilter/nft_osf.c index d82677e83400b..720dc9fba6d4f 100644 --- a/net/netfilter/nft_osf.c +++ b/net/netfilter/nft_osf.c @@ -115,9 +115,21 @@ static int nft_osf_validate(const struct nft_ctx *ctx, const struct nft_expr *expr, const struct nft_data **data) { - return nft_chain_validate_hooks(ctx->chain, (1 << NF_INET_LOCAL_IN) | - (1 << NF_INET_PRE_ROUTING) | - (1 << NF_INET_FORWARD)); + unsigned int hooks; + + switch (ctx->family) { + case NFPROTO_IPV4: + case NFPROTO_IPV6: + case NFPROTO_INET: + hooks = (1 << NF_INET_LOCAL_IN) | + (1 << NF_INET_PRE_ROUTING) | + (1 << NF_INET_FORWARD); + break; + default: + return -EOPNOTSUPP; + } + + return nft_chain_validate_hooks(ctx->chain, hooks); } static struct nft_expr_type nft_osf_type; -- 2.35.1