Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4198890yba; Wed, 17 Apr 2019 06:43:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd+MYhG6NpiUGrZYOe1uaxuwAwwqZ12W5ahQB/aob9n5l1p0r2ajGa4C/TeayJ0TG2lbDh X-Received: by 2002:a63:e402:: with SMTP id a2mr84227465pgi.268.1555508595968; Wed, 17 Apr 2019 06:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555508595; cv=none; d=google.com; s=arc-20160816; b=O2+r8cmCaV16jCe6e1JxftOd5EaGYTkOsWkrJ0xVUY5sj2v0KY0wjLtBVNX3knSCs+ +oDgAOSEWIAuOgkk9T9jRYsuQ6fBHqrgLKhFtHS/kel/OhngHjtibtAXL/sZatOHeqee 8E20NAkaanRgyM5GpB8R7cfIttsU/MsFhjCn6IIzjP69hgo8RbipRn0uwZ3UqbOSMe6Z pwjb5eFcWqKlXJ6+M4kR7OxF7heceJwxRYko1JcX1Qe2g3I6CQiktlNo4m+0ZaGu3aAk tJCktrZUdRktXiqC7sqK8Z9Bny+7Qb7jyVWeF52WyFudv5RKzFgt6w1g2j2qd+0VIvk5 JDww== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jzICcgedi+s9LIZxaX5EHYwDuMiVUohGNkzjSLI0MOw=; b=wUjbXSqx9K7DR/kKFInAHgKbZkFE+FYZwVpNYQT16FfjAVfusBRyWwrj5iGcJKPf68 oj9+Z5Ed5Pp8U0Wx/Qc99aR0ADJqh4jOYQjcSMxm8Ca/izH7RfMBXvCs4L/CbZd5msTr dvrByrQasAwA45n1IQYyXhSgYKtqXb0i3QjpeQbgrTp4Bcgp1elVvVyVBXQgZKzo2/CK j8/Xty0POk9cu2iz3M01WDpBEKNN2Pj0DyZyx6M7TQuRIAmlGOARoVLa2g1+tb3FXdtH ZrKwnuno+KW2B4PCQXhmbbmLpJNwJfTcA19BWwI9SrbYVHJlmP5uJzWoHbagUpLZ4o0j f91Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si50084776pge.151.2019.04.17.06.43.01; Wed, 17 Apr 2019 06:43:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732222AbfDQNlz (ORCPT + 99 others); Wed, 17 Apr 2019 09:41:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:35524 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729939AbfDQNly (ORCPT ); Wed, 17 Apr 2019 09:41:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8A131B175; Wed, 17 Apr 2019 13:41:53 +0000 (UTC) Date: Wed, 17 Apr 2019 15:41:52 +0200 From: Michal Hocko To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: Andrew Morton , Mateusz Guzik , Mike Rapoport , Vlastimil Babka , Geert Uytterhoeven , Arun KS , Bartosz Golaszewski , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: get_cmdline use arg_lock instead of mmap_sem Message-ID: <20190417134152.GM5878@dhcp22.suse.cz> References: <20190417120347.15397-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190417120347.15397-1-mkoutny@suse.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 17-04-19 14:03:47, Michal Koutny wrote: > The commit a3b609ef9f8b ("proc read mm's {arg,env}_{start,end} with mmap > semaphore taken.") added synchronization of reading argument/environment > boundaries under mmap_sem. Later commit 88aa7cc688d4 ("mm: introduce > arg_lock to protect arg_start|end and env_start|end in mm_struct") > avoided the coarse use of mmap_sem in similar situations. > > get_cmdline can also use arg_lock instead of mmap_sem when it reads the > boundaries. Don't we need to use the lock in prctl_set_mm as well then? > Signed-off-by: Michal Koutn? > --- > mm/util.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/util.c b/mm/util.c > index d559bde497a9..568575cceefc 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) > if (!mm->arg_end) > goto out_mm; /* Shh! No looking before we're done */ > > - down_read(&mm->mmap_sem); > + spin_lock(&mm->arg_lock); > arg_start = mm->arg_start; > arg_end = mm->arg_end; > env_start = mm->env_start; > env_end = mm->env_end; > - up_read(&mm->mmap_sem); > + spin_unlock(&mm->arg_lock); > > len = arg_end - arg_start; > > -- > 2.16.4 -- Michal Hocko SUSE Labs