Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3180126imw; Mon, 11 Jul 2022 03:41:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1stxjWLHpsy/3dx8+ycujLiyaVWwg3tx/73FJ2My/eXpaUyixHxp9QIquh5JJMCiYeLEtf+ X-Received: by 2002:a63:2b8c:0:b0:411:954c:1f1f with SMTP id r134-20020a632b8c000000b00411954c1f1fmr14764144pgr.548.1657536105469; Mon, 11 Jul 2022 03:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536105; cv=none; d=google.com; s=arc-20160816; b=jwjn38CvMjTrsWisCxzpwTRh33KwsSVYeaSZ+D5/siIUhTfIfkArEbc0Sgnv9GuQlv uxwlHW3EOPJOZZeCgQbaQdkMXmkYRcQPMNn2t0KeDU2ryL96Zlsl/Qlmvuln9exBw8DY zyp+vIA4GQhac8+isfbZN87lHFxWoFwSpnnBhTEvT4iNlBJLXpa1LVbc56iXLGoyCdeo hDHhR+PNxwreO9yc2slgTWKYYjkFE6sGmXFt3zP78QxG6bu34FpHPKCh1cKS0oDHHNuO ldWOsQmOw1uysSqAhsfmIXNeOZANwKz7HAiS/E8Tv4+MLxxgYIkMdxGNWHisEEeLYTjF O2vg== 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=nl1PABC6uIeOzTIn4i6NVeKuknp2pBnov2lpsrmLKYQ=; b=qvSC3dTxnzxsd2485fuHYUNq2W7zZK8s/pvDc8U/82NXoJNNqpWAZLFiNw9jZLPkYN g3pHDGK2vrNVK2WUjuj590VXUtrj7JvPU5Om2UhrIi9dqCgsNOHJvdbcLa+QelkwAOTV qaLr4u5T0u0MuDXmSyEdXtuvALPOmxHzkxcDGZFgB1YWIKUE7kLY4W60Z2RRf2D06SN5 xPumb/efpG1MVvC1PPRhmOHn21VXJz+sbNQrIoS/2XwxYXCB8rCny2i4O9Ml1HlkuQ79 bdiJSBrzEo8nVgUsteT35T6Hck8HepZuJexhH53RxbI3qqzIXwwxTMTG8YSyy1EPEL7C FyYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tSy1nORp; 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 l7-20020a63ea47000000b0040d9ec62b16si8270093pgk.366.2022.07.11.03.41.33; Mon, 11 Jul 2022 03:41:45 -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=tSy1nORp; 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 S231783AbiGKJTC (ORCPT + 99 others); Mon, 11 Jul 2022 05:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbiGKJS3 (ORCPT ); Mon, 11 Jul 2022 05:18:29 -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 3086C4D174; Mon, 11 Jul 2022 02:11:48 -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 9F21261148; Mon, 11 Jul 2022 09:11:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB678C34115; Mon, 11 Jul 2022 09:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530707; bh=c6lHgrC8ABeMaDjsp0Y9eCQSxBZwkmKPXV7L9DCxXbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tSy1nORp1B7iYc4b45yti9e1Uu7vulcpcg8YJqJ0WxFWCHL+J38RAO5hAELKTIRxq Hvyw5cgH+UITHlKgBowDN9M2VrROaV/w3KqYkv4rxKM80NpqKFcMdvVcvuNoMLWXET TtHUdR7ulRbJ0yrb+Sa+w1tsxfol6rP9oV+zu+7Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugues ANGUELKOV , Pablo Neira Ayuso Subject: [PATCH 5.10 11/55] netfilter: nf_tables: stricter validation of element data Date: Mon, 11 Jul 2022 11:06:59 +0200 Message-Id: <20220711090542.094432740@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090541.764895984@linuxfoundation.org> References: <20220711090541.764895984@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: Pablo Neira Ayuso commit 7e6bc1f6cabcd30aba0b11219d8e01b952eacbb6 upstream. Make sure element data type and length do not mismatch the one specified by the set declaration. Fixes: 7d7402642eaf ("netfilter: nf_tables: variable sized set element keys / data") Reported-by: Hugues ANGUELKOV Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4886,13 +4886,20 @@ static int nft_setelem_parse_data(struct struct nft_data *data, struct nlattr *attr) { + u32 dtype; int err; err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr); if (err < 0) return err; - if (desc->type != NFT_DATA_VERDICT && desc->len != set->dlen) { + if (set->dtype == NFT_DATA_VERDICT) + dtype = NFT_DATA_VERDICT; + else + dtype = NFT_DATA_VALUE; + + if (dtype != desc->type || + set->dlen != desc->len) { nft_data_release(data, desc->type); return -EINVAL; }