Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp687754pxv; Thu, 22 Jul 2021 09:44:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzgpM1huRPpyZ7Dw+v+ksLsCDlj/AIWv7wv/91h7HLtqtIeX0kSi42fZDwSG3mn1hRUTH9 X-Received: by 2002:a02:a80f:: with SMTP id f15mr403104jaj.142.1626972291494; Thu, 22 Jul 2021 09:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972291; cv=none; d=google.com; s=arc-20160816; b=cP+usOwt//Csy82i3SafAgArqJic/+bwtSek4EhJbWGcxZ19We49UqBbuUXcqdf+Uz Grx/rqF+CYUSy+yU/3iWdqPDsrYZOc/nWWRMfqed/ekVgyEhTu9R7YKLk5NBAnIT3ItO znuURGIyu8fpVsGjDNBtlZBLns3jf7wyCqea1D1C5bw8obkf72Coc8avLBvPlCkpMxfc lPUWEEersfqSHte0ydszKWShED3HKGWZ2PwfCnsNWc4wdULmWk0K99MlmkjvzWwuehh4 gRIxLBtGY5EQGuXrYczzrHMmLHFsTwP8Czlzpvx/HTpl7nOev+/gdOpceD3/mK0HhZQS oI5w== 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=MqjExtxNuVsRs1pcQesFQG6e5L9AnuHxCd37FOZAdzI=; b=xR1YJy8zsJuDluBekQpci3DDObYPgO+fvVTdaMJknVupQlihVMULMRGZJ+767by10e 9FfNIbdeiPAMqMmcHckMIn7mhsfxMAYqVcEXugYqIoJILR/AKzu/4a8VJMKu/vScHa5w OrCmDTg68eCdRsa+U9sZOZhobS1hFoICKZ47sNztrPKOexQy5lVWxXGy5znpMxKQWpM9 TOsNHmw+TafpLoe9KuUv2r3sQhbAxfAAkgTe4RiB7o+vN7OOAt32CTHlIgtqwhcdZ7z+ SOtjZF+9fZPkzlSrO+1ZDnCgmcZQDPV7ZlJTrzXYxb4il/DNfKkcRGYvfGsewT41nm3w pk8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lsdDwkg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si31096776iol.30.2021.07.22.09.44.40; Thu, 22 Jul 2021 09:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lsdDwkg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233346AbhGVQDX (ORCPT + 99 others); Thu, 22 Jul 2021 12:03:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbhGVQB4 (ORCPT ); Thu, 22 Jul 2021 12:01:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F41DB613D2; Thu, 22 Jul 2021 16:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972151; bh=bIzTXGsHr8QHJ+5atn7vpgyCBEq5bSAhFCqbgLtBvxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lsdDwkg7jrTYP5uB8PbAJiUnmUWdhCGD+NqIHHiHdSQDrOk3np154VisJeRgVgGWY 9Ytzejs/FhU/LgY6opLwIjH5HqieGgaCjTzhnH0Wl9lByZTsHFDvLmadETlBKJd8jV OXmlqxQ0wwgRpbCBmoYHyxfcnd/Y1eWSjdFamEvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Talal Ahmad , Willem de Bruijn , Wei Wang , Soheil Hassas Yeganeh , Eric Dumazet , "David S. Miller" Subject: [PATCH 5.10 119/125] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path Date: Thu, 22 Jul 2021 18:31:50 +0200 Message-Id: <20210722155628.661907281@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Talal Ahmad commit 358ed624207012f03318235017ac6fb41f8af592 upstream. sk_wmem_schedule makes sure that sk_forward_alloc has enough bytes for charging that is going to be done by sk_mem_charge. In the transmit zerocopy path, there is sk_mem_charge but there was no call to sk_wmem_schedule. This change adds that call. Without this call to sk_wmem_schedule, sk_forward_alloc can go negetive which is a bug because sk_forward_alloc is a per-socket space that has been forward charged so this can't be negative. Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY") Signed-off-by: Talal Ahmad Reviewed-by: Willem de Bruijn Reviewed-by: Wei Wang Reviewed-by: Soheil Hassas Yeganeh Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1361,6 +1361,9 @@ new_segment: } pfrag->offset += copy; } else { + if (!sk_wmem_schedule(sk, copy)) + goto wait_for_space; + err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg); if (err == -EMSGSIZE || err == -EEXIST) { tcp_mark_push(tp, skb);