Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2887507rwb; Mon, 15 Aug 2022 13:20:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR45UCB/wgor9UCdC/Fa6UPM4+s5Q1R2KF7D5ASW7UElpXcUfoMEStTCcQ0ex8UBSgXzeqLJ X-Received: by 2002:a05:6402:520e:b0:43d:df14:fbed with SMTP id s14-20020a056402520e00b0043ddf14fbedmr16183352edd.16.1660594829443; Mon, 15 Aug 2022 13:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594829; cv=none; d=google.com; s=arc-20160816; b=zpEvHw0vP8X9HlMLZKBI6uE6lSG6jnx7h+eCst8Fl9UzgNvwwtKGF6Luk+TtoogoAw v+olLlv1xbQMbe+E8SIlLAXuEOyuB0C2xms5f8BYnppRQh8cRIOLBFPOqqUfsASY25Pr NI0bVAMklDpZzdsLNWWphrSfHf0er3hGGCVEAQXsbifgSqi2KMoz8/wTTJBjMqpXtI8b fV78g9Nqe+0LpTn++YZVf2uQaNTotXpvf5IE351DlnYkka2zzfbY4ujXsLqaC6UCOc3S BJAzj6v64mVhDRIeXn8f+iwSS1hUJgW19a6AK5JWlWzk+yQfTTfnPZlH5u1ZTmYX4fHG ULug== 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=yvmwJsg+daiWqb+iqksvP4k45MPsCizLZvscH+1Rm3Y=; b=kE5Is9SAE1JYNlJxGDMtLP9dSSJEpN94oMNtEI2tIQkNXNVHK5Nm99wPsQb87ClnOj 2aMMoOck9jckfWPg7ADqKVCwK+vkO/lApaK/qm4yE5FMZEVz4UOXLuqZ4E5zpRELYLEy JRIxEj0TTqa5vmkmoFLD79LJWMabkUtqJ0JEG++Rsl+MOmJ1qdxLo12iDSFFw9eEd6J1 HT+QQD/aTsNIAVS0miqAm1O/E90mRSgSF9ejsWsSGb5Z9xtHK+qCOZumDRSjx96tQgDc gmyzabGx/vDZ5r3w7dvdMB2y2z+V8QTZxfIy5sIqM+aA1sa6xOLiuNiz7TaY7g39LLq/ f07Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RjKG6pmj; 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 u4-20020aa7d884000000b00440608ba4d1si7799300edq.151.2022.08.15.13.20.00; Mon, 15 Aug 2022 13:20: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=RjKG6pmj; 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 S243854AbiHOUC6 (ORCPT + 99 others); Mon, 15 Aug 2022 16:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346138AbiHOUBp (ORCPT ); Mon, 15 Aug 2022 16:01:45 -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 1CAE17CB64; Mon, 15 Aug 2022 11:53:55 -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 1343FB810A0; Mon, 15 Aug 2022 18:53:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48776C43470; Mon, 15 Aug 2022 18:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589632; bh=lO4agyz0ZSzI8UkHKUsysasIuHutY5jQ8FqjF1ZH5tE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RjKG6pmjqr0gp964v9nJ9byIbVWtcw3OnhNjnBlEXov8+dYxqx6DOBByGP2plGTqv q2FJrDXKun2V9Dt/CsN0/tnlVo95K2RJretPossv8j8meSS3r2UL/680AKbpoqQ7JR /SEt/hI4CalonqCefe3EOS/jffkMR6PFMWcTIA0M= 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 5.15 763/779] tcp: fix over estimation in sk_forced_mem_schedule() Date: Mon, 15 Aug 2022 20:06:47 +0200 Message-Id: <20220815180410.031894477@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 @@ -3372,11 +3372,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);