Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1342542imm; Tue, 2 Oct 2018 06:49:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Pmlzk3X8DdFQrIr8dYlkt84hBcUolKFVpqTNOTlQCwJWGht0FjyCygyRt/eh/Q7sCQzAY X-Received: by 2002:a62:de05:: with SMTP id h5-v6mr16409768pfg.258.1538488184112; Tue, 02 Oct 2018 06:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488184; cv=none; d=google.com; s=arc-20160816; b=X6hXNjN/i+7Xj3EUAzBeE3Vt7g76iPj5eEn3kxZRHbp38tZML4grhaPQU+ZYxe1EeU QrAjQYtcV+fZ2pPuwNGCZ8JAZKvg/ZDmUP1F+dnP43NAS7iZWcIhLCl+KeG4NdnuxxQE FZGdb+tBfdoawbO61EUMfHqCy5BEH4iW7xjI0gJSyEi+bsC79tT3+fqF22y07JSxoMp8 0KusM1woZLkssd5lMaBq2fXJjUyZlXaUsAAqWOLwC/0zOfyie4/IE2EQib5A71U0Os+u EeGbtw+DSEHXcPduyw3BXfpY1iqK6lAsmcRoVDEcmn3fxteCqx0HK5u4IhjifmmcthgK AOJg== 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; bh=474pemYwRrR3D/BtmBKN7XdTOJ19TgG4f2PsxZZUPIg=; b=zZXloLQZgc61Y6ui6kv+mQKF0RmY2I+YkhpbzvEK4wlQeaS7KJ3jNd0BSlOMzd9E2A RkKIYdEJv7oqn3+drmt3vJ03gO64s3V5fYjtIyIs6O5+dPP5JpRrxo2RI6X05dvQ77Eq ChHM6fbVj2sXL/AgyxBSiQ55gzCRMGKY2/HDvsKQ6nlquvVIESsK4pd/x4qRyEG9qcVP x8PDPTl3ayipmWVpPRKQaw6WLMQt+my5mPW4hi7NN2mFD4NOK0BVbg2KLEwMBMq9jtrf Pd2r8jq4pAhSSpen5LLyo0ok1t2TqAKCNrqewLbFJvk+NEEDw7ojb9tpiD+JKo9bh55o T4EA== ARC-Authentication-Results: i=1; mx.google.com; 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 v23-v6si7455654pgh.581.2018.10.02.06.49.29; Tue, 02 Oct 2018 06:49:44 -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; 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 S1732390AbeJBUSP (ORCPT + 99 others); Tue, 2 Oct 2018 16:18:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35410 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732373AbeJBUSO (ORCPT ); Tue, 2 Oct 2018 16:18:14 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8E62E5AA; Tue, 2 Oct 2018 13:34:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Fastabend , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.14 120/137] bpf: sockmap: write_space events need to be passed to TCP handler Date: Tue, 2 Oct 2018 06:25:21 -0700 Message-Id: <20181002132506.929797303@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132458.446916963@linuxfoundation.org> References: <20181002132458.446916963@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: John Fastabend [ Upstream commit 9b2e0388bec8ec5427403e23faff3b58dd1c3200 ] When sockmap code is using the stream parser it also handles the write space events in order to handle the case where (a) verdict redirects skb to another socket and (b) the sockmap then sends the skb but due to memory constraints (or other EAGAIN errors) needs to do a retry. But the initial code missed a third case where the skb_send_sock_locked() triggers an sk_wait_event(). A typically case would be when sndbuf size is exceeded. If this happens because we do not pass the write_space event to the lower layers we never wake up the event and it will wait for sndtimeo. Which as noted in ktls fix may be rather large and look like a hang to the user. To reproduce the best test is to reduce the sndbuf size and send 1B data chunks to stress the memory handling. To fix this pass the event from the upper layer to the lower layer. Signed-off-by: John Fastabend Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/sockmap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -313,12 +313,15 @@ out: static void smap_write_space(struct sock *sk) { struct smap_psock *psock; + void (*write_space)(struct sock *sk); rcu_read_lock(); psock = smap_psock_sk(sk); if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state))) schedule_work(&psock->tx_work); + write_space = psock->save_write_space; rcu_read_unlock(); + write_space(sk); } static void smap_stop_sock(struct smap_psock *psock, struct sock *sk)