Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp806281yba; Thu, 18 Apr 2019 09:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOBhFXIF0vvxtraFmjqANManEwu4RdVVuRzbijUhMGXJQuoo1fFNyCW9PjF1WPauzUIuci X-Received: by 2002:a62:1bc7:: with SMTP id b190mr98455286pfb.29.1555606227170; Thu, 18 Apr 2019 09:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555606227; cv=none; d=google.com; s=arc-20160816; b=06dKwNWigvL4NIg37aOxlQRoZ0KUezguG1Y4iYD9VCw2YxCt66l3Bcg4YMHHcgqNDj xUdwMr5a43fbmOsX89U/5EXriCzAYrh4/rr5mGjejsmmeRO4PPbfBPf0WDMH0AeER576 DIRydpjFNo2KdIlCL5fWzLXYZACzV/Ep9P14Ioy9oPtWAGp6OnWaGiHe2lVrYzlyjApL cFGIaMsEYOmTV391vuiJBNbqy9E72J/7q70tTVQTp0ZY/dDYS41aD0kKlLNuKTasPh08 rdJjK37QzfetrRbL9ZLg4vSL4A1GwYwyea/JAzYbxsbGn93wBktQy9jwIYuatL1La9YX dE7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7fd//MdsUnuf1kx0gSh/g4qsh6yU8kXSazoNNEO7Dy0=; b=k5Lo9M0B4TFKp+G+i70m4L0NFD9b03SPRfEaDUkDGmK9XiGaxwWxPWCEiAHjQ+yOMu TO56kXwEBcIFsVaK2+hIlJ5uoIo0YF1wJ9FJkiWhxlCBtUQyy5AQX7W3UV7r75QODe2g X5CwtepjI6epGMAZ/3iP8sbTUVJ/HgJCfe4ARYcGKgqjb5tLMDU5hx4HXnKsAid8GsDo 765Jb9JplhKFgrKFEQfMrlMgPuq3jybb4s1j1Q88lpM0j6A0+/FNfLgID/OJq7f7Gh96 Yb3JFtOXmUwdN71NKEzJIzrsmoYnH6HEuVB++urxxkS73P0aZnZgHHirgGo7Onx4rU9c 49dQ== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o9si2185912pgv.25.2019.04.18.09.50.11; Thu, 18 Apr 2019 09:50:27 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389442AbfDRQs1 (ORCPT + 99 others); Thu, 18 Apr 2019 12:48:27 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:38663 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387519AbfDRQs0 (ORCPT ); Thu, 18 Apr 2019 12:48:26 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0TPeyfr1_1555606089; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TPeyfr1_1555606089) by smtp.aliyun-inc.com(127.0.0.1); Fri, 19 Apr 2019 00:48:12 +0800 Subject: Re: [PATCH] mm: use mm.arg_lock in get_cmdline() To: Laurent Dufour , Michal Hocko Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Koutny References: <20190418125827.57479-1-ldufour@linux.ibm.com> <20190418130310.GJ6567@dhcp22.suse.cz> <749b8c73-a97d-b568-c0e5-a7bda77090c9@linux.ibm.com> From: Yang Shi Message-ID: Date: Thu, 18 Apr 2019 09:48:09 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <749b8c73-a97d-b568-c0e5-a7bda77090c9@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/18/19 6:05 AM, Laurent Dufour wrote: > Le 18/04/2019 à 15:03, Michal Hocko a écrit : >> Michal has posted the same patch few days ago >> http://lkml.kernel.org/r/20190417120347.15397-1-mkoutny@suse.com > > Oups, sorry for the noise, I missed it. Yes, Michal already posted a similar patch. Anyway, thanks for catching this. > >> 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 >>