From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752610AbdHGIo5 (ORCPT ); Mon, 7 Aug 2017 04:44:57 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:42797 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752430AbdHGIo4 (ORCPT ); Mon, 7 Aug 2017 04:44:56 -0400 Date: Mon, 7 Aug 2017 10:44:51 +0200 From: Peter Zijlstra To: Aleksa Sarai Cc: Ingo Molnar , "Eric W. Biederman" , cyphar@cyphar.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jess Frazelle Subject: Re: [PATCH v2] sched: debug: use task_pid_nr_ns in /proc/$pid/sched Message-ID: <20170807084451.rdtsjws6hwtdy6ki@hirez.programming.kicks-ass.net> References: <20170806044141.5093-1-asarai@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170806044141.5093-1-asarai@suse.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 06, 2017 at 02:41:41PM +1000, Aleksa Sarai wrote: > It appears as though the addition of the PID namespace did not update > the output code for /proc/*/sched, which resulted in it providing PIDs > that were not self-consistent with the /proc mount. This additionally > made it trivial to detect whether a process was inside &init_pid_ns from > userspace (making container detection trivial[1]). This lead to > situations such as: > > % unshare -pmf > % mount -t proc proc /proc > % head -n1 /proc/1/sched > head (10047, #threads: 1) > > Fix this by just using task_pid_nr_ns for the output of /proc/*/sched. > All of the other uses of task_pid_nr in kernel/sched/debug.c are from a > sysctl context and thus don't need to be namespaced. > > [1]: https://github.com/jessfraz/amicontained > > Cc: > Cc: Jess Frazelle > Signed-off-by: Aleksa Sarai Thanks!