Received: by 10.192.165.148 with SMTP id m20csp327553imm; Tue, 24 Apr 2018 23:32:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Ml5heP/moL9iAji4V1B+uez73po9PKO4mzy98dG/2SzcD1k7X8hRChjqj8Fok/uTP1DLd X-Received: by 10.99.126.82 with SMTP id o18mr22629409pgn.116.1524637924376; Tue, 24 Apr 2018 23:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524637924; cv=none; d=google.com; s=arc-20160816; b=gb8EpHiNtp7xykel0tNICKV7mWE0gi+5sj+2ZhCbpzNlq9qMOOwvncgpzP1QfdzOj6 +fWvTY5X0qzZXTAl16jrfa+VTsnw38qpz/2eQ6QLI7BvdS4p9rwry15M34px2EB1Mkj/ +T9R4MiXBO+KF+7eTnjcB3BLL55U16RuFwBuntvtnP4/W//Xa69X2wKzT+boL5idB/Jj zlkLlr9WBbaLeVv/7SglsVlDUr4Np0DQBWJ1jgb0GOeRYkC3mZlMPq2oEnl2cuSJJd3c mZ2sk3LWQxgjFrLw9jRahViX8vCdKmwkEFigK0xrBi3H04sZXAWJSTzsrL4QveUXCKJZ bLZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Vz5Gf5tLUh5QwLuamrcGa70JDEz59lT73nCaHS70q4A=; b=BEQBqGh1tOcKI/2V2YS0JpIcqR5HeWtirouaSMA0MIJ0jvAyfMoGrTD4Ds6hif8le1 TMybwAIezwOSkbYqfD2p8SYXlo5ZaMwdOqFGt1xdmWsqV9DbmrZ5Cdqt4ronO6vviq8/ phVVZeXKdpmrr0viRyRtmVR/ZInU/7TNrrT913CY1AVEEg2CMGqkGVlAj68ePomPbPmE mRqpvtusyMhTFj8DCzldBU7ImetDZoXFYjfV2P8K+QN3lZSHH7CWlC0mM2xlZHBqpqbI r7TYb7/PwxR3I+lhkji3suvcsHePjarHM8eYdfBJkeGEa21EeagEwB7YHFPI6B9/wpMh MUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=axjD4yEU; 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 t135si8202637pgc.656.2018.04.24.23.31.49; Tue, 24 Apr 2018 23:32:04 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=axjD4yEU; 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 S1751588AbeDYG3G (ORCPT + 99 others); Wed, 25 Apr 2018 02:29:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50710 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbeDYG3D (ORCPT ); Wed, 25 Apr 2018 02:29:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vz5Gf5tLUh5QwLuamrcGa70JDEz59lT73nCaHS70q4A=; b=axjD4yEUCAwfnF5LYJ8DlZp2H i60QQ2rjdf8L8c3CK2v1cB5W3MHICa6LQLhpYX/BwDUB6SAoPXRTRQSHy6Zv/Y42uKFCFsz4W8WXu zuPL4WUJGtabDhPji7R2mR3aqk7iKKVwlagNAxsPNlxRHzsMIF8X0d2sNh2ZDezWjYMjZHVGRXy73 5Y4C6FhmBQcAhxFLQnLDD17u2QjlUO5JnXI41W5hEgSwwut4hp29GEnBQPlbeI4WGMCarGbHQJxYn wK7XvryzYPT2/dkZKwCq2af2Pt4qhTOzGGBiJ1x41vvgaE5MVvnD6/rjLddkuZeB+TejV2k2yU6dk kn13wMwyg==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBDvH-0007Ew-Pf; Wed, 25 Apr 2018 06:28:59 +0000 Date: Tue, 24 Apr 2018 23:28:59 -0700 From: Christoph Hellwig To: Eric Dumazet Cc: "David S . Miller" , netdev , Andy Lutomirski , linux-kernel , linux-mm , Soheil Hassas Yeganeh , Eric Dumazet Subject: Re: [PATCH net-next 1/2] tcp: add TCP_ZEROCOPY_RECEIVE support for zerocopy receive Message-ID: <20180425062859.GA23914@infradead.org> References: <20180425052722.73022-1-edumazet@google.com> <20180425052722.73022-2-edumazet@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180425052722.73022-2-edumazet@google.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 24, 2018 at 10:27:21PM -0700, Eric Dumazet wrote: > When adding tcp mmap() implementation, I forgot that socket lock > had to be taken before current->mm->mmap_sem. syzbot eventually caught > the bug. > > Since we can not lock the socket in tcp mmap() handler we have to > split the operation in two phases. > > 1) mmap() on a tcp socket simply reserves VMA space, and nothing else. > This operation does not involve any TCP locking. > > 2) setsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE, ...) implements > the transfert of pages from skbs to one VMA. > This operation only uses down_read(¤t->mm->mmap_sem) after > holding TCP lock, thus solving the lockdep issue. > > This new implementation was suggested by Andy Lutomirski with great details. Thanks, this looks much more sensible to me.