Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3404541rwa; Tue, 23 Aug 2022 04:20:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5H08rW5AvhqlRVhf35OEpC1DRDH38P8y7ykir3jYp0R9uGCUGJ7cpZXwTxjYhIemaUWZFJ X-Received: by 2002:a63:290:0:b0:41c:506f:7ae9 with SMTP id 138-20020a630290000000b0041c506f7ae9mr20539365pgc.373.1661253621903; Tue, 23 Aug 2022 04:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253621; cv=none; d=google.com; s=arc-20160816; b=g5aFrPrvpkbGFwCLSdFt34pnFDiDeKw1FQ47ZNIndFcLq8CQuMRYBGkUrrPLVyVvrw +yi0G6hP38l64DNGqQnJxN6tDXDBdE1djC1KlAg3shpy1cWAT90pGx4uMmZ8QByD8J3g HrJRYtHL8/F4UHR+0UfHzv85VrUFwteTfHj47LCaxR1r6Vf5S6jM7VC1ouaqopD/43q6 1Nbj17V23esYoFo6SbcBQIz3KBuxxdaGkitt8OmJms71vZWFU7ZXZ+6NT5lIgT9JPw53 XOg8y8ugOIQ6O1riMcY3ANaJOZTWdL75OLh2IMxZbW8VtBqzVqPNqK1kc5/V8SShY3n9 4mTg== 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=vqMUICmuxMtEVo4m5sLdUewt019zHhLJZEE0ZFQc9Wk=; b=SDzoBSqTqDcE0VgqYcZHBd+JpSU8Emf0Zy8M8nkL/obeG6KQc98bTkfmK/Bq6BHowA ZKiCOHsr9CGOMYAPtL6GO3ZJD+M0qNHntRz+YGe/bT11kgUr6mIS2f42qJwOOfUvvQYP 4jFNu7vQo51siDTGk7/w/38BtDCZnw0rBQB+CNTrjhNJbP8zznpKE6IUhZFx/wRr3isv hAPGq5HrhLCFgZZlfnLv4TaUgN2bfK1wDisdbgJuqciAgWhDzJNWJudl2n14iwIFA+yy DnuLUOyiJKhny8ZcZl1Ppj/C+nMEs3xn+efwmHvxdVsMBF08lWe+IC37NqvSfogeUET3 u26A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OwGgKbWQ; 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 b9-20020a631b49000000b00415e130eb76si15014427pgm.685.2022.08.23.04.20.10; Tue, 23 Aug 2022 04:20:21 -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=OwGgKbWQ; 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 S1347252AbiHWIoQ (ORCPT + 99 others); Tue, 23 Aug 2022 04:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348162AbiHWIlW (ORCPT ); Tue, 23 Aug 2022 04:41:22 -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 4FC19796B2; Tue, 23 Aug 2022 01:19:31 -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 B03C0B81C4E; Tue, 23 Aug 2022 08:19:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09869C433C1; Tue, 23 Aug 2022 08:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242769; bh=foCti0Sh9RxG6Ky8jlJd3/eKJ1pUg06/w3XLziQgKGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OwGgKbWQwhGaKziucVxbee36vr6cSX9GTCWflw8eBZZ3LGyM2QOql4+HjAkODJORI SXTRSaSUNJy568wl4pPAlYgOK9CNyBapfsTPhPiYONooN1m5InHsuq7wF8YTUMzYRf n2aGfUZVCs6Zke7EkWIKirJ9Ln8NHmcDYFcIIGSQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.19 193/365] netfilter: nf_ct_h323: cap packet size at 64k Date: Tue, 23 Aug 2022 10:01:34 +0200 Message-Id: <20220823080126.293138101@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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: Florian Westphal commit f3e124c36f70d5ffcdd4e8bdbe7bb28a98a715c0 upstream. With BIG TCP, packets generated by tcp stack may exceed 64kb. Cap datalen at 64kb. The internal message format uses 16bit fields, so no embedded message can exceed 64k size. Multiple h323 messages in a single superpacket may now result in a message to get treated as incomplete/truncated, but thats better than scribbling past h323_buffer. Another alternative suitable for net tree would be a switch to skb_linearize(). Fixes: 7c4e983c4f3c ("net: allow gso_max_size to exceed 65536") Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conntrack_h323_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/net/netfilter/nf_conntrack_h323_main.c +++ b/net/netfilter/nf_conntrack_h323_main.c @@ -34,6 +34,8 @@ #include #include +#define H323_MAX_SIZE 65535 + /* Parameters */ static unsigned int default_rrq_ttl __read_mostly = 300; module_param(default_rrq_ttl, uint, 0600); @@ -142,6 +144,9 @@ static int get_tpkt_data(struct sk_buff if (tcpdatalen <= 0) /* No TCP data */ goto clear_out; + if (tcpdatalen > H323_MAX_SIZE) + tcpdatalen = H323_MAX_SIZE; + if (*data == NULL) { /* first TPKT */ /* Get first TPKT pointer */ tpkt = skb_header_pointer(skb, tcpdataoff, tcpdatalen, @@ -1220,6 +1225,9 @@ static unsigned char *get_udp_data(struc if (dataoff >= skb->len) return NULL; *datalen = skb->len - dataoff; + if (*datalen > H323_MAX_SIZE) + *datalen = H323_MAX_SIZE; + return skb_header_pointer(skb, dataoff, *datalen, h323_buffer); } @@ -1821,7 +1829,7 @@ static int __init nf_conntrack_h323_init NF_CT_HELPER_BUILD_BUG_ON(sizeof(struct nf_ct_h323_master)); - h323_buffer = kmalloc(65536, GFP_KERNEL); + h323_buffer = kmalloc(H323_MAX_SIZE + 1, GFP_KERNEL); if (!h323_buffer) return -ENOMEM; ret = h323_helper_init();