Skip to content

Commit 2b5a6d7

Browse files
arndbgregkh
authored andcommitted
nds32: fix access_ok() checks in get/put_user
commit 8926d88 upstream. The get_user()/put_user() functions are meant to check for access_ok(), while the __get_user()/__put_user() functions don't. This broke in 4.19 for nds32, when it gained an extraneous check in __get_user(), but lost the check it needs in __put_user(). Fixes: 487913a ("nds32: Extract the checking and getting pointer to a macro") Cc: stable@vger.kernel.org @ v4.19+ Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c064268 commit 2b5a6d7

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

arch/nds32/include/asm/uaccess.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ static inline void set_fs(mm_segment_t fs)
7070
* versions are void (ie, don't return a value as such).
7171
*/
7272

73-
#define get_user __get_user \
74-
75-
#define __get_user(x, ptr) \
73+
#define get_user(x, ptr) \
7674
({ \
7775
long __gu_err = 0; \
7876
__get_user_check((x), (ptr), __gu_err); \
@@ -85,6 +83,14 @@ static inline void set_fs(mm_segment_t fs)
8583
(void)0; \
8684
})
8785

86+
#define __get_user(x, ptr) \
87+
({ \
88+
long __gu_err = 0; \
89+
const __typeof__(*(ptr)) __user *__p = (ptr); \
90+
__get_user_err((x), __p, (__gu_err)); \
91+
__gu_err; \
92+
})
93+
8894
#define __get_user_check(x, ptr, err) \
8995
({ \
9096
const __typeof__(*(ptr)) __user *__p = (ptr); \
@@ -165,12 +171,18 @@ do { \
165171
: "r"(addr), "i"(-EFAULT) \
166172
: "cc")
167173

168-
#define put_user __put_user \
174+
#define put_user(x, ptr) \
175+
({ \
176+
long __pu_err = 0; \
177+
__put_user_check((x), (ptr), __pu_err); \
178+
__pu_err; \
179+
})
169180

170181
#define __put_user(x, ptr) \
171182
({ \
172183
long __pu_err = 0; \
173-
__put_user_err((x), (ptr), __pu_err); \
184+
__typeof__(*(ptr)) __user *__p = (ptr); \
185+
__put_user_err((x), __p, __pu_err); \
174186
__pu_err; \
175187
})
176188

0 commit comments

Comments
 (0)