fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall
Jeff Layton
maintainerPATCH v2 1/1 fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall
From: Jeff Layton <[email protected]>
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_OFF_T_MAX either, so remove it.
--- arch/arm64/include/asm/compat.h | 1 - arch/mips/include/asm/compat.h | 1 - arch/parisc/include/asm/compat.h | 1 - arch/powerpc/include/asm/compat.h | 1 - arch/s390/include/asm/compat.h | 1 - arch/sparc/include/asm/compat.h | 1 - arch/tile/include/asm/compat.h | 1 - arch/x86/include/asm/compat.h | 1 - fs/fcntl.c | 11 +++++------ 9 files changed, 5 insertions(+), 14 deletions(-)
arch/arm64/include/asm/compat.h +0 -1
@@ -215,7 +215,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL/* * A pointer passed in from user mode. This should not
arch/mips/include/asm/compat.h +0 -1
@@ -200,7 +200,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL/* * A pointer passed in from user mode. This should not
arch/parisc/include/asm/compat.h +0 -1
@@ -195,7 +195,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffLstruct compat_ipc64_perm {compat_key_t key;
arch/powerpc/include/asm/compat.h +0 -1
@@ -185,7 +185,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL/* * A pointer passed in from user mode. This should not
arch/s390/include/asm/compat.h +0 -1
@@ -263,7 +263,6 @@ typedef struct compat_siginfo {#define si_overrun _sifields._timer._overrun#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL/* * A pointer passed in from user mode. This should not
arch/sparc/include/asm/compat.h +0 -1
@@ -209,7 +209,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL/* * A pointer passed in from user mode. This should not
arch/tile/include/asm/compat.h +0 -1
@@ -173,7 +173,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffLstruct compat_ipc64_perm {compat_key_t key;
arch/x86/include/asm/compat.h +0 -1
@@ -210,7 +210,6 @@ typedef struct compat_siginfo { } compat_siginfo_t;#define COMPAT_OFF_T_MAX 0x7fffffff -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffLstruct compat_ipc64_perm {compat_key_t key;
fs/fcntl.c +5 -6
@@ -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 :
Signature · 1 line
2.14.3
Jeff Layton писал 15.11.17 21:03:
...
Quoted 1 line
With this, we no longer need
COMPAT_OFF_T_MAXeither, so remove it.
COMPAT_LOFF_T_MAX
Signature · 3 lines
С уважением, Виталий Липатов, Etersoft
Jeff Layton
maintainerQuoted 6 lines · Vitaly Lipatov
Jeff Layton писал 15.11.17 21:03:
...Quoted 1 line
With this, we no longer need
COMPAT_OFF_T_MAXeither, so remove it.
COMPAT_LOFF_T_MAX
Thanks, fixed in tree, but I won't resend just for that.
Are you able to test this patch and confirm that it fixes the problem you were seeing?
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 10 lines · Jeff Layton
From: Jeff Layton <[email protected]>
Currently, we're capping the values too low in the
F_GETLK64case. 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_OFF_T_MAXeither, so remove it.
Sounds like the COMPAT_LOFF_T_MAX should be a separate patch, but otherwise this looks good.
Btw, I seems like arm has another copy of the old broken compat code in arch/arm/kernel/sys_oabi-compat.c. I wonder if anyone with a vested interest in arm would be willing to clean that mess up.