Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2495931imm; Mon, 24 Sep 2018 05:28:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV62TdIibSU3POUOdbPEwIgyagvFMNzjep+vPj40uYvxV26O2rWR9UbCVJqBAcbLR+WPZT4bz X-Received: by 2002:a63:2541:: with SMTP id l62-v6mr9172550pgl.343.1537792091474; Mon, 24 Sep 2018 05:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792091; cv=none; d=google.com; s=arc-20160816; b=HuoGLvIoME4vte+lGlLbO1p42lVmi+rOa4kQTIt0OY0JwLARE+gXXX3munM24xjB5A Ne4SP2SrWTtNTD2MP8WWna/JzB5gw/M7yaOtLmgoXjG2CpNxuNZc3dHf0oMDLy5OBCPL nowJlTivlNzY+ExouehNKpcWbh4viBOZxvbEvhzdP23q4/Hkmz3VeB7h58JPfEqOSkpH sf34y73HAuEOkdrwfsbYCsWVwN895xeMaS67E6SWpTO9UFKu01idodCQBy+rsbF7gThz hHExpwjzViFN0rA8aTG6sxLJOMiK/wEvL27LBfsCtjabmmee3RVOXByuXgxq4CouHo8G 7nvQ== 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=1Md1CBe2kcWez5NZvLCTG5HFn1iXL9jQ+uLTJxAkGgg=; b=c0GyQiiE36blFDAGZuorxC8PPQXglBn8/r0De251wx9dfEwf6Gf7X2lL6e1ykLhjFx gkwnHMcx5b5tAjXhPX/jO4wTLJZkSdZSdLVBroTGb51/Zfr/kR8pIZ1+OBD/365XuLcu 4B62x9zy8bNg+3ekp9b5LuUfLJaxXeYaygVbqQcwtvZYTC00fFCJ7Q+Do3joacxLaoTj /iEAk13rU7iJoCvgmhJ0tT74Pv8c4F7lCXYBYLwRPaYL7bq075r30JQema4AOqKkdqdT rcdPHM+D07giDffejRRk3qZPeT+wDCkChIMxnok3nc5eZ+2zmU4r+FnBxfpXKU/nM9H7 ky4Q== 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 cf16-v6si37120834plb.254.2018.09.24.05.27.55; Mon, 24 Sep 2018 05:28:11 -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 S1733228AbeIXS25 (ORCPT + 99 others); Mon, 24 Sep 2018 14:28:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57210 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732223AbeIXS24 (ORCPT ); Mon, 24 Sep 2018 14:28:56 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CAF77108B; Mon, 24 Sep 2018 12:27:02 +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.18 012/235] tcp: really ignore MSG_ZEROCOPY if no SO_ZEROCOPY Date: Mon, 24 Sep 2018 13:49:58 +0200 Message-Id: <20180924113105.617367236@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@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.18-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 @@ -939,9 +939,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 @@ -1186,7 +1186,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;