[PATCH] arm: fix handling of F_OFD_... in oabi_fcntl64()

Cc: stable@vger.kernel.org # 3.15+
Reviewed-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-12-28 20:47:08 -05:00
parent 74bf8efb5f
commit 76cc404bfd
1 changed files with 39 additions and 38 deletions

View File

@ -193,22 +193,14 @@ struct oabi_flock64 {
pid_t l_pid; pid_t l_pid;
} __attribute__ ((packed,aligned(4))); } __attribute__ ((packed,aligned(4)));
asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, static long do_locks(unsigned int fd, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct oabi_flock64 user;
struct flock64 kernel; struct flock64 kernel;
mm_segment_t fs = USER_DS; /* initialized to kill a warning */ struct oabi_flock64 user;
unsigned long local_arg = arg; mm_segment_t fs;
int ret; long ret;
switch (cmd) {
case F_OFD_GETLK:
case F_OFD_SETLK:
case F_OFD_SETLKW:
case F_GETLK64:
case F_SETLK64:
case F_SETLKW64:
if (copy_from_user(&user, (struct oabi_flock64 __user *)arg, if (copy_from_user(&user, (struct oabi_flock64 __user *)arg,
sizeof(user))) sizeof(user)))
return -EFAULT; return -EFAULT;
@ -217,16 +209,13 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
kernel.l_start = user.l_start; kernel.l_start = user.l_start;
kernel.l_len = user.l_len; kernel.l_len = user.l_len;
kernel.l_pid = user.l_pid; kernel.l_pid = user.l_pid;
local_arg = (unsigned long)&kernel;
fs = get_fs(); fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
} ret = sys_fcntl64(fd, cmd, (unsigned long)&kernel);
set_fs(fs);
ret = sys_fcntl64(fd, cmd, local_arg); if (!ret && (cmd == F_GETLK64 || cmd == F_OFD_GETLK)) {
switch (cmd) {
case F_GETLK64:
if (!ret) {
user.l_type = kernel.l_type; user.l_type = kernel.l_type;
user.l_whence = kernel.l_whence; user.l_whence = kernel.l_whence;
user.l_start = kernel.l_start; user.l_start = kernel.l_start;
@ -236,12 +225,24 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
&user, sizeof(user))) &user, sizeof(user)))
ret = -EFAULT; ret = -EFAULT;
} }
case F_SETLK64: return ret;
case F_SETLKW64:
set_fs(fs);
} }
return ret; asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
unsigned long arg)
{
switch (cmd) {
case F_OFD_GETLK:
case F_OFD_SETLK:
case F_OFD_SETLKW:
case F_GETLK64:
case F_SETLK64:
case F_SETLKW64:
return do_locks(fd, cmd, arg);
default:
return sys_fcntl64(fd, cmd, arg);
}
} }
struct oabi_epoll_event { struct oabi_epoll_event {