Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3060819rwe; Mon, 29 Aug 2022 05:18:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ok1J1uu0EGRY2/LJBnGvXUYdoxbhvLptYBizB0DIq5x5EbRRcR94dluWPv4vUVnyJkfrs X-Received: by 2002:a17:907:1627:b0:741:5338:936 with SMTP id hb39-20020a170907162700b0074153380936mr6214782ejc.619.1661775509108; Mon, 29 Aug 2022 05:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775509; cv=none; d=google.com; s=arc-20160816; b=GCPM6/jagMvHtmt+hzWtXWWh+SuPF5uCZuVtHdnKldB10k4xjhhkKf66+CSwvdkZ9y waqcjiAHz+QEpN9FQty2sw3pr9fl++VdEuMlW5EqGtbUE5ThC7BQsrSbFc813UDfZpfb 4FC2NyoMMQhEUm3Q1pEEnkQ2FxUPKgcopT6Agh9rDDxPsBVANc/3RnN+9Q6uhffEQEYt /iaUCN/MODDIuoIsqYYNw3FFnuHNl8IbbN+V7EMQHnvb70QO5/vxkTWGdvkoJt2m5JVY O7VGBGSwi6TPX5gGt1PlQj2eaSLtgrqXdVbq88bVKKZtdiJ/GT5uGauNI08jf/aqrs5J 4zIw== 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=gbW8+z4Md0mGELngUHBnlv7bpCuyjOvAq/UgBweRbbs=; b=JXyz5JLVwxJftHYgjrUGrl24YXUW8SfYmTBpHVirB+I9oRvBor0FwZPUrqSu1/+cRt WXsgBdedXbZFITR5OeJ4YyJKSkC9GZbK8iITxz6yYdET53ORGl394ruhSvM36LCvlSo1 8/q962wDwy2OTFLPQYumwBzhh/mIjWzTpheub6j0wqHkc8noxQydVpJ0mwN349Dmv6BJ 1lyvx6m3MAqfToCriSTznmPrrIjW15I+D0I/GXkcXfKSwg00BLgxFDlAtCR+tiKH/so7 JqL0leKd+oodhuNjQ2zRlWQ3IJHvQDTsYXI3gjR2QGYBe2b+2+MaTTNCVjVkX2fr5dAU mwuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iIvfEMz7; 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 eh13-20020a0564020f8d00b004472b35d7a5si5689434edb.309.2022.08.29.05.18.03; Mon, 29 Aug 2022 05:18:29 -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=iIvfEMz7; 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 S231391AbiH2MMG (ORCPT + 99 others); Mon, 29 Aug 2022 08:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbiH2MLd (ORCPT ); Mon, 29 Aug 2022 08:11:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10EF522527; Mon, 29 Aug 2022 04:56:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9FB0AB80FAE; Mon, 29 Aug 2022 11:14:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECD8EC433C1; Mon, 29 Aug 2022 11:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771665; bh=uMQJvyfzpyrFxCJ+wIpRifUys8/OmF5TnZH79b4QBCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iIvfEMz7yaPNNKg+TUCIiSKW+9ZlJ2NggJdKhWK8HywPrMHBbgPIs9FyKI/JMdwLW BC/yN/QlCE2hbOO47HRxRdIQ5uUv+n7OT4e8zqNKI+MDQ7L6ak1p9BSPgWmasX6ZN7 UTwKnrbruIyHA2apg8ZZC2/2imU3+mtwwqVN3B78= 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.19 058/158] netfilter: nft_payload: do not truncate csum_offset and csum_type Date: Mon, 29 Aug 2022 12:58:28 +0200 Message-Id: <20220829105811.147620883@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@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 7044ab281febae9e2fa9b0b247693d6026166293 ] Instead report ERANGE if csum_offset is too long, and EOPNOTSUPP if type is not support. Fixes: 7ec3f7b47b8d ("netfilter: nft_payload: add packet mangling support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_payload.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 4fee67abfe2c5..eb0e40c297121 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -740,17 +740,23 @@ static int nft_payload_set_init(const struct nft_ctx *ctx, const struct nlattr * const tb[]) { struct nft_payload_set *priv = nft_expr_priv(expr); + u32 csum_offset, csum_type = NFT_PAYLOAD_CSUM_NONE; + int err; priv->base = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE])); priv->offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET])); priv->len = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN])); if (tb[NFTA_PAYLOAD_CSUM_TYPE]) - priv->csum_type = - ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_TYPE])); - if (tb[NFTA_PAYLOAD_CSUM_OFFSET]) - priv->csum_offset = - ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_OFFSET])); + csum_type = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_TYPE])); + if (tb[NFTA_PAYLOAD_CSUM_OFFSET]) { + err = nft_parse_u32_check(tb[NFTA_PAYLOAD_CSUM_OFFSET], U8_MAX, + &csum_offset); + if (err < 0) + return err; + + priv->csum_offset = csum_offset; + } if (tb[NFTA_PAYLOAD_CSUM_FLAGS]) { u32 flags; @@ -761,7 +767,7 @@ static int nft_payload_set_init(const struct nft_ctx *ctx, priv->csum_flags = flags; } - switch (priv->csum_type) { + switch (csum_type) { case NFT_PAYLOAD_CSUM_NONE: case NFT_PAYLOAD_CSUM_INET: break; @@ -775,6 +781,7 @@ static int nft_payload_set_init(const struct nft_ctx *ctx, default: return -EOPNOTSUPP; } + priv->csum_type = csum_type; return nft_parse_register_load(tb[NFTA_PAYLOAD_SREG], &priv->sreg, priv->len); -- 2.35.1