From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by kanga.kvack.org (Postfix) with ESMTP id 2B0066B0253 for ; Wed, 23 Sep 2015 05:13:10 -0400 (EDT) Received: by pacfv12 with SMTP id fv12so35980374pac.2 for ; Wed, 23 Sep 2015 02:13:09 -0700 (PDT) Received: from mail-pa0-x22e.google.com (mail-pa0-x22e.google.com. [2607:f8b0:400e:c03::22e]) by mx.google.com with ESMTPS id mp9si9183702pbc.76.2015.09.23.02.13.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2015 02:13:09 -0700 (PDT) Received: by padhy16 with SMTP id hy16so35587549pad.1 for ; Wed, 23 Sep 2015 02:13:09 -0700 (PDT) Date: Wed, 23 Sep 2015 18:13:54 +0900 From: Sergey Senozhatsky Subject: Re: [patch] mm, oom: remove task_lock protecting comm printing Message-ID: <20150923091354.GA640@swordfish> References: <20150923080632.GD12318@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150923080632.GD12318@esperanza> Sender: owner-linux-mm@kvack.org List-ID: To: Vladimir Davydov Cc: David Rientjes , Andrew Morton , Oleg Nesterov , Michal Hocko , Linus Torvalds , Kyle Walker , Christoph Lameter , Johannes Weiner , linux-mm , Linux Kernel Mailing List , Stanislav Kozina , Tetsuo Handa On (09/23/15 11:06), Vladimir Davydov wrote: > Hi, > > On Tue, Sep 22, 2015 at 04:30:13PM -0700, David Rientjes wrote: > > The oom killer takes task_lock() in a couple of places solely to protect > > printing the task's comm. > > > > A process's comm, including current's comm, may change due to > > /proc/pid/comm or PR_SET_NAME. > > > > The comm will always be NULL-terminated, so the worst race scenario would > > only be during update. We can tolerate a comm being printed that is in > > the middle of an update to avoid taking the lock. > > > > Other locations in the kernel have already dropped task_lock() when > > printing comm, so this is consistent. > > Without the protection, can't reading task->comm race with PR_SET_NAME > as described below? the previous name was already null terminated, so it should be [name\0old_name\0] -ss > > Let T->comm[16] = "name\0rubbish1234" > > CPU1 CPU2 > ---- ---- > set_task_comm(T, "longname\0") > T->comm[0] = 'l' > T->comm[1] = 'o' > T->comm[2] = 'n' > T->comm[3] = 'g' > T->comm[4] = 'n' > printk("%s\n", T->comm) > T->comm = "longnrubbish1234" > OOPS: the string is not > nil-terminated! > T->comm[5] = 'a' > T->comm[6] = 'm' > T->comm[7] = 'e' > T->comm[8] = '\0' -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org