diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2006-04-26 02:28:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-26 10:52:21 -0400 |
commit | 6ad0013b316367671ef316cff91ab2d912e309c9 (patch) | |
tree | ff07d7294b9aa8ff2ae11c91d214f0a424e9b180 | |
parent | de0bb97aff6743f71abb8ec581238e2bdae9cdd1 (diff) |
[PATCH] fix mips sys32_p{read,write}
Switched to use of sys_pread64()/sys_pwrite64() rather than keep duplicating
their guts; among the little things that had been missing there were such as
ret = security_file_permission (file, MAY_READ);
Gotta love the LSM robustness, right?
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/mips/kernel/linux32.c | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 7c953bcc5f6a..a7d2bb3cf835 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
@@ -356,73 +356,13 @@ asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high, | |||
356 | asmlinkage ssize_t sys32_pread(unsigned int fd, char __user * buf, | 356 | asmlinkage ssize_t sys32_pread(unsigned int fd, char __user * buf, |
357 | size_t count, u32 unused, u64 a4, u64 a5) | 357 | size_t count, u32 unused, u64 a4, u64 a5) |
358 | { | 358 | { |
359 | ssize_t ret; | 359 | return sys_pread64(fd, buf, count, merge_64(a4, a5)); |
360 | struct file * file; | ||
361 | ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); | ||
362 | loff_t pos; | ||
363 | |||
364 | ret = -EBADF; | ||
365 | file = fget(fd); | ||
366 | if (!file) | ||
367 | goto bad_file; | ||
368 | if (!(file->f_mode & FMODE_READ)) | ||
369 | goto out; | ||
370 | pos = merge_64(a4, a5); | ||
371 | ret = rw_verify_area(READ, file, &pos, count); | ||
372 | if (ret < 0) | ||
373 | goto out; | ||
374 | ret = -EINVAL; | ||
375 | if (!file->f_op || !(read = file->f_op->read)) | ||
376 | goto out; | ||
377 | if (pos < 0) | ||
378 | goto out; | ||
379 | ret = -ESPIPE; | ||
380 | if (!(file->f_mode & FMODE_PREAD)) | ||
381 | goto out; | ||
382 | ret = read(file, buf, count, &pos); | ||
383 | if (ret > 0) | ||
384 | dnotify_parent(file->f_dentry, DN_ACCESS); | ||
385 | out: | ||
386 | fput(file); | ||
387 | bad_file: | ||
388 | return ret; | ||
389 | } | 360 | } |
390 | 361 | ||
391 | asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char __user * buf, | 362 | asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char __user * buf, |
392 | size_t count, u32 unused, u64 a4, u64 a5) | 363 | size_t count, u32 unused, u64 a4, u64 a5) |
393 | { | 364 | { |
394 | ssize_t ret; | 365 | return sys_pwrite64(fd, buf, count, merge_64(a4, a5)); |
395 | struct file * file; | ||
396 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); | ||
397 | loff_t pos; | ||
398 | |||
399 | ret = -EBADF; | ||
400 | file = fget(fd); | ||
401 | if (!file) | ||
402 | goto bad_file; | ||
403 | if (!(file->f_mode & FMODE_WRITE)) | ||
404 | goto out; | ||
405 | pos = merge_64(a4, a5); | ||
406 | ret = rw_verify_area(WRITE, file, &pos, count); | ||
407 | if (ret < 0) | ||
408 | goto out; | ||
409 | ret = -EINVAL; | ||
410 | if (!file->f_op || !(write = file->f_op->write)) | ||
411 | goto out; | ||
412 | if (pos < 0) | ||
413 | goto out; | ||
414 | |||
415 | ret = -ESPIPE; | ||
416 | if (!(file->f_mode & FMODE_PWRITE)) | ||
417 | goto out; | ||
418 | |||
419 | ret = write(file, buf, count, &pos); | ||
420 | if (ret > 0) | ||
421 | dnotify_parent(file->f_dentry, DN_MODIFY); | ||
422 | out: | ||
423 | fput(file); | ||
424 | bad_file: | ||
425 | return ret; | ||
426 | } | 366 | } |
427 | 367 | ||
428 | asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, | 368 | asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, |