lkml.org 
[lkml]   [1999]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectSecure /proc permissions
I made a patch for the 2.2.7 kernel which sets the permissions for the
/proc/<pid> and files inside so users can read information about only
their processes. If someone will try "ps aux" he will see a list composed
only by the processes he owns, and no other.

This option does not affect the root capability of seeing all processes
launched on the system.

The patch allows you to enable or disable the option from the configure
scripts.

I find it very useful and may be it would be good to be included in the
linux source.

If you ask yourself why this option, well, this is the way SunOS behaves.

The /proc filesystem contains sensitive information and I don't think is
normal to be read by any user who wants to.

Victor STANESCU-network administrator
The Numerical Methods Laboratory,
Politehnica University of Bucharest
diff -u -r linux/Documentation/Configure.help linux-2.2.7/Documentation/Configure.help
--- linux/Documentation/Configure.help Wed Apr 21 01:17:20 1999
+++ linux-2.2.7/Documentation/Configure.help Fri May 7 19:48:35 1999
@@ -6976,6 +6976,16 @@
This option will enlarge your kernel by about 18 KB. Several
programs depend on this, so everyone should say Y here.

+Secure /proc filesystem permissions
+CONFIG_PROC_SFS
+ Checking this option will deny users access to other users processes
+ information. When a normal user will try to see all processes using
+ something like 'ps aux', or 'w', or anything else, he will be able
+ to see only the processes he owns. This option does not affect the
+ possibility to see all processes as root.
+ Use it if you are interested in protecting users privacy. It is also
+ a good ideea for security.
+
NFS filesystem support
CONFIG_NFS_FS
If you are connected to some other (usually local) Unix computer
diff -u -r linux/fs/Config.in linux-2.2.7/fs/Config.in
--- linux/fs/Config.in Mon Mar 8 01:25:23 1999
+++ linux-2.2.7/fs/Config.in Fri May 7 13:22:39 1999
@@ -34,6 +34,9 @@
fi
tristate 'OS/2 HPFS filesystem support (read only)' CONFIG_HPFS_FS
bool '/proc filesystem support' CONFIG_PROC_FS
+if [ "$CONFIG_PROC_FS" = "y" ]; then
+ bool ' Secure /proc filesystem permissions' CONFIG_PROC_SFS
+fi
if [ "$CONFIG_UNIX98_PTYS" = "y" ]; then
# It compiles as a module for testing only. It should not be used
# as a module in general. If we make this "tristate", a bunch of people
diff -u -r linux/fs/proc/base.c linux-2.2.7/fs/proc/base.c
--- linux/fs/proc/base.c Mon Aug 24 23:02:43 1998
+++ linux-2.2.7/fs/proc/base.c Fri May 7 19:43:23 1999
@@ -4,6 +4,9 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*
* proc base directory handling functions
+ *
+ * 1999, May 7 Victor STANESCU, <bruno@lmn.pub.ro>
+ * added secure permissions to the proc filesystem.
*/

#include <asm/uaccess.h>
@@ -84,7 +87,11 @@
*/
struct proc_dir_entry proc_pid = {
PROC_PID_INO, 5, "<pid>",
+#ifdef CONFIG_PROC_SFS
+ S_IFDIR | S_IRUSR | S_IXUSR, 2, 0, 0,
+#else
S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
+#endif
0, &proc_base_inode_operations,
NULL, proc_pid_fill_inode,
NULL, &proc_root, NULL
@@ -92,7 +99,11 @@

static struct proc_dir_entry proc_pid_status = {
PROC_PID_STATUS, 6, "status",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_array_inode_operations,
NULL, proc_pid_fill_inode,
};
@@ -134,25 +145,41 @@
};
static struct proc_dir_entry proc_pid_cmdline = {
PROC_PID_CMDLINE, 7, "cmdline",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_array_inode_operations,
NULL, proc_pid_fill_inode,
};
static struct proc_dir_entry proc_pid_stat = {
PROC_PID_STAT, 4, "stat",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_array_inode_operations,
NULL, proc_pid_fill_inode,
};
static struct proc_dir_entry proc_pid_statm = {
PROC_PID_STATM, 5, "statm",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_array_inode_operations,
NULL, proc_pid_fill_inode,
};
static struct proc_dir_entry proc_pid_maps = {
PROC_PID_MAPS, 4, "maps",
+#ifdef CONFIG_PROC_SFS
+ S_IFIFO | S_IRUSR, 1, 0, 0,
+#else
S_IFIFO | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_arraylong_inode_operations,
NULL, proc_pid_fill_inode,
};
@@ -160,7 +187,11 @@
#if CONFIG_AP1000
static struct proc_dir_entry proc_pid_ringbuf = {
PROC_PID_RINGBUF, 7, "ringbuf",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR | S_IWUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO | S_IWUSR, 1, 0, 0,
+#endif
0, &proc_ringbuf_inode_operations,
NULL, proc_pid_fill_inode,
};
@@ -169,7 +200,11 @@
#ifdef __SMP__
static struct proc_dir_entry proc_pid_cpu = {
PROC_PID_CPU, 3, "cpu",
+#ifdef CONFIG_PROC_SFS
+ S_IFREG | S_IRUSR, 1, 0, 0,
+#else
S_IFREG | S_IRUGO, 1, 0, 0,
+#endif
0, &proc_array_inode_operations,
NULL, proc_pid_fill_inode,
};
\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.136 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site