From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752780AbdATP43 (ORCPT ); Fri, 20 Jan 2017 10:56:29 -0500 Received: from mail-vk0-f65.google.com ([209.85.213.65]:34323 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752193AbdATP41 (ORCPT ); Fri, 20 Jan 2017 10:56:27 -0500 MIME-Version: 1.0 In-Reply-To: References: <1484572984-13388-1-git-send-email-djalal@gmail.com> <1484572984-13388-3-git-send-email-djalal@gmail.com> From: Lafcadio Wluiki Date: Fri, 20 Jan 2017 16:56:24 +0100 Message-ID: Subject: Re: [PATCH v4 2/2] procfs/tasks: add a simple per-task procfs hidepid= field To: Andy Lutomirski Cc: Djalal Harouni , Linux API , "kernel-hardening@lists.openwall.com" , "linux-kernel@vger.kernel.org" , Andrew Morton , Kees Cook Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 19, 2017 at 8:52 PM, Andy Lutomirski wrote: >> Sure, the hidepid mount option is old enough, and this per-task >> hidepid is clearly defined only for procfs and per task, we can't add >> another switch that's relate to both a filesystem and pid namespaces, >> it will be a bit complicated and not really useful for cases that are >> in *same* pidns where *each* one have to mount its procfs, it will >> propagate. Also as noted by Lafcadio, the gid thing is a bit hard to >> use now. > > What I'm trying to say is that I want to understand a complete, > real-world use case. Adding a security-related per-task flag is can > be quite messy and requires a lot of careful thought to get right, and > I'd rather avoid it if at all possible. > > I'm imaging something like a new RestrictPidVisisbility= option in > systemd. I agree that this is currently a mess to do. But maybe a It's not just a "mess" to do, it's not possible afaics. The hidepid thing is after all not really a mount option, but an option of the pid namespace. Hence, if you want to restrict the visibility for one service only, then you have to get your own PID namespace, but that does a lot more than just hide visibility: it renumbers everything after all... > simpler solution would be to add a new mount option local_hidepid to > procfs. If you set that option, then it overrides hidepid for that > instance. Most of these semi-sandboxed daemon processes already have > their own mount namespace, so the overhead should be minimal. When I worked on the patches originally, I actually wanted to implement this as true per-superblock procfs mount option. But this is really hard to do, as the private superblock pointer of the procfs instance currently points to the pid namespace, and breaking that up, so that you can have multiple procfs superblocks per pid namespace is a ton of work, and I doubt anyone would really like the complexity this brings, just for adding a single 2bit option... The per-process option is much simpler code-wise. It also has semantical benefits: if the thing isn't a mount option it is accessible with absolutely minimal privileges, as it does not imply namespaces and mounting. This means, my Firefox can run with hidepid turned on without my KDE Konsole instance also having to turn it on. Or to say this differently: your suggested RestrictPidVisibility= works nicely both for "systemd" as PID 1 and for "systemd --user" as user "lafcadio", when it is per-process, but is much more complex to implement if it was a true mount option. L.