Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp259456img; Mon, 18 Mar 2019 02:28:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqznSq+zja7eHptBxl38Q75PnbLDvKrB5G0LD+Fzf+ZRJYGJf4VSuW1K9tJzuNQSoI2PA1e1 X-Received: by 2002:a62:f5c9:: with SMTP id b70mr13856555pfm.255.1552901287762; Mon, 18 Mar 2019 02:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901287; cv=none; d=google.com; s=arc-20160816; b=eCNIisQZRgbktGqvSertXt2mc2sxRMc1jgKC7WEkoIwJXJyMkoXvomXp0M1ggeZinC xSVDH/LijbqZXFPyTKF5YCSkFWV3vpqJ0A/+NVW16qQ7COi3ojrQzkigln6dVsPuJa7r JTLhVoc4OQYXRahOpFm/ltlr0SDgu9XibaBb46vuyN1mfmAfZknO9aY5+MsP7O6vqzYn Wp4CmTH+5xysntwIXtTpAtC5QIX5oi4o26ZBb71Ze/Bw0Pxlko2LU2WZpcWRGdcJD+mD hVlDW00U5W1GY8uuTqCdQdIotgKg3xQtFXd5Nm9B+q9zIeReCh++yZ8H/SQhwyp2BwbC 99QQ== 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=S13wzDcfE2oDLTPkHeihItCF/8sdqcjGsoKmYvanwHA=; b=0tAwpZZ2MWydZk6ZE75UnrQnPut2WAxmjHYvJFD4Jj792AkFYbNkXFo+JvDDjlyLo1 OULug7XHsg0pV2GoL6cZVg31p1u8OjLxkenu4IJuwtxqP4M3VwQANpx0mnsdq7bmXPjt qOTxJhIFdh7HJlRQEXPv3uqMU+ZEGCxKze7o/a8AA4HbgbS2T5xVx2dhgGeSVe09P40j Xf5AJ2vlaoA6OUARPTOpYTLI83cr1UCwFoOfe0XHCtRFmxGgLAoNrZiCiBUZoUaP1I0t c5rwduSnx7lQhdTmsmEnJaWz1E6NQXGw/xtVGoev51tHLtwMItZ143nga7OGOv5JUlgg sLzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HrswCXeH; 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 i4si8168212pgs.408.2019.03.18.02.27.52; Mon, 18 Mar 2019 02:28:07 -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=HrswCXeH; 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 S1727613AbfCRJ0u (ORCPT + 99 others); Mon, 18 Mar 2019 05:26:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:59878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727360AbfCRJ0r (ORCPT ); Mon, 18 Mar 2019 05:26:47 -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 CC59821773; Mon, 18 Mar 2019 09:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901207; bh=J16TXg8Bj0+0EpZ2O/ctswJBPOwntF8WzyHcNaG1GfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrswCXeHh1A9LwCZSMWKVD/WxC4r5K32x0TafwZLy+PKIJLGEyJp76eSQQJCWtODp pyB+ZLeK6F00Hq3MaymiE7LcBRKhGQzSqcf+IiupB0Z5C0COpovLWNwtkd2hw5OhgJ JY5Lu5kPx4U69qr3FkMb2Cp/Jr3UubS+H5SfzGcU= 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 5.0 19/43] tcp: do not report TCP_CM_INQ of 0 for closed connections Date: Mon, 18 Mar 2019 10:24:11 +0100 Message-Id: <20190318083716.428723811@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318083715.877441740@linuxfoundation.org> References: <20190318083715.877441740@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 5.0-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; }