From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755568Ab3LUS0R (ORCPT ); Sat, 21 Dec 2013 13:26:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14020 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754507Ab3LUS0Q (ORCPT ); Sat, 21 Dec 2013 13:26:16 -0500 Date: Sat, 21 Dec 2013 19:27:04 +0100 From: Oleg Nesterov To: Linus Torvalds Cc: naveen yadav , Vaibhav Shinde , Ajeet Yadav , Tejun Heo , Andrew Morton , Linux Kernel Mailing List Subject: Re: [PATCH] secure unlock_task_sighand() call Message-ID: <20131221182703.GA11516@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/21, Linus Torvalds wrote: > > We have coredump serialization in exit_mm() that I think *should* make > this all ok - if we still see p->mm matching our mm, Yes. And the comment says: lock_task_sighand(p) must be used. Since p->mm != NULL and we hold ->mmap_sem it can't fail. IOW, this task can't pass exit_mm() and thus lock_task_sighand() can't fail. > > do { > > if (p->mm) { > > if (unlikely(p->mm == mm)) { > > - lock_task_sighand(p, &flags); > > - nr += zap_process(p, exit_code); > > - unlock_task_sighand(p, &flags); > > + if (lock_task_sighand(p, &flags) { > > + nr += zap_process(p, exit_code); > > + unlock_task_sighand(p, &flags); > > + } I too do not think this is needed. But perhaps BUG_ON() make sense. Note: just in case, this has another problem: while_each_thread() is racy. We already have the initial fixes in -mm, this code (as other users) should be converted to use for_each_thread(), I'll send the patch(es). Oleg.