Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp270138img; Mon, 18 Mar 2019 02:44:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjPWNzxAqSrRUABXXExF8GL3kGPgSTtsjga9st863LV965QfjYRutulWoUPfupEqNtq+HP X-Received: by 2002:aa7:8b03:: with SMTP id f3mr18005084pfd.208.1552902297272; Mon, 18 Mar 2019 02:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552902297; cv=none; d=google.com; s=arc-20160816; b=uQu1ovxBIJ2fdFLUtoG1WngsoksvlecMjE4u26pY4KwmY0fCl2v/NTlHpkrCY4qlbj Kx4HOqab8vn/BecTI5dxbx9zqwTo3YXI996v5yPmFRE9S5gDnTv2NH+ANxwYGi2L++9s NRGPGBf9/myB7FnZMuaBctl4/25DGhFNzA3vYCDhMMp9GPeLfjmyTEFgJSo7WLHHC2Mq Q0FqfLjwrZkGbBNJhvdiqGM4hgFUWzGGrenJq2UygrAtkEqfFTcVPQ9KwTZ7csbYEisW WIwiygVS2tI/+HVP8G7McqgNawqeTd/PBDgIbkC2K6gJu5/iU1g6cLctDTD7FGL38659 ME/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nou74miJSd7nRCIia71tYJPYAyrd3PI/NPREtlI3nNc=; b=eJH9QsNKRZXforxsSNIltjEa8LdCvPA3iWZHHXJJprZuBZky/oCEIcZ7cHfRfJ0Q4B SaerzHm5VrwLUbfPnmNOmhkxqS8AUn7e2B11sAJqm09VF7yZc/1qsH7IZO6HWRy4vVqM CuZbvg3C8VGRfQGPHEXFUxy0mNGgQ3U1osV0bGsrNwsJn0uSlro4eL/Tt4MwFI7Zs5/3 clqHC+wDMUmtdXEsapn1WpTYRAY39OboMHzJULl1Jcd/VehWf9zvb7acQimJW/lc6tpI fxi2Ea4X8EXCGlMHq1FP+4JZshx8j2PrzEiZeuA4kOpa4ADHvhsfBLgYLqmzrj3N2EiT 3H3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ND3sO1Sh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si8751926pll.63.2019.03.18.02.44.42; Mon, 18 Mar 2019 02:44:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ND3sO1Sh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728657AbfCRJb6 (ORCPT + 99 others); Mon, 18 Mar 2019 05:31:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728278AbfCRJby (ORCPT ); Mon, 18 Mar 2019 05:31:54 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 701A921734; Mon, 18 Mar 2019 09:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901513; bh=XJVg4AUyhz5QxPfNQ5Xrl7LNngDcd29gbFX+DjF1byw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ND3sO1ShKwL4uFsh/epyg/BUej61/30zpuqh5KcpaFSKUXGCWVW05TWsKZwGaq5Vx z4XM90kWp5w9sN+FAA+kw+gZrch2lWJGTjPaIWrbD3Vh83EgIVzy+w1OFZ27qiL5Lk ftoe95cyuCLdXMgFdUZ399uQ5zmubVvEsjk2o95Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soheil Hassas Yeganeh , Neal Cardwell , Eric Dumazet , Yuchung Cheng , "David S. Miller" Subject: [PATCH 4.19 17/52] tcp: do not report TCP_CM_INQ of 0 for closed connections Date: Mon, 18 Mar 2019 10:25:14 +0100 Message-Id: <20190318084015.595388165@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084013.532280682@linuxfoundation.org> References: <20190318084013.532280682@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Soheil Hassas Yeganeh [ Upstream commit 6466e715651f9f358e60c5ea4880e4731325827f ] Returning 0 as inq to userspace indicates there is no more data to read, and the application needs to wait for EPOLLIN. For a connection that has received FIN from the remote peer, however, the application must continue reading until getting EOF (return value of 0 from tcp_recvmsg) or an error, if edge-triggered epoll (EPOLLET) is being used. Otherwise, the application will never receive a new EPOLLIN, since there is no epoll edge after the FIN. Return 1 when there is no data left on the queue but the connection has received FIN, so that the applications continue reading. Fixes: b75eba76d3d72 (tcp: send in-queue bytes in cmsg upon read) Signed-off-by: Soheil Hassas Yeganeh Acked-by: Neal Cardwell Signed-off-by: Eric Dumazet Acked-by: Yuchung Cheng Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1901,6 +1901,11 @@ static int tcp_inq_hint(struct sock *sk) inq = tp->rcv_nxt - tp->copied_seq; release_sock(sk); } + /* After receiving a FIN, tell the user-space to continue reading + * by returning a non-zero inq. + */ + if (inq == 0 && sock_flag(sk, SOCK_DONE)) + inq = 1; return inq; }