linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall
@ 2017-11-15 13:17 Jeff Layton
  2017-11-15 13:36 ` Vitaly Lipatov
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2017-11-15 13:17 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Vitaly Lipatov, hch, bfields, Alexander Viro, linux-kernel

From: Jeff Layton <jlayton@redhat.com>

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

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>
---
 fs/fcntl.c | 11 +++++------
 1 file 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
 {
 	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:
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall
  2017-11-15 13:17 [PATCH] fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall Jeff Layton
@ 2017-11-15 13:36 ` Vitaly Lipatov
  0 siblings, 0 replies; 2+ messages in thread
From: Vitaly Lipatov @ 2017-11-15 13:36 UTC (permalink / raw)
  To: Jeff Layton; +Cc: linux-fsdevel, hch, bfields, Alexander Viro, linux-kernel

Jeff Layton писал 15.11.17 16:17:
> From: Jeff Layton <jlayton@redhat.com>
> 
> 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 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.
Nice fix.
The only question I do not know answer is what is purpose of 
COMPAT_LOFF_T_MAX macro?

-- 
С уважением,
Виталий Липатов,
Etersoft

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-15 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-15 13:17 [PATCH] fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall Jeff Layton
2017-11-15 13:36 ` Vitaly Lipatov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).