Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759606Ab0LNQo3 (ORCPT ); Tue, 14 Dec 2010 11:44:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54180 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759594Ab0LNQo2 (ORCPT ); Tue, 14 Dec 2010 11:44:28 -0500 Date: Tue, 14 Dec 2010 17:37:19 +0100 From: Oleg Nesterov To: "Suzuki K. Poulose" Cc: linux-kernel@vger.kernel.org, Jeremy Fitzhardinge , Christoph Hellwig , Masami Hiramatsu , Ananth N Mavinakayanahalli , Daisuke HATAYAMA , Andi Kleen , Roland McGrath , Amerigo Wang , Linus Torvalds , KAMEZAWA Hiroyuki , KOSAKI Motohiro , Andrew Morton Subject: Re: [Patch 15/21] Collect ELF Core notes data Message-ID: <20101214163719.GH11400@redhat.com> References: <20101214152259.67896960@suzukikp> <20101214154733.495bd2e7@suzukikp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101214154733.495bd2e7@suzukikp> 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 Content-Length: 1123 Lines: 35 On 12/14, Suzuki K. Poulose wrote: > > @@ -164,10 +197,28 @@ static int open_gencore(struct inode *in > list_add(&cp->list, &core_list); > mutex_unlock(&core_mutex); > > + max_regset = get_max_regsets(task); > + > + for (i = 0; i < get_nr_threads(task); i++) { > + tinfo = kzalloc(offsetof(struct elf_thread_core_info, > + notes[max_regset]), GFP_KERNEL); > + if (unlikely(!tinfo)) { > + cleanup_cp(cp); > + ret = -ENOMEM; > + goto out; > + } > + tinfo->next = cp->tinfo; > + cp->tinfo = tinfo; > + } This looks strange... Obviously we can't trust get_nr_threads() before this process is stopped/frozen. Just noticed... release_gencore() does thaw_process() for each thread. But, again, if it was stopped we can race with SIGCONT and exit. IOW, -EIO is possible. Who will thaw other threads? Also, we can probably race with exec, but I am not sure. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/