A while ago, I used to use the grsecurity kernel patches, which had an option to hide process arguments from other non-root users. Basically this just made /proc/*/cmdline
be mode 0600, and ps
handles that properly by showing that the process exists but not its arguments.
This is kind of nice if someone on a multiuser machine is running say vi christmas-presents.txt
, to use the canonical example.
Is there any supported way to do this in Ubuntu, other than by installing a new kernel?
(I'm familiar with the technique that lets individual programs alter their argv, but most programs don't do that and anyhow it is racy. This stackoverflow user seems to be asking the same question, but actually just seems very confused.)
The only way to do this currently is to put each user in a separate container (see clone with
CLONE_NEWPID
andCLONE_NEWNS
), and mounting a new/proc
in the container. (lxc will do some of this for you.)However, there are plans to be porting grsecurity features to the Ubuntu and upstream kernels. If you can, please sign up for something and help out.
Up to and including Natty it is not possible to change the permissions on the
/proc/$pid/cmdline
files with the stock kernel, the permissions bits are built into the kernel. Currently you would have to build a bespoke kernel with those patches applied.If the patches are simple to enable this functionality then it may be worth posting them to the Ubuntu Kernel Team list ([email protected]) and we can consider them for inclusion in future releases.
There is now a
hidepid
mount option forprocfs
that lets you hide arguments from other users, and optionally allow one group to see all processes:Years ago I published the following two kernel patches:
Those two patches still work for the current stable vanilla kernel from kernel.org. If you're interested I can post the current patch. Don't ask me why never anybody included a process hiding option in the upstream kernel.
Warning: These patches completely hide processes of other users except for root.
You could stop them from accessing system monitor and top, by changing their permissions in the users and groups settings. I'm not certain this will be a complete solution but it should be sufficient to block this from most common users.