From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABB2C48BD3 for ; Wed, 26 Jun 2019 08:45:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9ACF208E3 for ; Wed, 26 Jun 2019 08:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561538730; bh=MvX15utEKAcATYppKZNs7AWrpDtaWHcM6Ve5Lm0+uOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nwclkpEbwzV2DlBtg0bqZ5kGX6ZXFdqC84dxiPBy2Kuae0zsBhKV6CFSQyTPfstOc 3oaBRQJKZgX0Wua4LiV5qkw0qiMux69qT2FNz6YOzY406lr3RMXpk4ESvYaMcEYmhL I6UFN5JeynoBH/k/3KXd2ESPaoWO9DCLFmKJ9B0M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726042AbfFZIp3 (ORCPT ); Wed, 26 Jun 2019 04:45:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbfFZIp3 (ORCPT ); Wed, 26 Jun 2019 04:45:29 -0400 Received: from localhost (unknown [116.247.127.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA49E20663; Wed, 26 Jun 2019 08:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561538728; bh=MvX15utEKAcATYppKZNs7AWrpDtaWHcM6Ve5Lm0+uOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLF0zI1tmilDCcXwmz3nZNm1u7iDXv9u5bofe+A0Ka6eInJ+0zlvpxrpAqZV4jve3 tmocHAvqOlI3oCPulQXHvc0+9xrZ6Ma8EePrU6ZGCmddfeyxYv0QMkU6zsnKLkjkZr siia6yBqo9CpbxuZjeBns7PRwgJphpQ80SLNewvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Christoph Paasch , "David S. Miller" Subject: [PATCH 4.4 1/1] tcp: refine memory limit test in tcp_fragment() Date: Wed, 26 Jun 2019 16:45:05 +0800 Message-Id: <20190626083604.952026980@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190626083604.894288021@linuxfoundation.org> References: <20190626083604.894288021@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Dumazet commit b6653b3629e5b88202be3c9abc44713973f5c4b4 upstream. tcp_fragment() might be called for skbs in the write queue. Memory limits might have been exceeded because tcp_sendmsg() only checks limits at full skb (64KB) boundaries. Therefore, we need to make sure tcp_fragment() wont punish applications that might have setup very low SO_SNDBUF values. Fixes: f070ef2ac667 ("tcp: tcp_fragment() should apply sane memory limits") Signed-off-by: Eric Dumazet Reported-by: Christoph Paasch Tested-by: Christoph Paasch Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1161,7 +1161,7 @@ int tcp_fragment(struct sock *sk, struct if (nsize < 0) nsize = 0; - if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) { + if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf + 0x20000)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG); return -ENOMEM; }