Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3078313rwb; Mon, 15 Aug 2022 17:35:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR4JsUlG7ZOzU65xnehi5usqp1Fe8FhaXxRx0p1ugk+1iWkZg/5L6O1tz4L3R0lEKZzooq9V X-Received: by 2002:a05:6402:3492:b0:43e:9666:ece2 with SMTP id v18-20020a056402349200b0043e9666ece2mr16844547edc.65.1660610122451; Mon, 15 Aug 2022 17:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610122; cv=none; d=google.com; s=arc-20160816; b=jLn1X6z0IKvaKjXXtypGbAr+yvfV/KVl3KqN90lLwtCqSPNGHg7Pwv792qxFkTtFfR R6IszUQl9YS4J3VeK8CWmz8ZxY1ZW8d2FW5yTZ5KF7MVIbpdQf+6TGIxvquZuES0wowA i3YQZuSi4udU4kjgqmZR52V/F22igIzdQfi9N7MPe+0onoG2Ksi8WNRBE5Cy7cegnCln 3hXTqU63g2jzOwZQHGvhsaYg5kH/qx3dyJ7weEnlksmLlqbcKa4nxXWN02/J7RijCmd4 PRepU7/jjVYXPwLFy2WqR2HOPSqHUjKuUpWTrwjOWJ7vO/4IPlnbikF1fNeKB79HwyZA HHRA== 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=cBDF3nVgfhTJYgNo5HJUDWeli1x/Tpo+aogoiBQjmH8=; b=c5x/OI+u9coYnvq3BUIiqVboqV65Qe05zRedH5BqiGerlo0STCvOB0EzcnlFnSxObV LwVD6dyxjMAj24YXeb0CpNOCiteOzbn8I3Ond7qkDmTtbDrH4BtZLjl3ZlA46oMPgBIE hRAa9DziH5ihtTGHIP3BaBx00x5FWh1+jkL/DBb6TqKK489VsK0xTNcFALLgzqEt8npJ LAbX3o3JIBXDdRZ1CAdPQ/tG+FEhLnP0spzP02vbLP0sqfbqgIj08+rGzdVx+9FuBNuT VbfL+5gRdwyBt0QShB+Jl0M88vBTR2pZmNQiqgBZSjtKvDxwbmfleoyEG1pbygAM6hAP mQEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kra0gckR; 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 h20-20020aa7c614000000b0043d267cee03si8093854edq.299.2022.08.15.17.34.57; Mon, 15 Aug 2022 17:35:22 -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=kra0gckR; 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 S1354204AbiHOXny (ORCPT + 99 others); Mon, 15 Aug 2022 19:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354126AbiHOXl0 (ORCPT ); Mon, 15 Aug 2022 19:41:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 617C0B8A51; Mon, 15 Aug 2022 13:10:42 -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 dfw.source.kernel.org (Postfix) with ESMTPS id F33B260025; Mon, 15 Aug 2022 20:10:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ADE0C433D6; Mon, 15 Aug 2022 20:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594241; bh=wrdV1fXSBKWOJtHJ7kC8djl55hFYUK2qDMkSXC92H5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kra0gckRklY9r7iD3KaeTZKDmLJqQ5njHdp24jb08Ex1v4l8m9YrOB4fNZhFbMfKy fzI4/sszj7I2mci5nFzQCms6BOJ6FB5S6hcHjti7MrZeSCYnSBKOJ0G8d0+HZ466Cy MV4SygCs3XEU4qWg/+tp6JFS90n91CPj9TCyZnTQ= 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.18 1077/1095] tcp: fix over estimation in sk_forced_mem_schedule() Date: Mon, 15 Aug 2022 20:07:56 +0200 Message-Id: <20220815180513.603052216@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 @@ -3367,11 +3367,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);