diff options
author | Jeff Layton <jlayton@redhat.com> | 2017-11-14 14:42:57 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-17 15:07:59 +0100 |
commit | fc2f802193ccecf710ab608712b5b102dd9efc75 (patch) | |
tree | 82cc9a30c45bbfe64f58b4b0476468eac5427a39 /fs/fcntl.c | |
parent | 4b57542126669a5ad8bede61c8e9e07a5fc4a39b (diff) | |
download | linux-exynos-fc2f802193ccecf710ab608712b5b102dd9efc75.tar.gz linux-exynos-fc2f802193ccecf710ab608712b5b102dd9efc75.tar.bz2 linux-exynos-fc2f802193ccecf710ab608712b5b102dd9efc75.zip |
fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall
commit 4d2dc2cc766c3b51929658cacbc6e34fc8e242fb upstream.
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: 94073ad77fff2 (fs/locks: don't mess with the address limit in compat_fcntl64)
Reported-by: Vitaly Lipatov <lav@etersoft.ru>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r-- | fs/fcntl.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 6fd311367efc..0345a46b8856 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -563,6 +563,9 @@ static int put_compat_flock64(const struct flock *kfl, struct compat_flock64 __u { 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)); copy_flock_fields(&fl, kfl); if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64))) @@ -641,12 +644,8 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, if (err) break; err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); - if (err) - break; - err = fixup_compat_flock(&flock); - if (err) - return err; - err = put_compat_flock64(&flock, compat_ptr(arg)); + if (!err) + err = put_compat_flock64(&flock, compat_ptr(arg)); break; case F_SETLK: case F_SETLKW: |