Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp271838img; Mon, 18 Mar 2019 02:47:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmNe+6NVGZ9QNcaxICkcClNQvt+fhl6esSD2TTx1CzpWQYMfcFy/ElV2r4YP0SVuOPDqkA X-Received: by 2002:a65:5181:: with SMTP id h1mr17016397pgq.422.1552902468868; Mon, 18 Mar 2019 02:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552902468; cv=none; d=google.com; s=arc-20160816; b=YRkUX8fnDhKm2ryvdehv/CmjcAjsgbODLB46baRAQoNOb1PpnuNYBJvIzOZQo0yX/C aAJ51xoOnBCqG3wBNoqKfF4ghF2yCsvoZTBpdyHHHSE7bC+LcJvowdy+7X1jwU3YIEFb RrAC6ivR0wROR8O91HaJaGleQ/5X3wNh9KayVVPRT+0AgqbFodHGryvd/uw7Vw8jCrNC 0ADxOwX0oFzdii5KwAEZ+/sNM/AZxhRkBXwIXEmzOVwWuGDlGttrhYqY8mwr4L9XzzvK 3hh5swYW2Ur9Mt3N1wZs58SxHd5Grp96X4JLG/GggBCu+VqfLv4/WMDRjocHRc9+U3GE DDvw== 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=0ZQuPOzSU1XUHZYptPRULHqrKX9Ap2HSrANdN2upInc=; b=SuzxnUEFw9GJfQlYOteaMKwPanIw01P7+qHlaTqMWy8U4sx87mUsRjmdF3I1pfy+iv sLsrzHE0q1Vf/jGxIXeULXHeiWUtB2+LFnnPuJziOMUDYX9j81ikpwNx8JwXWKOXLEh4 Gh2saxcZrdoWk175xHmTUqamoJlOjZIIbhigR+aqatPlpBUV5gYoVTLZzgxpQ3Nf59MY XHqs585TTJK8FGLR6ih103YWwh7F64PuM8EjyM4/YjQ3EtVmNBNnlbDr/DBoh+QJKuZ9 YnuvuBnT15eRic06KV6b6TslNUd+78B3SBVTA8lvyK/6wHZxVAkP98bHsPfd+ON4HZ30 XlhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H8q2Efqg; 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 c4si9000381pfn.83.2019.03.18.02.47.34; Mon, 18 Mar 2019 02:47:48 -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=H8q2Efqg; 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 S1728285AbfCRJqN (ORCPT + 99 others); Mon, 18 Mar 2019 05:46:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:35366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727421AbfCRJ3J (ORCPT ); Mon, 18 Mar 2019 05:29:09 -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 1B191214D8; Mon, 18 Mar 2019 09:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901348; bh=p1GXDvGApxDZIFTHE/uaoEC7UFcdhT/bqkm0dK0l21U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8q2EfqgvoKTbOeiTPaeII0qETqmIJZohA+hhg9MhRRS6XCJvGtli6/9JZns0qWjS JGZ9CrUECmPDhHCXCeEF3x/8X+CpCFIQ7r5HEsK9ei9NUT2Y82V4GDhNNvchqZx7QG kBZcoQcRmpZvP/G+rRx2D0r381cA/z2thKAyGHSc= 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.20 18/52] tcp: do not report TCP_CM_INQ of 0 for closed connections Date: Mon, 18 Mar 2019 10:25:05 +0100 Message-Id: <20190318083845.610451195@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318083843.398913295@linuxfoundation.org> References: <20190318083843.398913295@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.20-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 @@ -1914,6 +1914,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; }