Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3119731rwb; Mon, 15 Aug 2022 18:36:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tXzqC5Z3u8GQYsj/lCfM3zOzymvga/wY3VKKWRj4K/zXXo2/ryms/C+fzTVeGqFLnY74J X-Received: by 2002:a65:6e87:0:b0:41d:fefe:fd9d with SMTP id bm7-20020a656e87000000b0041dfefefd9dmr15658302pgb.557.1660613764529; Mon, 15 Aug 2022 18:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613764; cv=none; d=google.com; s=arc-20160816; b=SwMKMfY/zk21ZI5F9y46Hrgk0U4RBp34prNaVnfN4NwlhKRjMWEj4SQax3KI0AXHjC 3XdEETloYPFfL6QNoETWwAQ8hGgeg75t8MatytMslqV/oW+hJw2z+KOx1jUxDbLAHbyN gGWDq/9YsHDMChgZMcPMXefv8KbDBZHbgIu2GvO83La36i4+kpcmQ/gg1Y0UJS5Edg49 uouV9tiaOv8Ni/PgDTVGas1PnjQkUHORn3XQM6xg/EsGwdV4x/h7OuSqgkDTwELt7bFU fzksxKd908I/Wf6LYG0QmAi7YgflsdtnnUsVJ/6lrPUxDjHrflABNsCTt1Qgctr6tYnX jyWQ== 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=WO4AX7XyFFHsV4AjiM4EIB3cOTJZWjvABsI5O9WxhsM=; b=pwO3NodX/7A61+C8uXX9xZshP5lE5JIoOggi4f8A2/lfUDYRVLBrZcYw987y8lc+o0 Y7wySc4cvWLrH3FzU/Y8AKCZvPT330zfuMg9Lu5kj/S+E8/KDLKDfC2EG3rTnYtzfHeK SAchOK5b7RXjclzfQa6GmzlPAwMx/jqzTNn0NVpW5N3qW+hFNxxsZNNDkF/uB5uoq3pT PcyWMY3hfOb8rXt0SP8s99s4m0dvYBmM1UPcMKM5XGBaxMNFe6mHTNF2wVCgW4X+y95Y goayxInQ6r/0+QMfpUYvjmRfUIA3wopdIJeWW3ErtgXoXZOfxtS8Ef9KnjYPPo8kOlJI Vlng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TVXWajmE; 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 h11-20020a170902704b00b0016d15070027si11345433plt.352.2022.08.15.18.35.53; Mon, 15 Aug 2022 18:36:04 -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=TVXWajmE; 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 S1348776AbiHPBI1 (ORCPT + 99 others); Mon, 15 Aug 2022 21:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245635AbiHPBD4 (ORCPT ); Mon, 15 Aug 2022 21:03:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E6A8BA9FC; Mon, 15 Aug 2022 13:51:04 -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 838FFB8114A; Mon, 15 Aug 2022 20:50:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCB62C43470; Mon, 15 Aug 2022 20:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596629; bh=arXwBhpQI6OPqNlxGbSUSOG5lO22yRh40HpnT+j/kRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVXWajmEfBRANoGdQNIxLLT/yDui0vtHg8tAQfCqJMO6r4fjCa3hhZncqseIQ9nIz /1mMXeqb/vi8svaIho0Gilz9ioESVnjHzEnOhJ1aRmHaaXzPZd354rP2QENsWEkE+Q 4eiZrZtWRF+UhtiI0aeAkQ8y+593XcffATkJ0yOo= 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.19 1140/1157] tcp: fix over estimation in sk_forced_mem_schedule() Date: Mon, 15 Aug 2022 20:08:16 +0200 Message-Id: <20220815180526.069222680@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 @@ -3369,11 +3369,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);