diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-12-30 11:39:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-12-30 11:39:10 -0500 |
commit | 8b90db0df7187a01fb7177f1f812123138f562cf (patch) | |
tree | 8d7029403cc50d822bc22085202bfdbf6110203b /fs/proc | |
parent | 40c37213a081990b1d3778f57630f97df75a7ec1 (diff) |
Insanity avoidance in /proc
The old /proc interfaces were never updated to use loff_t, and are just
generally broken. Now, we should be using the seq_file interface for
all of the proc files, but converting the legacy functions is more work
than most people care for and has little upside..
But at least we can make the non-LFS rules explicit, rather than just
insanely wrapping the offset or something.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/generic.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index b638fb500743..72b431d0a0a4 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -54,6 +54,18 @@ proc_file_read(struct file *file, char __user *buf, size_t nbytes, | |||
54 | ssize_t n, count; | 54 | ssize_t n, count; |
55 | char *start; | 55 | char *start; |
56 | struct proc_dir_entry * dp; | 56 | struct proc_dir_entry * dp; |
57 | unsigned long long pos; | ||
58 | |||
59 | /* | ||
60 | * Gaah, please just use "seq_file" instead. The legacy /proc | ||
61 | * interfaces cut loff_t down to off_t for reads, and ignore | ||
62 | * the offset entirely for writes.. | ||
63 | */ | ||
64 | pos = *ppos; | ||
65 | if (pos > MAX_NON_LFS) | ||
66 | return 0; | ||
67 | if (nbytes > MAX_NON_LFS - pos) | ||
68 | nbytes = MAX_NON_LFS - pos; | ||
57 | 69 | ||
58 | dp = PDE(inode); | 70 | dp = PDE(inode); |
59 | if (!(page = (char*) __get_free_page(GFP_KERNEL))) | 71 | if (!(page = (char*) __get_free_page(GFP_KERNEL))) |
@@ -202,30 +214,17 @@ proc_file_write(struct file *file, const char __user *buffer, | |||
202 | static loff_t | 214 | static loff_t |
203 | proc_file_lseek(struct file *file, loff_t offset, int orig) | 215 | proc_file_lseek(struct file *file, loff_t offset, int orig) |
204 | { | 216 | { |
205 | lock_kernel(); | 217 | loff_t retval = -EINVAL; |
206 | 218 | switch (orig) { | |
207 | switch (orig) { | 219 | case 1: |
208 | case 0: | 220 | offset += file->f_pos; |
209 | if (offset < 0) | 221 | /* fallthrough */ |
210 | goto out; | 222 | case 0: |
211 | file->f_pos = offset; | 223 | if (offset < 0 || offset > MAX_NON_LFS) |
212 | unlock_kernel(); | 224 | break; |
213 | return(file->f_pos); | 225 | file->f_pos = retval = offset; |
214 | case 1: | 226 | } |
215 | if (offset + file->f_pos < 0) | 227 | return retval; |
216 | goto out; | ||
217 | file->f_pos += offset; | ||
218 | unlock_kernel(); | ||
219 | return(file->f_pos); | ||
220 | case 2: | ||
221 | goto out; | ||
222 | default: | ||
223 | goto out; | ||
224 | } | ||
225 | |||
226 | out: | ||
227 | unlock_kernel(); | ||
228 | return -EINVAL; | ||
229 | } | 228 | } |
230 | 229 | ||
231 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) | 230 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) |