Re: > [PATCH] Security: Handle hidepid option correctly

From: çæ
Date: Sun Dec 16 2018 - 23:22:07 EST


Actually I'm pretty sure kernel calls proc_mount()
Here is the call stack
[ 0.003450] [<ffffff8bef2a0190>] proc_mount+0x2c/0x98
[ 0.003459] [<ffffff8bef22e560>] mount_fs+0x164/0x190
[ 0.003465] [<ffffff8bef24c138>] vfs_kern_mount+0x74/0x168
[ 0.003469] [<ffffff8bef24c244>] kern_mount_data+0x18/0x30
[ 0.003474] [<ffffff8bef2a0258>] pid_ns_prepare_proc+0x24/0x40
[ 0.003484] [<ffffff8bef0cd5ec>] alloc_pid+0x498/0x4b4
[ 0.003492] [<ffffff8bef0a9b94>] copy_process.isra.73.part.74+0xed0/0x1708
[ 0.003496] [<ffffff8bef0aa560>] _do_fork+0xdc/0x3f8
[ 0.003501] [<ffffff8bef0aa8c8>] kernel_thread+0x34/0x3c
[ 0.003511] [<ffffff8bf00cd498>] rest_init+0x20/0x80
[ 0.003522] [<ffffff8bf0c00c7c>] start_kernel+0x3e4/0x43c
[ 0.003527] [<ffffff8bf0c001e8>] __primary_switched+0x64/0x90
Alexey Dobriyan <adobriyan@xxxxxxxxx> ä2018å12æ14æåä äå11:44åéï
>
> On Wed, Dec 05, 2018 at 03:26:04PM +0800, çæ wrote:
> > Anyone who can review my patch?
> >
> > çæ <chengyang@xxxxxxxxxx> ä2018å11æ30æåä äå10:34åéï
> > >
> > > Here is an article illustrates the details.
> > > https://medium.com/@topjohnwu/from-anime-game-to-android-system-security-vulnerability-9b955a182f20
> > >
> > > And There is a similar fix on kernel-4.4:
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=99663be772c827b8f5f594fe87eb4807be1994e5
> > >
> > > Q: Other filesystems parse the options from fill_super(). Is proc special in some fashion?
> > > A: According to my research, start_kernel will call proc_mount first, and initialize sb->s_root before any userspace process runs. If others want to mount it, all options will be ignored.
> > > AOSP change here: https://android-review.googlesource.com/c/platform/system/core/+/181345/4/init/init.cpp
> > > At first I though we should mount it with MS_REMOUNT flag. But kernel will crash if we did this.
>
> This is not true: /proc is mounted by userspace (and it is easy to see
> from the fact that proc_mount() is not called from kernel anywhere).
>
> hidepid= in its current form is misdesigned, so might as well not bother
> changing anything. IIRC there were(?) patches to make it per-mount.