All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org,
	Greg KH <gregkh@suse.de>
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	Eugene Teo <eteo@redhat.com>,
	Marcel Holtmann <marcel@holtmann.org>
Subject: [patch 02/23] Dont allow chmod() on the /proc/<pid>/ files
Date: Thu, 3 Aug 2006 22:38:30 -0700	[thread overview]
Message-ID: <20060804053830.GC769@kroah.com> (raw)
In-Reply-To: <20060804053807.GA769@kroah.com>

[-- Attachment #1: don-t-allow-chmod-on-the-proc-pid-files.patch --]
[-- Type: text/plain, Size: 3794 bytes --]

-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Marcel Holtmann <marcel@holtmann.org>

Don't allow chmod() on the /proc/<pid>/ files

This just turns off chmod() on the /proc/<pid>/ files, since there is no
good reason to allow it, and had we disallowed it originally, the nasty
/proc race exploit wouldn't have been possible.

The other patches already fixed the problem chmod() could cause, so this
is really just some final mop-up..

This particular version is based off a patch by Eugene and Marcel which
had much better naming than my original equivalent one.

Signed-off-by: Eugene Teo <eteo@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 fs/proc/base.c |   33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

--- linux-2.6.17.7.orig/fs/proc/base.c
+++ linux-2.6.17.7/fs/proc/base.c
@@ -596,6 +596,27 @@ static int proc_permission(struct inode 
 	return proc_check_root(inode);
 }
 
+static int proc_setattr(struct dentry *dentry, struct iattr *attr)
+{
+	int error;
+	struct inode *inode = dentry->d_inode;
+
+	if (attr->ia_valid & ATTR_MODE)
+		return -EPERM;
+
+	error = inode_change_ok(inode, attr);
+	if (!error) {
+		error = security_inode_setattr(dentry, attr);
+		if (!error)
+			error = inode_setattr(inode, attr);
+	}
+	return error;
+}
+
+static struct inode_operations proc_def_inode_operations = {
+	.setattr	= proc_setattr,
+};
+
 static int proc_task_permission(struct inode *inode, int mask, struct nameidata *nd)
 {
 	struct dentry *root;
@@ -987,6 +1008,7 @@ static struct file_operations proc_oom_a
 
 static struct inode_operations proc_mem_inode_operations = {
 	.permission	= proc_permission,
+	.setattr	= proc_setattr,
 };
 
 #ifdef CONFIG_AUDITSYSCALL
@@ -1184,7 +1206,8 @@ out:
 
 static struct inode_operations proc_pid_link_inode_operations = {
 	.readlink	= proc_pid_readlink,
-	.follow_link	= proc_pid_follow_link
+	.follow_link	= proc_pid_follow_link,
+	.setattr	= proc_setattr,
 };
 
 #define NUMBUF 10
@@ -1356,6 +1379,7 @@ static struct inode *proc_pid_make_inode
 	ei->task = NULL;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 	inode->i_ino = fake_ino(task->pid, ino);
+	inode->i_op = &proc_def_inode_operations;
 
 	if (!pid_alive(task))
 		goto out_unlock;
@@ -1579,11 +1603,13 @@ static struct file_operations proc_task_
 static struct inode_operations proc_fd_inode_operations = {
 	.lookup		= proc_lookupfd,
 	.permission	= proc_permission,
+	.setattr	= proc_setattr,
 };
 
 static struct inode_operations proc_task_inode_operations = {
 	.lookup		= proc_task_lookup,
 	.permission	= proc_task_permission,
+	.setattr	= proc_setattr,
 };
 
 #ifdef CONFIG_SECURITY
@@ -1873,10 +1899,12 @@ static struct file_operations proc_tid_b
 
 static struct inode_operations proc_tgid_base_inode_operations = {
 	.lookup		= proc_tgid_base_lookup,
+	.setattr	= proc_setattr,
 };
 
 static struct inode_operations proc_tid_base_inode_operations = {
 	.lookup		= proc_tid_base_lookup,
+	.setattr	= proc_setattr,
 };
 
 #ifdef CONFIG_SECURITY
@@ -1918,10 +1946,12 @@ static struct dentry *proc_tid_attr_look
 
 static struct inode_operations proc_tgid_attr_inode_operations = {
 	.lookup		= proc_tgid_attr_lookup,
+	.setattr	= proc_setattr,
 };
 
 static struct inode_operations proc_tid_attr_inode_operations = {
 	.lookup		= proc_tid_attr_lookup,
+	.setattr	= proc_setattr,
 };
 #endif
 
@@ -1946,6 +1976,7 @@ static void *proc_self_follow_link(struc
 static struct inode_operations proc_self_inode_operations = {
 	.readlink	= proc_self_readlink,
 	.follow_link	= proc_self_follow_link,
+	.setattr	= proc_setattr,
 };
 
 /**

--

  parent reply	other threads:[~2006-08-04  5:43 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060804053258.391158155@quad.kroah.org>
2006-08-04  5:38 ` [patch 00/23] -stable review Greg KH
2006-08-04  5:38   ` [patch 01/23] PCI: fix issues with extended conf space when MMCONFIG disabled because of e820 Greg KH
2006-08-04  5:38   ` Greg KH [this message]
2006-08-04  5:38   ` [patch 03/23] : H.323 helper: fix possible NULL-ptr dereference Greg KH
2006-08-04  5:38   ` [patch 04/23] scx200_acb: Fix the state machine Greg KH
2006-08-04  5:38   ` [patch 05/23] scx200_acb: Fix the block transactions Greg KH
2006-08-04  5:38   ` [patch 06/23] i2c: Fix ignore module parameter handling in i2c-core Greg KH
2006-08-04  5:39   ` [patch 07/23] sky2: NAPI bug Greg KH
2006-08-04  5:39   ` [patch 08/23] UHCI: Fix handling of short last packet Greg KH
2006-08-04  5:39   ` [patch 09/23] : Update frag_list in pskb_trim Greg KH
2006-08-04  5:39   ` [patch 10/23] VLAN state handling fix Greg KH
2006-08-04  5:39   ` [patch 11/23] Sparc64 quad-float emulation fix Greg KH
2006-08-04  5:39   ` [patch 12/23] invalidate_bdev() speedup Greg KH
2006-08-04  8:50     ` Christoph Hellwig
2006-08-04  9:04       ` Andrew Morton
2006-08-04 13:08         ` Arjan van de Ven
2006-08-04 13:25           ` Jes Sorensen
2006-08-04 15:18           ` Andrew Morton
2006-08-04  5:39   ` [patch 13/23] ieee1394: sbp2: enable auto spin-up for Maxtor disks Greg KH
2006-08-04  5:39   ` [patch 14/23] Fix race related problem when adding items to and svcrpc auth cache Greg KH
2006-08-04  5:39     ` Greg KH
2006-08-04  5:40   ` [patch 15/23] ext3 -nobh option causes oops Greg KH
2006-11-16 22:51     ` Adrian Bunk
2006-11-16 23:07       ` Badari Pulavarty
2006-11-17 16:47         ` Adrian Bunk
2006-08-04  5:40   ` [patch 16/23] ext3: avoid triggering ext3_error on bad NFS file handle Greg KH
2006-08-04 14:45     ` Eric Sandeen
2006-08-04 14:52       ` Christoph Hellwig
2006-08-04 15:35         ` Eric Sandeen
2006-08-05  1:28           ` Theodore Tso
2006-08-10  5:38           ` [stable] " Greg KH
2006-08-04  5:40   ` [patch 17/23] e1000: add forgotten PCI ID for supported device Greg KH
2006-08-04  5:40   ` [patch 18/23] cond_resched() fix Greg KH
2006-08-04  5:40   ` [patch 19/23] Fix budget-av compile failure Greg KH
2006-08-04  5:40   ` [patch 20/23] S390: fix futex_atomic_cmpxchg_inatomic Greg KH
2006-08-07  8:39     ` Martin Schwidefsky
2006-08-04  5:40   ` [patch 21/23] tty serialize flush_to_ldisc Greg KH
2006-08-04  5:40   ` [patch 22/23] Add stable branch to maintainers file Greg KH
2006-08-04  5:41   ` [patch 23/23] Have ext2 reject file handles with bad inode numbers early Greg KH
2006-08-04  7:18   ` [patch 00/23] -stable review Grant Coady
2006-08-04  7:20     ` Greg KH
2006-08-04  9:04   ` Jesper Juhl
2006-08-04  9:10     ` Patrick McHardy
2006-08-04  9:19       ` Jesper Juhl
2006-08-04  9:24         ` Patrick McHardy
2006-08-04  9:31           ` Jesper Juhl
2006-08-04  9:19     ` Andrew Morton
2006-08-04  9:22       ` Jesper Juhl
2006-08-04 13:50         ` Auke Kok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060804053830.GC769@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=eteo@redhat.com \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.