Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775785pxp; Mon, 7 Mar 2022 02:02:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzWMQsvGmTFXatz6ZjUwMlqoEXYpqF4ADDQRpcQhAGj2mKk86Sh6c9Ianm7BNJNG7QVOl5 X-Received: by 2002:a17:907:7f06:b0:6d6:f8f7:2655 with SMTP id qf6-20020a1709077f0600b006d6f8f72655mr8483848ejc.658.1646647376400; Mon, 07 Mar 2022 02:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647376; cv=none; d=google.com; s=arc-20160816; b=F/yecdkzRU5Nb/MLi2Xk2iuAgpnnoeCySp3nkQ7BVI/3vGI5j0si4UeLujQMetKgnT tCzA9EYPXVRfA+21gFIHkWwOsjMl+v2Px6FLIYLPwiaB/do4HtUav8wdkmO2gUyWpy4G FAeZhyzaphUUGQQ7ffT0KvKTEzN2EpNouBm3DVOnp9LccbMMprD7BS67MwhzPFAJwvzN AQ8ejuIu2UTlWjTOOBITza27bEMT5SUov8MlxPzc0ANxHPz7XpcFGyBNCMnSta6Oqp33 X7dfS+aSb2dQwuf2Dzm6NBbObNVRyTj5K1zUmegrUwby61Qklm5N3/lklvue9Q+wRrLI brWg== 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=4huQAXyubSNj7sEN02o1iviLReqgvpKQopUQQjP2nEA=; b=yZkt1D91QFP9V3taKeUfgE6FZ0hVESL4J8uWy0gGPiV2DcrknUDP7urSDuPoSFn+Lx 6lryk0gnRh5Ix1ZaadR+AJNP+mwdvaJUvdiuc4wYyean7oG4nmDKJXi6UuulfdBde/dU uaGvTfFaduejZjWRtVGDRn6STv0B5B0ozEICed1FO9DmEc6N/mKzI6BCUNJUBh9giKiy +lKjw9B09ETRhr8n1+hSftLZy+ZUNxkWMK0lotr9wda7/T3FKyLzWKWJZ3c3MV3UNdRA Mv1MmWRENPRtoaGypEhHNJfHwuameKj12+w4f0EvBTYn88J4vz9EWlHbAy0FkHUlqe3O dcIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MwtOd/9+"; 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 w26-20020a1709060a1a00b006d02222ff46si7140130ejf.754.2022.03.07.02.02.33; Mon, 07 Mar 2022 02:02:56 -0800 (PST) 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="MwtOd/9+"; 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 S236828AbiCGJZm (ORCPT + 99 others); Mon, 7 Mar 2022 04:25:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237013AbiCGJXS (ORCPT ); Mon, 7 Mar 2022 04:23:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B2D66607; Mon, 7 Mar 2022 01:21:39 -0800 (PST) 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 9E90361015; Mon, 7 Mar 2022 09:21:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7197C340E9; Mon, 7 Mar 2022 09:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644898; bh=fk3To6U2sEeYyO5t87ziffhXrEXeFLqFNumAxEt63ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MwtOd/9+GJLaFacQFi41cHK0vxJF/ri8GcP9B4e/5EURUib3ZHB2o9BUQ08oSTB2F UlyLhTz+HOp6CEB0b8JSGqgnc0j/gnRWxKAfLXS+xwDoKMIppu/4amvpXIUPMFxphk f1qokUMKk70wMr/XTHWDh68KE/xoROHwV4u9I+iQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Bohac , Steffen Klassert Subject: [PATCH 4.14 15/42] xfrm: fix MTU regression Date: Mon, 7 Mar 2022 10:18:49 +0100 Message-Id: <20220307091636.593984884@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@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.6 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: Jiri Bohac commit 6596a0229541270fb8d38d989f91b78838e5e9da upstream. Commit 749439bfac6e1a2932c582e2699f91d329658196 ("ipv6: fix udpv6 sendmsg crash caused by too small MTU") breaks PMTU for xfrm. A Packet Too Big ICMPv6 message received in response to an ESP packet will prevent all further communication through the tunnel if the reported MTU minus the ESP overhead is smaller than 1280. E.g. in a case of a tunnel-mode ESP with sha256/aes the overhead is 92 bytes. Receiving a PTB with MTU of 1371 or less will result in all further packets in the tunnel dropped. A ping through the tunnel fails with "ping: sendmsg: Invalid argument". Apparently the MTU on the xfrm route is smaller than 1280 and fails the check inside ip6_setup_cork() added by 749439bf. We found this by debugging USGv6/ipv6ready failures. Failing tests are: "Phase-2 Interoperability Test Scenario IPsec" / 5.3.11 and 5.4.11 (Tunnel Mode: Fragmentation). Commit b515d2637276a3810d6595e10ab02c13bfd0b63a ("xfrm: xfrm_state_mtu should return at least 1280 for ipv6") attempted to fix this but caused another regression in TCP MSS calculations and had to be reverted. The patch below fixes the situation by dropping the MTU check and instead checking for the underflows described in the 749439bf commit message. Signed-off-by: Jiri Bohac Fixes: 749439bfac6e ("ipv6: fix udpv6 sendmsg crash caused by too small MTU") Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_output.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1266,8 +1266,6 @@ static int ip6_setup_cork(struct sock *s if (np->frag_size) mtu = np->frag_size; } - if (mtu < IPV6_MIN_MTU) - return -EINVAL; cork->base.fragsize = mtu; if (dst_allfrag(rt->dst.path)) cork->base.flags |= IPCORK_ALLFRAG; @@ -1316,8 +1314,6 @@ static int __ip6_append_data(struct sock fragheaderlen = sizeof(struct ipv6hdr) + rt->rt6i_nfheader_len + (opt ? opt->opt_nflen : 0); - maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - - sizeof(struct frag_hdr); headersize = sizeof(struct ipv6hdr) + (opt ? opt->opt_flen + opt->opt_nflen : 0) + @@ -1325,6 +1321,13 @@ static int __ip6_append_data(struct sock sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; + if (mtu < fragheaderlen || + ((mtu - fragheaderlen) & ~7) + fragheaderlen < sizeof(struct frag_hdr)) + goto emsgsize; + + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - + sizeof(struct frag_hdr); + /* as per RFC 7112 section 5, the entire IPv6 Header Chain must fit * the first fragment */