Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755998AbdLVBb5 (ORCPT ); Thu, 21 Dec 2017 20:31:57 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:33615 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbdLVBbz (ORCPT ); Thu, 21 Dec 2017 20:31:55 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Dave Jones Cc: Alexey Dobriyan , Linus Torvalds , Al Viro , Linux Kernel , syzkaller-bugs@googlegroups.com, Gargi Sharma , Oleg Nesterov , Rik van Riel , Andrew Morton References: <20171219033926.GA26981@codemonkey.org.uk> <87lghy7eul.fsf@xmission.com> <20171219193020.GA9237@codemonkey.org.uk> <878tdy5r5t.fsf@xmission.com> <87mv2e17vz.fsf@xmission.com> <20171220052803.GA17079@codemonkey.org.uk> <871sjp1cjz.fsf@xmission.com> <20171221031606.GA4636@codemonkey.org.uk> <87po78trjm.fsf@xmission.com> <20171221220044.GA4977@codemonkey.org.uk> Date: Thu, 21 Dec 2017 19:31:26 -0600 In-Reply-To: <20171221220044.GA4977@codemonkey.org.uk> (Dave Jones's message of "Thu, 21 Dec 2017 17:00:44 -0500") Message-ID: <87wp1fk0pd.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1eSCBk-0006Tu-M0;;;mid=<87wp1fk0pd.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.133.177;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX182LSQTzGZvd1alMoyT3/dy+a4l861QQ7A= X-SA-Exim-Connect-IP: 67.3.133.177 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa08 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Dave Jones X-Spam-Relay-Country: X-Spam-Timing: total 1365 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 6 (0.4%), b_tie_ro: 4.4 (0.3%), parse: 1.15 (0.1%), extract_message_metadata: 11 (0.8%), get_uri_detail_list: 1.88 (0.1%), tests_pri_-1000: 4.1 (0.3%), tests_pri_-950: 0.97 (0.1%), tests_pri_-900: 0.83 (0.1%), tests_pri_-400: 21 (1.5%), check_bayes: 20 (1.5%), b_tokenize: 5 (0.4%), b_tok_get_all: 8 (0.6%), b_comp_prob: 1.54 (0.1%), b_tok_touch_all: 3.4 (0.3%), b_finish: 0.75 (0.1%), tests_pri_0: 1309 (95.9%), check_dkim_signature: 0.43 (0.0%), check_dkim_adsp: 4.1 (0.3%), tests_pri_500: 8 (0.6%), poll_dns_idle: 1.77 (0.1%), rewrite_mail: 0.00 (0.0%) Subject: Re: proc_flush_task oops X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2079 Lines: 59 Dave Jones writes: > On Thu, Dec 21, 2017 at 12:38:12PM +0200, Alexey Dobriyan wrote: > > > > with proc_mnt still set to NULL is a mystery to me. > > > > > > Is there any chance the idr code doesn't always return the lowest valid > > > free number? So init gets assigned something other than 1? > > > > Well, this theory is easy to test (attached). > > I didn't hit this BUG, but I hit the same oops in proc_flush_task. Scratch one idea. If it isn't too much trouble can you try this. I am wondering if somehow the proc_mnt that is NULL is somewhere in the middle of the stack of pid namespaces. This adds two warnings. The first just reports which pid namespace in the stack of pid namespaces is problematic, and the pid number in that pid namespace. Which should give a whole lot more to go by. The second warning complains if we manage to create a pid namespace where the parent pid namespace is not properly set up. The test to prevent that looks quite robust, but at this point I don't know where to look. Thank you very much, Eric diff --git a/kernel/pid.c b/kernel/pid.c index b13b624e2c49..a1e8734afbba 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -210,6 +210,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) goto out_unlock; for ( ; upid >= pid->numbers; --upid) { /* Make the PID visible to find_pid_ns. */ + WARN(!upid->ns->proc_mnt, "%ld/%d: %d no proc_mnt", (upid - pid->numbers), pid->level, upid->nr); idr_replace(&upid->ns->idr, pid, upid->nr); upid->ns->pid_allocated++; } diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 0b53eef7d34b..8f4c02c7223a 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -136,6 +136,8 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns ns->pid_allocated = PIDNS_ADDING; INIT_WORK(&ns->proc_work, proc_cleanup_work); + WARN_ON(!parent_pid_ns->proc_mnt); + return ns; out_free_idr: