Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407978rwa; Tue, 23 Aug 2022 04:23:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR7cB4db2b5BIBVu1FuftdHTdLimXkWfyi2Wa2f/AdjEcZ6VjGDvGXwfa1v8NASBlghj7n27 X-Received: by 2002:a17:90a:9401:b0:1fa:af9c:20db with SMTP id r1-20020a17090a940100b001faaf9c20dbmr2877382pjo.190.1661253825081; Tue, 23 Aug 2022 04:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253825; cv=none; d=google.com; s=arc-20160816; b=IdGf2rSYAne+Lb9X/W6qTFVxN4yGcD8YbRULiCCRThUtRzCc/kcJ3dTguoLR7Rev6r AUr3AW0hOM9LdsZKWNrBynxRPYGIhvPgmuFfI1ADHNkdkYGPtucgaISaILOUklmstcrN ooEkd1vx2NNa3bzylst7qEyRgngj03oha1qRNQn8UByZt6ETHf42p+ytlnXJWz4quaA2 rKEBlEqBAWXPXp1+WveLNEyCnvLE6I4XMfhm8H0qKGqtNZBNrHOVjrDtCiPGE0G+lC1X cufjNBCtLLI9l+HQYFEUOG7ZLd7lZh84JEU8xv0ypJ6AJvoYzIZ4AjIekduKRZH2tSjc vR7A== 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=j6AlKZ4bWXSStij1L+nkzQCmzRWyCEVTUp645E2wLKU=; b=Y1R0NUt3UxCAEYAVsZ73vAfCoXCvyp8aTUNioGcoDVvWxFKK1g5OAGUyIxSsI69hR3 sxQ/hek974D6HAiJUtAe3LiGr13JgA/P4CX0k1HkTOhsn93F0Ik1XNWOkl8fj3DQdA5j MpH+gzJJ5Hcqdg1FIeDOh357j4s4P2GtUePP2UB29aKdTmsWGMNpud9vGhbCRlrzANoi j02jWWxKP+sPFuFTQLLYvlrDMDxi/F6M7dn+kYADf5IVZXqhTRjph9x8B+p6rvRPQymN njVxNCOE0e2bMlJuzlyMX2fIMyjBpFrrGyq12oQ93WrN8H8giNOdPOQYschn1ozSy/rf 5+Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ImyXeCIh; 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 q15-20020a170902a3cf00b00172b9ebe99dsi13648646plb.445.2022.08.23.04.23.33; Tue, 23 Aug 2022 04:23: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=ImyXeCIh; 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 S1353035AbiHWKKO (ORCPT + 99 others); Tue, 23 Aug 2022 06:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352749AbiHWKC1 (ORCPT ); Tue, 23 Aug 2022 06:02:27 -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 804907C748; Tue, 23 Aug 2022 01:50:47 -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 F05E8B8105C; Tue, 23 Aug 2022 08:50:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB8AC433D6; Tue, 23 Aug 2022 08:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244644; bh=MJ9PmoMD6d/lpjd/2z9GkI5gkqaZpktyZICEJxlwDDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ImyXeCIhxzUKEjemGlRiPqOwF/W59dv9lJXIc+6wa5+9IX1/qy+gaa+L2jbLIXi5x ydxRRxVRbonMN73+WRth9kSkmGvsNZIFq+B3UZELfR7G6x6NYHmBi9YOIf0CTHFIkf PjFg08r5tTVt3M4oVDgeKgJv0jfmKs9/OFlZz01M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Soheil Hassas Yeganeh , Shakeel Butt , Wei Wang , "David S. Miller" Subject: [PATCH 4.14 169/229] tcp: fix over estimation in sk_forced_mem_schedule() Date: Tue, 23 Aug 2022 10:25:30 +0200 Message-Id: <20220823080059.684450676@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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: Eric Dumazet commit c4ee118561a0f74442439b7b5b486db1ac1ddfeb upstream. sk_forced_mem_schedule() has a bug similar to ones fixed in commit 7c80b038d23e ("net: fix sk_wmem_schedule() and sk_rmem_schedule() errors") While this bug has little chance to trigger in old kernels, we need to fix it before the following patch. Fixes: d83769a580f1 ("tcp: fix possible deadlock in tcp_send_fin()") Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Reviewed-by: Shakeel Butt Reviewed-by: Wei Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3086,11 +3086,12 @@ void tcp_xmit_retransmit_queue(struct so */ void sk_forced_mem_schedule(struct sock *sk, int size) { - int amt; + int delta, amt; - if (size <= sk->sk_forward_alloc) + delta = size - sk->sk_forward_alloc; + if (delta <= 0) return; - amt = sk_mem_pages(size); + amt = sk_mem_pages(delta); sk->sk_forward_alloc += amt * SK_MEM_QUANTUM; sk_memory_allocated_add(sk, amt);