]>
Commit | Line | Data |
---|---|---|
c3ac1dc6 GKH |
1 | From 4d2dc2cc766c3b51929658cacbc6e34fc8e242fb Mon Sep 17 00:00:00 2001 |
2 | From: Jeff Layton <jlayton@redhat.com> | |
3 | Date: Tue, 14 Nov 2017 14:42:57 -0500 | |
4 | Subject: fcntl: don't cap l_start and l_end values for F_GETLK64 in compat syscall | |
5 | ||
6 | From: Jeff Layton <jlayton@redhat.com> | |
7 | ||
8 | commit 4d2dc2cc766c3b51929658cacbc6e34fc8e242fb upstream. | |
9 | ||
10 | Currently, we're capping the values too low in the F_GETLK64 case. The | |
11 | fields in that structure are 64-bit values, so we shouldn't need to do | |
12 | any sort of fixup there. | |
13 | ||
14 | Make sure we check that assumption at build time in the future however | |
15 | by ensuring that the sizes we're copying will fit. | |
16 | ||
17 | With this, we no longer need COMPAT_LOFF_T_MAX either, so remove it. | |
18 | ||
19 | Fixes: 94073ad77fff2 (fs/locks: don't mess with the address limit in compat_fcntl64) | |
20 | Reported-by: Vitaly Lipatov <lav@etersoft.ru> | |
21 | Signed-off-by: Jeff Layton <jlayton@redhat.com> | |
22 | Reviewed-by: David Howells <dhowells@redhat.com> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
24 | ||
25 | --- | |
26 | arch/arm64/include/asm/compat.h | 1 - | |
27 | arch/mips/include/asm/compat.h | 1 - | |
28 | arch/parisc/include/asm/compat.h | 1 - | |
29 | arch/powerpc/include/asm/compat.h | 1 - | |
30 | arch/s390/include/asm/compat.h | 1 - | |
31 | arch/sparc/include/asm/compat.h | 1 - | |
32 | arch/tile/include/asm/compat.h | 1 - | |
33 | arch/x86/include/asm/compat.h | 1 - | |
34 | fs/fcntl.c | 11 +++++------ | |
35 | 9 files changed, 5 insertions(+), 14 deletions(-) | |
36 | ||
37 | --- a/arch/arm64/include/asm/compat.h | |
38 | +++ b/arch/arm64/include/asm/compat.h | |
39 | @@ -215,7 +215,6 @@ typedef struct compat_siginfo { | |
40 | } compat_siginfo_t; | |
41 | ||
42 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
43 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
44 | ||
45 | /* | |
46 | * A pointer passed in from user mode. This should not | |
47 | --- a/arch/mips/include/asm/compat.h | |
48 | +++ b/arch/mips/include/asm/compat.h | |
49 | @@ -200,7 +200,6 @@ typedef struct compat_siginfo { | |
50 | } compat_siginfo_t; | |
51 | ||
52 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
53 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
54 | ||
55 | /* | |
56 | * A pointer passed in from user mode. This should not | |
57 | --- a/arch/parisc/include/asm/compat.h | |
58 | +++ b/arch/parisc/include/asm/compat.h | |
59 | @@ -195,7 +195,6 @@ typedef struct compat_siginfo { | |
60 | } compat_siginfo_t; | |
61 | ||
62 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
63 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
64 | ||
65 | struct compat_ipc64_perm { | |
66 | compat_key_t key; | |
67 | --- a/arch/powerpc/include/asm/compat.h | |
68 | +++ b/arch/powerpc/include/asm/compat.h | |
69 | @@ -185,7 +185,6 @@ typedef struct compat_siginfo { | |
70 | } compat_siginfo_t; | |
71 | ||
72 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
73 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
74 | ||
75 | /* | |
76 | * A pointer passed in from user mode. This should not | |
77 | --- a/arch/s390/include/asm/compat.h | |
78 | +++ b/arch/s390/include/asm/compat.h | |
79 | @@ -263,7 +263,6 @@ typedef struct compat_siginfo { | |
80 | #define si_overrun _sifields._timer._overrun | |
81 | ||
82 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
83 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
84 | ||
85 | /* | |
86 | * A pointer passed in from user mode. This should not | |
87 | --- a/arch/sparc/include/asm/compat.h | |
88 | +++ b/arch/sparc/include/asm/compat.h | |
89 | @@ -209,7 +209,6 @@ typedef struct compat_siginfo { | |
90 | } compat_siginfo_t; | |
91 | ||
92 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
93 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
94 | ||
95 | /* | |
96 | * A pointer passed in from user mode. This should not | |
97 | --- a/arch/tile/include/asm/compat.h | |
98 | +++ b/arch/tile/include/asm/compat.h | |
99 | @@ -173,7 +173,6 @@ typedef struct compat_siginfo { | |
100 | } compat_siginfo_t; | |
101 | ||
102 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
103 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
104 | ||
105 | struct compat_ipc64_perm { | |
106 | compat_key_t key; | |
107 | --- a/arch/x86/include/asm/compat.h | |
108 | +++ b/arch/x86/include/asm/compat.h | |
109 | @@ -209,7 +209,6 @@ typedef struct compat_siginfo { | |
110 | } compat_siginfo_t; | |
111 | ||
112 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
113 | -#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
114 | ||
115 | struct compat_ipc64_perm { | |
116 | compat_key_t key; | |
117 | --- a/fs/fcntl.c | |
118 | +++ b/fs/fcntl.c | |
119 | @@ -563,6 +563,9 @@ static int put_compat_flock64(const stru | |
120 | { | |
121 | struct compat_flock64 fl; | |
122 | ||
123 | + BUILD_BUG_ON(sizeof(kfl->l_start) > sizeof(ufl->l_start)); | |
124 | + BUILD_BUG_ON(sizeof(kfl->l_len) > sizeof(ufl->l_len)); | |
125 | + | |
126 | memset(&fl, 0, sizeof(struct compat_flock64)); | |
127 | copy_flock_fields(&fl, kfl); | |
128 | if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64))) | |
129 | @@ -641,12 +644,8 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned | |
130 | if (err) | |
131 | break; | |
132 | err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); | |
133 | - if (err) | |
134 | - break; | |
135 | - err = fixup_compat_flock(&flock); | |
136 | - if (err) | |
137 | - return err; | |
138 | - err = put_compat_flock64(&flock, compat_ptr(arg)); | |
139 | + if (!err) | |
140 | + err = put_compat_flock64(&flock, compat_ptr(arg)); | |
141 | break; | |
142 | case F_SETLK: | |
143 | case F_SETLKW: |