summaryrefslogtreecommitdiffstats
path: root/fs/fcntl.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2017-11-14 14:42:57 -0500
committerJeff Layton <jlayton@redhat.com>2017-11-15 08:08:36 -0500
commit4d2dc2cc766c3b51929658cacbc6e34fc8e242fb (patch)
treecc8fca80ff984b268f9acedbb582f1f7a410ac69 /fs/fcntl.c
parent9280a601e6080c9ff658468c1c775ff6514099a6 (diff)
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: 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>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r--fs/fcntl.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c
index e15bcc4265d0..0522e283a4f4 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
563{ 563{
564 struct compat_flock64 fl; 564 struct compat_flock64 fl;
565 565
566 BUILD_BUG_ON(sizeof(kfl->l_start) > sizeof(ufl->l_start));
567 BUILD_BUG_ON(sizeof(kfl->l_len) > sizeof(ufl->l_len));
568
566 memset(&fl, 0, sizeof(struct compat_flock64)); 569 memset(&fl, 0, sizeof(struct compat_flock64));
567 copy_flock_fields(&fl, kfl); 570 copy_flock_fields(&fl, kfl);
568 if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64))) 571 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 if (err) 644 if (err)
642 break; 645 break;
643 err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); 646 err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
644 if (err) 647 if (!err)
645 break; 648 err = put_compat_flock64(&flock, compat_ptr(arg));
646 err = fixup_compat_flock(&flock);
647 if (err)
648 return err;
649 err = put_compat_flock64(&flock, compat_ptr(arg));
650 break; 649 break;
651 case F_SETLK: 650 case F_SETLK:
652 case F_SETLKW: 651 case F_SETLKW: