• R/O
  • HTTP
  • SSH
  • HTTPS

linux-2.4.36: Commit

2.4.36-stable kernel tree


Commit MetaInfo

Revisionf654703d45148071037e8b904e7a674c6d78466a (tree)
Time2008-02-04 00:37:46
Authordann frazier <dannf@dann...>
CommiterWilly Tarreau

Log Message

2.4: fix memory corruption from misinterpreted bad_inode_ops return values

This is a 2.4 backport of a linux-2.6 change by Eric Sandeen
(commit be6aab0e9fa6d3c6d75aa1e38ac972d8b4ee82b8)

CVE-2006-5753 was assigned for this issue.

I've built and boot-tested this, but I'm not sure how to exercise
these codepaths.

Commit log from 2.6 follows.

CVE-2006-5753 is for a case where an inode can be marked bad, switching
the ops to bad_inode_ops, which are all connected as:
static int return_EIO(void)
{
return -EIO;
}
#define EIO_ERROR ((void *) (return_EIO))
static struct inode_operations bad_inode_ops =
{
.create = bad_inode_create
...etc...
The problem here is that the void cast causes return types to not be
promoted, and for ops such as listxattr which expect more than 32 bits of
return value, the 32-bit -EIO is interpreted as a large positive 64-bit
number, i.e. 0x00000000fffffffa instead of 0xfffffffa.
This goes particularly badly when the return value is taken as a number of
bytes to copy into, say, a user's buffer for example...
I originally had coded up the fix by creating a return_EIO_<TYPE> macro
for each return type, like this:
static int return_EIO_int(void)
{
return -EIO;
}
#define EIO_ERROR_INT ((void *) (return_EIO_int))
static struct inode_operations bad_inode_ops =
{
.create = EIO_ERROR_INT,
...etc...
but Al felt that it was probably better to create an EIO-returner for each
actual op signature. Since so few ops share a signature, I just went ahead
& created an EIO function for each individual file & inode op that returns
a value.

Signed-off-by: dann frazier <dannf@hp.com>

Change Summary

Incremental Difference

--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -9,6 +9,76 @@
99 #include <linux/fs.h>
1010 #include <linux/stat.h>
1111 #include <linux/sched.h>
12+#include <linux/poll.h>
13+
14+static loff_t bad_file_llseek(struct file *file, loff_t offset, int origin)
15+{
16+ return -EIO;
17+}
18+
19+static ssize_t bad_file_read(struct file *filp, char __user *buf,
20+ size_t size, loff_t *ppos)
21+{
22+ return -EIO;
23+}
24+
25+static ssize_t bad_file_write(struct file *filp, const char __user *buf,
26+ size_t siz, loff_t *ppos)
27+{
28+ return -EIO;
29+}
30+
31+static int bad_file_readdir(struct file *filp, void *dirent, filldir_t filldir)
32+{
33+ return -EIO;
34+}
35+
36+static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
37+{
38+ return POLLERR;
39+}
40+
41+static int bad_file_ioctl (struct inode *inode, struct file *filp,
42+ unsigned int cmd, unsigned long arg)
43+{
44+ return -EIO;
45+}
46+
47+static int bad_file_mmap(struct file *file, struct vm_area_struct *vma)
48+{
49+ return -EIO;
50+}
51+
52+static int bad_file_open(struct inode *inode, struct file *filp)
53+{
54+ return -EIO;
55+}
56+
57+static int bad_file_flush(struct file *file)
58+{
59+ return -EIO;
60+}
61+
62+static int bad_file_release(struct inode *inode, struct file *filp)
63+{
64+ return -EIO;
65+}
66+
67+static int bad_file_fsync(struct file *file, struct dentry *dentry,
68+ int datasync)
69+{
70+ return -EIO;
71+}
72+
73+static int bad_file_fasync(int fd, struct file *filp, int on)
74+{
75+ return -EIO;
76+}
77+
78+static int bad_file_lock(struct file *file, int cmd, struct file_lock *fl)
79+{
80+ return -EIO;
81+}
1282
1383 /*
1484 * The follow_link operation is special: it must behave as a no-op
@@ -20,46 +90,107 @@ static int bad_follow_link(struct dentry *dent, struct nameidata *nd)
2090 return vfs_follow_link(nd, ERR_PTR(-EIO));
2191 }
2292
23-static int return_EIO(void)
93+static struct file_operations bad_file_ops =
94+{
95+ llseek: bad_file_llseek,
96+ read: bad_file_read,
97+ write: bad_file_write,
98+ readdir: bad_file_readdir,
99+ poll: bad_file_poll,
100+ ioctl: bad_file_ioctl,
101+ mmap: bad_file_mmap,
102+ open: bad_file_open,
103+ flush: bad_file_flush,
104+ release: bad_file_release,
105+ fsync: bad_file_fsync,
106+ fasync: bad_file_fasync,
107+ lock: bad_file_lock,
108+};
109+
110+static int bad_inode_create (struct inode *dir, struct dentry *dentry,
111+ int mode)
24112 {
25113 return -EIO;
26114 }
115+
116+static struct dentry *bad_inode_lookup(struct inode *dir,
117+ struct dentry *dentry)
118+{
119+ return ERR_PTR(-EIO);
120+}
27121
28-#define EIO_ERROR ((void *) (return_EIO))
122+static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
123+ struct dentry *dentry)
124+{
125+ return -EIO;
126+}
29127
30-static struct file_operations bad_file_ops =
128+static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
31129 {
32- llseek: EIO_ERROR,
33- read: EIO_ERROR,
34- write: EIO_ERROR,
35- readdir: EIO_ERROR,
36- poll: EIO_ERROR,
37- ioctl: EIO_ERROR,
38- mmap: EIO_ERROR,
39- open: EIO_ERROR,
40- flush: EIO_ERROR,
41- release: EIO_ERROR,
42- fsync: EIO_ERROR,
43- fasync: EIO_ERROR,
44- lock: EIO_ERROR,
45-};
130+ return -EIO;
131+}
132+
133+static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
134+ const char *symname)
135+{
136+ return -EIO;
137+}
138+
139+static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
140+ int mode)
141+{
142+ return -EIO;
143+}
144+
145+static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
146+{
147+ return -EIO;
148+}
149+
150+static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
151+ int mode, int rdev)
152+{
153+ return -EIO;
154+}
155+
156+static int bad_inode_rename (struct inode *old_dir, struct dentry *old_dentry,
157+ struct inode *new_dir, struct dentry *new_dentry)
158+{
159+ return -EIO;
160+}
161+
162+static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
163+ int buflen)
164+{
165+ return -EIO;
166+}
167+
168+static int bad_inode_permission(struct inode *inode, int mask)
169+{
170+ return -EIO;
171+}
172+
173+static int bad_inode_revalidate(struct dentry *dentry)
174+{
175+ return -EIO;
176+}
46177
47178 struct inode_operations bad_inode_ops =
48179 {
49- create: EIO_ERROR,
50- lookup: EIO_ERROR,
51- link: EIO_ERROR,
52- unlink: EIO_ERROR,
53- symlink: EIO_ERROR,
54- mkdir: EIO_ERROR,
55- rmdir: EIO_ERROR,
56- mknod: EIO_ERROR,
57- rename: EIO_ERROR,
58- readlink: EIO_ERROR,
180+ create: bad_inode_create,
181+ lookup: bad_inode_lookup,
182+ link: bad_inode_link,
183+ unlink: bad_inode_unlink,
184+ symlink: bad_inode_symlink,
185+ mkdir: bad_inode_mkdir,
186+ rmdir: bad_inode_rmdir,
187+ mknod: bad_inode_mknod,
188+ rename: bad_inode_rename,
189+ readlink: bad_inode_readlink,
59190 follow_link: bad_follow_link,
60- truncate: EIO_ERROR,
61- permission: EIO_ERROR,
62- revalidate: EIO_ERROR,
191+ /* truncate returns void */
192+ permission: bad_inode_permission,
193+ revalidate: bad_inode_revalidate,
63194 };
64195
65196
Show on old repository browser