Skip to content

Commit e66d511

Browse files
heiherchenhuacai
authored andcommitted
LoongArch: Fix return value underflow in exception path
This patch fixes an underflow issue in the return value within the exception path, specifically at .Llt8 when the remaining length is less than 8 bytes. Cc: [email protected] Fixes: 8941e93 ("LoongArch: Optimize memory ops (memset/memcpy/memmove)") Reported-by: Weihao Li <[email protected]> Signed-off-by: WANG Rui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 83da30d commit e66d511

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

arch/loongarch/lib/clear_user.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ SYM_FUNC_START(__clear_user_fast)
108108
addi.d a3, a2, -8
109109
bgeu a0, a3, .Llt8
110110
15: st.d zero, a0, 0
111+
addi.d a0, a0, 8
111112

112113
.Llt8:
113114
16: st.d zero, a2, -8
@@ -188,7 +189,7 @@ SYM_FUNC_START(__clear_user_fast)
188189
_asm_extable 13b, .L_fixup_handle_0
189190
_asm_extable 14b, .L_fixup_handle_1
190191
_asm_extable 15b, .L_fixup_handle_0
191-
_asm_extable 16b, .L_fixup_handle_1
192+
_asm_extable 16b, .L_fixup_handle_0
192193
_asm_extable 17b, .L_fixup_handle_s0
193194
_asm_extable 18b, .L_fixup_handle_s0
194195
_asm_extable 19b, .L_fixup_handle_s0

arch/loongarch/lib/copy_user.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ SYM_FUNC_START(__copy_user_fast)
136136
bgeu a1, a4, .Llt8
137137
30: ld.d t0, a1, 0
138138
31: st.d t0, a0, 0
139+
addi.d a0, a0, 8
139140

140141
.Llt8:
141142
32: ld.d t0, a3, -8
@@ -246,7 +247,7 @@ SYM_FUNC_START(__copy_user_fast)
246247
_asm_extable 30b, .L_fixup_handle_0
247248
_asm_extable 31b, .L_fixup_handle_0
248249
_asm_extable 32b, .L_fixup_handle_0
249-
_asm_extable 33b, .L_fixup_handle_1
250+
_asm_extable 33b, .L_fixup_handle_0
250251
_asm_extable 34b, .L_fixup_handle_s0
251252
_asm_extable 35b, .L_fixup_handle_s0
252253
_asm_extable 36b, .L_fixup_handle_s0

0 commit comments

Comments
 (0)