Received: by 10.213.65.68 with SMTP id h4csp1647852imn; Mon, 26 Mar 2018 11:38:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELtFGvHiKJLRCNVCoIrK8CCENrg4JGiLh4w7r1wbEBT5v+NkWBcJA802EIRq8YMh8kV3UXsV X-Received: by 10.99.143.30 with SMTP id n30mr13596104pgd.213.1522089528143; Mon, 26 Mar 2018 11:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522089528; cv=none; d=google.com; s=arc-20160816; b=HqS7NleUbPIxGTJ3ZB2sdu769YgNQckojBtMRhG4H3OAotLvRo4VS1//qmObD0jCAv +GiyqAaR1zMwuGOJx/gedYqYyitLiOFXzrI7bWFJsMjz1Y3U21uxNWTj6uxBEf1x60bg /E+F7W3bomK59IuHxtTgPyALYolZ3yKBJ6UQifJKFrXAubjfvvmFnOOQpJ/f7FecvKy2 Yi+BIhV0VqbxfwI4T+5neMUT0hniw+LhQofpgIi2uMa4UrWt8RI5au1tWDiQ7A87Tl/8 gZPnAP3uValFtiGxAS2pvBw5TYNhHBaQV3wKPh7vViWYkC0mq0+FarlMoLcb+DKqpv8E auoQ== 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=z0bKNplIKIhE7U2K6lgCkb2qMSZKAW652yzI3WsS0BU=; b=BIzuI6DcwnNFlPJTUcIjr6KmwXNquJfMfCtAFTKzI41k7fhUISSWeWo721xYDwFcOF dt25S39JPKOVzCHJmdhYCrdtdgNrC+S7N83r+ZNjX8qxTh8/CC3k7JvYBqiQuusfrr1E /b+siX6UV8m3qpjaZ8kKXI+2bc9zJHgfu0w8yZiTv1lRdztrB70iufEgSAeFp9EkY78g OpFK3n0YhEWo9i9m8v/JLNjzJmhk7jeBUE6VxFXumH64iRVkTNMOyXTN4gtwHQqLTd9i auEi8yJS9eLATwxVbpLLOcb2fLTUVxsyUbpC8aTur3Iy8Ia2TCQe1TOI+uUgJYJs18id EGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iZu5M5kL; 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 h90-v6si11470258plb.377.2018.03.26.11.38.31; Mon, 26 Mar 2018 11:38:48 -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=iZu5M5kL; 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 S1752562AbeCZShc (ORCPT + 99 others); Mon, 26 Mar 2018 14:37:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45798 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275AbeCZShb (ORCPT ); Mon, 26 Mar 2018 14:37:31 -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=z0bKNplIKIhE7U2K6lgCkb2qMSZKAW652yzI3WsS0BU=; b=iZu5M5kLNlQtSh6eRr50rqj6X v1ZO1aW2oqpdrQXXrZ6Ew03ksvAtI98AjeqR6JedOaw5iGQQ1/6sCne2+FyM481dchvNIgUtTHn8v ihoeiycwBcLd61UTfuTN3ywd+xApTq/cMnvzbmtxttCNx9eHpmrO6kgWT1+ur04/pGruObTVXoNkZ 8q4Gfdq6mLcRGBEy7yNb0jDruOFrEsFh1JhxlMCz1WSYCnKLS+u8iVXjQukDAiGTdqIEkFVWVbIm1 awgyBgAhp5MMo3qcSKrhecsYPhAwlkqs4MN44/1q/T3U88faIiVSh7InVRGgxjNcSsPq2JufeJucc 9tSlbnRiA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0Wzl-0007QP-JM; Mon, 26 Mar 2018 18:37:25 +0000 Date: Mon, 26 Mar 2018 11:37:25 -0700 From: Matthew Wilcox To: Yang Shi Cc: adobriyan@gmail.com, mhocko@kernel.org, mguzik@redhat.com, gorcunov@openvz.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct Message-ID: <20180326183725.GB27373@bombadil.infradead.org> References: <1522088439-105930-1-git-send-email-yang.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522088439-105930-1-git-send-email-yang.shi@linux.alibaba.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 02:20:39AM +0800, Yang Shi wrote: > +++ b/kernel/sys.c > @@ -1959,7 +1959,7 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data > return error; > } > > - down_write(&mm->mmap_sem); > + down_read(&mm->mmap_sem); > > /* > * We don't validate if these members are pointing to > @@ -1980,10 +1980,13 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data > mm->start_brk = prctl_map.start_brk; > mm->brk = prctl_map.brk; > mm->start_stack = prctl_map.start_stack; > + > + spin_lock(&mm->arg_lock); > mm->arg_start = prctl_map.arg_start; > mm->arg_end = prctl_map.arg_end; > mm->env_start = prctl_map.env_start; > mm->env_end = prctl_map.env_end; > + spin_unlock(&mm->arg_lock); > > /* > * Note this update of @saved_auxv is lockless thus I see the argument for the change to a write lock was because of a BUG validating arg_start and arg_end, but more generally, we are updating these values, so a write-lock is probably a good idea, and this is a very rare operation to do, so we don't care about making this more parallel. I would not make this change (but if other more knowledgable people in this area disagree with me, I will withdraw my objection to this part).