Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp562266yba; Thu, 18 Apr 2019 06:05:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeFCc2FiRh6AqzqToD7WOuuMhZTHsgS2+IBuRDP9SoVJmnHDRQ51AdSDOfyqqy1DMfgbpZ X-Received: by 2002:a05:6a00:11:: with SMTP id h17mr47943698pfk.232.1555592708678; Thu, 18 Apr 2019 06:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555592708; cv=none; d=google.com; s=arc-20160816; b=AubnPkCuuCZGuxnH62i98yVVIpm3rMsNb/AIQYSjrv4PwSXvIOgmINApiAyKLxOxBg ws9K/cmxTnWlbSP1VMQRgbRtRAp/DWgn2lOyOj7AZNaG/Rxv7kWuN8yWtkcXzVzw+nPw PjTjnNU7mp/tkvREGrYTcNeNZ5BWxVNQRfqTYCFpx3i3ep/sqf6OJiLL6plPzxFRpyL6 /XyZb6WvhoHzikjEL3nE3kur0vnJXzJaTQtjK9PreR3KWepqwmGD21f1ySGHSxZ4otqG 59LUt9M2ctSkIZem+D4fCMipWn5XVUf8L6jHMuALkgAksV2pPEHH0eaj023Z3IoEWYy/ nPkQ== 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; bh=W/IJHbTqHqpL2OsIpUgLKcZxDTFvuYW9P+wM6vW1CHo=; b=LyIe7RUp0PgTZP2hOgtsTPq7jxy8f3KUMocIxF8dGtKakRk5cK7ISlFUrOoa7eF9FE HHkvhaQfYdh0WAQShHr5h6XdS8RT3jqPYIo36aU+PeU/SmxZ7sTe1gOGCsuNhZKkavSL O+OSbhRh0HyumenrC4LKwRoezKhwp+ct8ujhnHZM3x+6JP1jY8TvM2uSaiokT3FbjNp4 pbcsaPWimNL4C5/zyVL0VkLnfWUfoMUuRemXQXQbFj4aeU3xhNatv8r9hYzwW/Gtc2+f RE1DseRMhVo48JZQ6RgQM8/9kn5rKWKEgctt8KmUK8vSg1YPZLMISu8hg89UJ/LQ89cH oPdA== 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 k3si2310867pfc.91.2019.04.18.06.04.46; Thu, 18 Apr 2019 06:05:08 -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 S2388392AbfDRNDN (ORCPT + 99 others); Thu, 18 Apr 2019 09:03:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:35612 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729497AbfDRNDN (ORCPT ); Thu, 18 Apr 2019 09:03:13 -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 25228B64C; Thu, 18 Apr 2019 13:03:12 +0000 (UTC) Date: Thu, 18 Apr 2019 15:03:10 +0200 From: Michal Hocko To: Laurent Dufour Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yang Shi , Michal Koutny Subject: Re: [PATCH] mm: use mm.arg_lock in get_cmdline() Message-ID: <20190418130310.GJ6567@dhcp22.suse.cz> References: <20190418125827.57479-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418125827.57479-1-ldufour@linux.ibm.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 Michal has posted the same patch few days ago http://lkml.kernel.org/r/20190417120347.15397-1-mkoutny@suse.com On Thu 18-04-19 14:58:27, Laurent Dufour wrote: > The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end > and env_start|end in mm_struct") introduce the spinlock arg_lock to protect > the arg_* and env_* field of the mm_struct structure. > > While reading the code, I found that this new spinlock was not used in > get_cmdline() to protect access to these fields. > > Fixing this even if there is no issue reported yet for this. > > Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct") > Cc: Yang Shi > Signed-off-by: Laurent Dufour > --- > mm/util.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/util.c b/mm/util.c > index 05a464929b3e..789760c3028b 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.21.0 -- Michal Hocko SUSE Labs