[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>

authored by Al Viro and committed by Linus Torvalds 6ad0013b de0bb97a

+2 -62
+2 -62
arch/mips/kernel/linux32.c
··· 356 356 asmlinkage ssize_t sys32_pread(unsigned int fd, char __user * buf, 357 357 size_t count, u32 unused, u64 a4, u64 a5) 358 358 { 359 - ssize_t ret; 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; 359 + return sys_pread64(fd, buf, count, merge_64(a4, a5)); 389 360 } 390 361 391 362 asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char __user * buf, 392 363 size_t count, u32 unused, u64 a4, u64 a5) 393 364 { 394 - ssize_t ret; 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; 365 + return sys_pwrite64(fd, buf, count, merge_64(a4, a5)); 426 366 } 427 367 428 368 asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid,