Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9319657

Browse files
committed
Merge tag 'x86_core_for_v6.11_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 uaccess update from Borislav Petkov: - Cleanup the 8-byte getuser() asm case * tag 'x86_core_for_v6.11_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/uaccess: Improve the 8-byte getuser() case
2 parents 98896d8 + 8a2462d commit 9319657

File tree

1 file changed

+20
-49
lines changed

1 file changed

+20
-49
lines changed

arch/x86/lib/getuser.S

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,23 @@
4444
or %rdx, %rax
4545
.else
4646
cmp $TASK_SIZE_MAX-\size+1, %eax
47-
.if \size != 8
4847
jae .Lbad_get_user
49-
.else
50-
jae .Lbad_get_user_8
51-
.endif
5248
sbb %edx, %edx /* array_index_mask_nospec() */
5349
and %edx, %eax
5450
.endif
5551
.endm
5652

53+
.macro UACCESS op src dst
54+
1: \op \src,\dst
55+
_ASM_EXTABLE_UA(1b, __get_user_handle_exception)
56+
.endm
57+
58+
5759
.text
5860
SYM_FUNC_START(__get_user_1)
5961
check_range size=1
6062
ASM_STAC
61-
1: movzbl (%_ASM_AX),%edx
63+
UACCESS movzbl (%_ASM_AX),%edx
6264
xor %eax,%eax
6365
ASM_CLAC
6466
RET
@@ -68,7 +70,7 @@ EXPORT_SYMBOL(__get_user_1)
6870
SYM_FUNC_START(__get_user_2)
6971
check_range size=2
7072
ASM_STAC
71-
2: movzwl (%_ASM_AX),%edx
73+
UACCESS movzwl (%_ASM_AX),%edx
7274
xor %eax,%eax
7375
ASM_CLAC
7476
RET
@@ -78,7 +80,7 @@ EXPORT_SYMBOL(__get_user_2)
7880
SYM_FUNC_START(__get_user_4)
7981
check_range size=4
8082
ASM_STAC
81-
3: movl (%_ASM_AX),%edx
83+
UACCESS movl (%_ASM_AX),%edx
8284
xor %eax,%eax
8385
ASM_CLAC
8486
RET
@@ -89,10 +91,11 @@ SYM_FUNC_START(__get_user_8)
8991
check_range size=8
9092
ASM_STAC
9193
#ifdef CONFIG_X86_64
92-
4: movq (%_ASM_AX),%rdx
94+
UACCESS movq (%_ASM_AX),%rdx
9395
#else
94-
4: movl (%_ASM_AX),%edx
95-
5: movl 4(%_ASM_AX),%ecx
96+
xor %ecx,%ecx
97+
UACCESS movl (%_ASM_AX),%edx
98+
UACCESS movl 4(%_ASM_AX),%ecx
9699
#endif
97100
xor %eax,%eax
98101
ASM_CLAC
@@ -104,7 +107,7 @@ EXPORT_SYMBOL(__get_user_8)
104107
SYM_FUNC_START(__get_user_nocheck_1)
105108
ASM_STAC
106109
ASM_BARRIER_NOSPEC
107-
6: movzbl (%_ASM_AX),%edx
110+
UACCESS movzbl (%_ASM_AX),%edx
108111
xor %eax,%eax
109112
ASM_CLAC
110113
RET
@@ -114,7 +117,7 @@ EXPORT_SYMBOL(__get_user_nocheck_1)
114117
SYM_FUNC_START(__get_user_nocheck_2)
115118
ASM_STAC
116119
ASM_BARRIER_NOSPEC
117-
7: movzwl (%_ASM_AX),%edx
120+
UACCESS movzwl (%_ASM_AX),%edx
118121
xor %eax,%eax
119122
ASM_CLAC
120123
RET
@@ -124,7 +127,7 @@ EXPORT_SYMBOL(__get_user_nocheck_2)
124127
SYM_FUNC_START(__get_user_nocheck_4)
125128
ASM_STAC
126129
ASM_BARRIER_NOSPEC
127-
8: movl (%_ASM_AX),%edx
130+
UACCESS movl (%_ASM_AX),%edx
128131
xor %eax,%eax
129132
ASM_CLAC
130133
RET
@@ -135,10 +138,11 @@ SYM_FUNC_START(__get_user_nocheck_8)
135138
ASM_STAC
136139
ASM_BARRIER_NOSPEC
137140
#ifdef CONFIG_X86_64
138-
9: movq (%_ASM_AX),%rdx
141+
UACCESS movq (%_ASM_AX),%rdx
139142
#else
140-
9: movl (%_ASM_AX),%edx
141-
10: movl 4(%_ASM_AX),%ecx
143+
xor %ecx,%ecx
144+
UACCESS movl (%_ASM_AX),%edx
145+
UACCESS movl 4(%_ASM_AX),%ecx
142146
#endif
143147
xor %eax,%eax
144148
ASM_CLAC
@@ -154,36 +158,3 @@ SYM_CODE_START_LOCAL(__get_user_handle_exception)
154158
mov $(-EFAULT),%_ASM_AX
155159
RET
156160
SYM_CODE_END(__get_user_handle_exception)
157-
158-
#ifdef CONFIG_X86_32
159-
SYM_CODE_START_LOCAL(__get_user_8_handle_exception)
160-
ASM_CLAC
161-
.Lbad_get_user_8:
162-
xor %edx,%edx
163-
xor %ecx,%ecx
164-
mov $(-EFAULT),%_ASM_AX
165-
RET
166-
SYM_CODE_END(__get_user_8_handle_exception)
167-
#endif
168-
169-
/* get_user */
170-
_ASM_EXTABLE_UA(1b, __get_user_handle_exception)
171-
_ASM_EXTABLE_UA(2b, __get_user_handle_exception)
172-
_ASM_EXTABLE_UA(3b, __get_user_handle_exception)
173-
#ifdef CONFIG_X86_64
174-
_ASM_EXTABLE_UA(4b, __get_user_handle_exception)
175-
#else
176-
_ASM_EXTABLE_UA(4b, __get_user_8_handle_exception)
177-
_ASM_EXTABLE_UA(5b, __get_user_8_handle_exception)
178-
#endif
179-
180-
/* __get_user */
181-
_ASM_EXTABLE_UA(6b, __get_user_handle_exception)
182-
_ASM_EXTABLE_UA(7b, __get_user_handle_exception)
183-
_ASM_EXTABLE_UA(8b, __get_user_handle_exception)
184-
#ifdef CONFIG_X86_64
185-
_ASM_EXTABLE_UA(9b, __get_user_handle_exception)
186-
#else
187-
_ASM_EXTABLE_UA(9b, __get_user_8_handle_exception)
188-
_ASM_EXTABLE_UA(10b, __get_user_8_handle_exception)
189-
#endif

0 commit comments

Comments
 (0)