Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2480419imm; Mon, 24 Sep 2018 05:13:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYpr3Lx0reD/kqYiO0HEC0U4M7OaPQuYackK8HnoR15mzFOdJY0iPMc5wCDMxLM822GtOTo X-Received: by 2002:a62:c008:: with SMTP id x8-v6mr10116503pff.149.1537791206689; Mon, 24 Sep 2018 05:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537791206; cv=none; d=google.com; s=arc-20160816; b=XhkgDdyLKQXf3+AHTJUb4LmRxM0V/eBVtSNpUJM43nAg8uQE2OSHvVdsg45wVxOvBw 3g5pa9V40un2k/9g/wmNaXtOjQpiteWpRr8cSPkGmyZ97xWB7TAEZ/z0RZ3apXLVFvIA c/bQbASOr3mgjGMvllwca5+Jl9xA0CIqrMhS8v7QZlDdMhKzsMB8gOqXcTv4tzCbxuBz c3Qpn1UnzIx0Q9XkYbCB1M8Rk/AfIFoKHsKBRA68ZsCSAZpAWMf1BG9ADDI0xpwZ2Gkb YmPJCEfBoqMjVNYTJIglaRNFqeBKiT23bwGoZ/o6ofRx3ZkBbIQQoChr5vkpFKb7t5v7 Sn8Q== 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=an6aNsMIGNDxeAKHzA+osXtPlEyi3XVuFe9NyoV6cGs=; b=iNbApXxHtMao5oe7JvZHX4q6psfzk1VM9TTFM0303VQP+/dt7NX/hy0tKGPFGFZ4C/ F5v7ev3EEuv3mP+8duKzBgU0h/l8T7y0uZLe/k4uUHLlRby8Ki/kY9wrZuZhbmpHV3mC gxy60vLarutHdKJJkITLPlobBSeaipP42qYAemtERgKD8nnhtw7xWNXgYruYZjH/iU/q wZEHOMSkkpemTYscNXc07tEJO0xdeFHntTkpGXa+Ua2aPKo9dFSmjwOA52JSANZbI2Hw tJJqHPrIFbKBdQUY2+JJDyU7ecIU0J5wii93TbQJdqMq4tvOdg9sWUtUG6UxZ93srAMt lq8A== 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 g128-v6si35717213pfc.339.2018.09.24.05.13.11; Mon, 24 Sep 2018 05:13:26 -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 S1731385AbeIXSOH (ORCPT + 99 others); Mon, 24 Sep 2018 14:14:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54960 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731371AbeIXSOG (ORCPT ); Mon, 24 Sep 2018 14:14:06 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EC7821081; Mon, 24 Sep 2018 12:12:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Whitchurch , Willem de Bruijn , "David S. Miller" Subject: [PATCH 4.14 011/173] tcp: really ignore MSG_ZEROCOPY if no SO_ZEROCOPY Date: Mon, 24 Sep 2018 13:50:45 +0200 Message-Id: <20180924113115.696440674@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113114.334025954@linuxfoundation.org> References: <20180924113114.334025954@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: Vincent Whitchurch [ Upstream commit 5cf4a8532c992bb22a9ecd5f6d93f873f4eaccc2 ] According to the documentation in msg_zerocopy.rst, the SO_ZEROCOPY flag was introduced because send(2) ignores unknown message flags and any legacy application which was accidentally passing the equivalent of MSG_ZEROCOPY earlier should not see any new behaviour. Before commit f214f915e7db ("tcp: enable MSG_ZEROCOPY"), a send(2) call which passed the equivalent of MSG_ZEROCOPY without setting SO_ZEROCOPY would succeed. However, after that commit, it fails with -ENOBUFS. So it appears that the SO_ZEROCOPY flag fails to fulfill its intended purpose. Fix it. Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY") Signed-off-by: Vincent Whitchurch Acked-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/skbuff.c | 3 --- net/ipv4/tcp.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -937,9 +937,6 @@ struct ubuf_info *sock_zerocopy_alloc(st WARN_ON_ONCE(!in_task()); - if (!sock_flag(sk, SOCK_ZEROCOPY)) - return NULL; - skb = sock_omalloc(sk, 0, GFP_KERNEL); if (!skb) return NULL; --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1177,7 +1177,7 @@ int tcp_sendmsg_locked(struct sock *sk, flags = msg->msg_flags; - if (flags & MSG_ZEROCOPY && size) { + if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) { if (sk->sk_state != TCP_ESTABLISHED) { err = -EINVAL; goto out_err;