Commit 4d2dc2cc authored by Jeff Layton's avatar Jeff Layton

fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall

Currently, we're capping the values too low in the F_GETLK64 case. The
fields in that structure are 64-bit values, so we shouldn't need to do
any sort of fixup there.

Make sure we check that assumption at build time in the future however
by ensuring that the sizes we're copying will fit.

With this, we no longer need COMPAT_LOFF_T_MAX either, so remove it.

Fixes: 94073ad7 (fs/locks: don't mess with the address limit in compat_fcntl64)
Reported-by: default avatarVitaly Lipatov <lav@etersoft.ru>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
parent 9280a601
...@@ -215,7 +215,6 @@ typedef struct compat_siginfo { ...@@ -215,7 +215,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
......
...@@ -200,7 +200,6 @@ typedef struct compat_siginfo { ...@@ -200,7 +200,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
......
...@@ -195,7 +195,6 @@ typedef struct compat_siginfo { ...@@ -195,7 +195,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
struct compat_ipc64_perm { struct compat_ipc64_perm {
compat_key_t key; compat_key_t key;
......
...@@ -185,7 +185,6 @@ typedef struct compat_siginfo { ...@@ -185,7 +185,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
......
...@@ -263,7 +263,6 @@ typedef struct compat_siginfo { ...@@ -263,7 +263,6 @@ typedef struct compat_siginfo {
#define si_overrun _sifields._timer._overrun #define si_overrun _sifields._timer._overrun
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
......
...@@ -209,7 +209,6 @@ typedef struct compat_siginfo { ...@@ -209,7 +209,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
......
...@@ -173,7 +173,6 @@ typedef struct compat_siginfo { ...@@ -173,7 +173,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
struct compat_ipc64_perm { struct compat_ipc64_perm {
compat_key_t key; compat_key_t key;
......
...@@ -210,7 +210,6 @@ typedef struct compat_siginfo { ...@@ -210,7 +210,6 @@ typedef struct compat_siginfo {
} compat_siginfo_t; } compat_siginfo_t;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
struct compat_ipc64_perm { struct compat_ipc64_perm {
compat_key_t key; compat_key_t key;
......
...@@ -563,6 +563,9 @@ static int put_compat_flock64(const struct flock *kfl, struct compat_flock64 __u ...@@ -563,6 +563,9 @@ static int put_compat_flock64(const struct flock *kfl, struct compat_flock64 __u
{ {
struct compat_flock64 fl; struct compat_flock64 fl;
BUILD_BUG_ON(sizeof(kfl->l_start) > sizeof(ufl->l_start));
BUILD_BUG_ON(sizeof(kfl->l_len) > sizeof(ufl->l_len));
memset(&fl, 0, sizeof(struct compat_flock64)); memset(&fl, 0, sizeof(struct compat_flock64));
copy_flock_fields(&fl, kfl); copy_flock_fields(&fl, kfl);
if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64))) if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64)))
...@@ -641,12 +644,8 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, ...@@ -641,12 +644,8 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
if (err) if (err)
break; break;
err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
if (err) if (!err)
break; err = put_compat_flock64(&flock, compat_ptr(arg));
err = fixup_compat_flock(&flock);
if (err)
return err;
err = put_compat_flock64(&flock, compat_ptr(arg));
break; break;
case F_SETLK: case F_SETLK:
case F_SETLKW: case F_SETLKW:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment