Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3011096ybi; Mon, 17 Jun 2019 14:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqypUZX7q6RJPP3no5VLd9xGbzHNzKwxnWuId4UQu+cuzRB+bAPYrwqcZ6+E5qQHl66eVib3 X-Received: by 2002:a17:90a:cb8e:: with SMTP id a14mr1210577pju.124.1560807497936; Mon, 17 Jun 2019 14:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807497; cv=none; d=google.com; s=arc-20160816; b=Q2In6HkKH+kg3HPG9vE9J692j9zNgyapm89dxR78Gxg1VTTaaV7ulyCr0APXx6PlH1 nbwdO25K8k9yvGxOsmLXkodzGG5c+szgZDWV+GSh28//9P2dcePIDALnnRwZWFSpGeaD 99VM70Vsp6nwviEYlvvkMp9BuTUep35BlKAM/MrsBKO/131oFC8AO6naLNTY/QJC+/66 HG21AFFPeAiYkg3HISaaO3dw3EMNHXSb2Q4L7crE+tf7+5E47+RoQENx0mVh7qAsgyVt 2/rCaHepSN2xi34VuDOzP4WJluVVWQLZ6TDyJ5xHobn4C/KDEibzbgXifDXEeM6e/YIO Z/Gw== 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=gb2QJkB9YXWqnkerDkQrPxHKB4fu9h/HRRape1BRnYM=; b=ja90E0GtklGnjm7TKnoiYGZnwUf5VwI3ao+xDH4m3ZR0vdrOSoyLFl6YRfNqt7C4dX 9DDuAr7dko62OszM7qEWkqsRMkZbBSj0SAYoohLOOHExQirDiyTEy4gFvXCAuG024fjV 4Isa2AXSyAeSsWuJAAVq/wVb6VNjbFy5R+60YnxUonlxPRRjKGW7rq5WynQW5X5wY+oQ QAqcRrHW0OsU8ndDS4uguTFGguKPhpEP2kzM+E+hTeSFGb5I8ae08V20npA8xy0vtL2l 8mtKsy/vczhJM3p4iwh6wygMNHPg3QSRXqTNqqqWWggtheRlqsi/aQ52IXuCnkyg+IdJ P25g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CLyWcV0z; 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 b13si11687547pgk.19.2019.06.17.14.38.02; Mon, 17 Jun 2019 14:38:17 -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=CLyWcV0z; 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 S1729285AbfFQVVI (ORCPT + 99 others); Mon, 17 Jun 2019 17:21:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:45534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728750AbfFQVVF (ORCPT ); Mon, 17 Jun 2019 17:21:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 7AF5520652; Mon, 17 Jun 2019 21:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806465; bh=hEgJyZc9Hwr8ie7GW20x125kBieP37qILr4Cyx2FG3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLyWcV0zypDGvbDYVT3unBQ81JMR+hMV/Y5Po5DjJjPaZsicPrrYxgUNc0hv9oFFp VRCUySgk0wjg0y5gyPTYSs5HfDedHXK9l3ynRqgC2WiEtwxK5cKrcVOuOFOgl99r/o P+Bq+hEiQvSg4fkatUVpAQmply5EILQOgZ/Vpbmo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arika Chen , John Fastabend , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.1 061/115] bpf, tcp: correctly handle DONT_WAIT flags and timeo == 0 Date: Mon, 17 Jun 2019 23:09:21 +0200 Message-Id: <20190617210803.364287540@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 5fa2ca7c4a3fc176f31b495e1a704862d8188b53 ] The tcp_bpf_wait_data() routine needs to check timeo != 0 before calling sk_wait_event() otherwise we may see unexpected stalls on receiver. Arika did all the leg work here I just formatted, posted and ran a few tests. Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface") Reported-by: Arika Chen Suggested-by: Arika Chen Signed-off-by: John Fastabend Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- net/ipv4/tcp_bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 4a619c85daed..3d1e15401384 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -27,7 +27,10 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock, int flags, long timeo, int *err) { DEFINE_WAIT_FUNC(wait, woken_wake_function); - int ret; + int ret = 0; + + if (!timeo) + return ret; add_wait_queue(sk_sleep(sk), &wait); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); -- 2.20.1