提交 afeb7ed4 编写于 作者: T Tong Tiangen 提交者: Ma Wupeng

arm64: copy_form/to_user support machine check safe

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GB28
CVE: NA

-------------------------------

Add copy_{to, from}_user() to machine check safe.

If copy fail due to hardware memory error, only the relevant processes are
affected, so killing the user process and isolate the user page with
hardware memory errors is a more reasonable choice than kernel panic.
Signed-off-by: NTong Tiangen <tongtiangen@huawei.com>
上级 8a9bc410
...@@ -70,6 +70,9 @@ alternative_else_nop_endif ...@@ -70,6 +70,9 @@ alternative_else_nop_endif
_asm_extable 8888b,\l; _asm_extable 8888b,\l;
_asm_extable 8889b,\l; _asm_extable 8889b,\l;
_asm_mc_extable 8888b,\l;
_asm_mc_extable 8889b,\l;
.endm .endm
.macro user_stp l, reg1, reg2, addr, post_inc .macro user_stp l, reg1, reg2, addr, post_inc
...@@ -86,5 +89,7 @@ alternative_else_nop_endif ...@@ -86,5 +89,7 @@ alternative_else_nop_endif
add \addr, \addr, \post_inc; add \addr, \addr, \post_inc;
_asm_extable 8888b,\l; _asm_extable 8888b,\l;
_asm_mc_extable 8888b,\l;
.endm .endm
#endif #endif
...@@ -162,8 +162,12 @@ alternative_endif ...@@ -162,8 +162,12 @@ alternative_endif
#define USER(l, x...) \ #define USER(l, x...) \
9999: x; \ 9999: x; \
_asm_extable 9999b, l _asm_extable 9999b, l; \
_asm_mc_extable 9999b, l
#define USER_MC(l, x...) \
9999: x; \
_asm_mc_extable 9999b, l
/* /*
* Register aliases. * Register aliases.
*/ */
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
.endm .endm
.macro strb1 reg, ptr, val .macro strb1 reg, ptr, val
strb \reg, [\ptr], \val USER_MC(9998f, strb \reg, [\ptr], \val)
.endm .endm
.macro ldrh1 reg, ptr, val .macro ldrh1 reg, ptr, val
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
.endm .endm
.macro strh1 reg, ptr, val .macro strh1 reg, ptr, val
strh \reg, [\ptr], \val USER_MC(9998f, strh \reg, [\ptr], \val)
.endm .endm
.macro ldr1 reg, ptr, val .macro ldr1 reg, ptr, val
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
.endm .endm
.macro str1 reg, ptr, val .macro str1 reg, ptr, val
str \reg, [\ptr], \val USER_MC(9998f, str \reg, [\ptr], \val)
.endm .endm
.macro ldp1 reg1, reg2, ptr, val .macro ldp1 reg1, reg2, ptr, val
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
.endm .endm
.macro stp1 reg1, reg2, ptr, val .macro stp1 reg1, reg2, ptr, val
stp \reg1, \reg2, [\ptr], \val USER_MC(9998f, stp \reg1, \reg2, [\ptr], \val)
.endm .endm
end .req x5 end .req x5
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* x0 - bytes not copied * x0 - bytes not copied
*/ */
.macro ldrb1 reg, ptr, val .macro ldrb1 reg, ptr, val
ldrb \reg, [\ptr], \val USER_MC(9998f, ldrb \reg, [\ptr], \val)
.endm .endm
.macro strb1 reg, ptr, val .macro strb1 reg, ptr, val
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
.endm .endm
.macro ldrh1 reg, ptr, val .macro ldrh1 reg, ptr, val
ldrh \reg, [\ptr], \val USER_MC(9998f, ldrh \reg, [\ptr], \val)
.endm .endm
.macro strh1 reg, ptr, val .macro strh1 reg, ptr, val
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
.endm .endm
.macro ldr1 reg, ptr, val .macro ldr1 reg, ptr, val
ldr \reg, [\ptr], \val USER_MC(9998f, ldr \reg, [\ptr], \val)
.endm .endm
.macro str1 reg, ptr, val .macro str1 reg, ptr, val
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
.endm .endm
.macro ldp1 reg1, reg2, ptr, val .macro ldp1 reg1, reg2, ptr, val
ldp \reg1, \reg2, [\ptr], \val USER_MC(9998f, ldp \reg1, \reg2, [\ptr], \val)
.endm .endm
.macro stp1 reg1, reg2, ptr, val .macro stp1 reg1, reg2, ptr, val
...@@ -67,7 +67,7 @@ EXPORT_SYMBOL(__arch_copy_to_user) ...@@ -67,7 +67,7 @@ EXPORT_SYMBOL(__arch_copy_to_user)
9997: cmp dst, dstin 9997: cmp dst, dstin
b.ne 9998f b.ne 9998f
// Before being absolutely sure we couldn't copy anything, try harder // Before being absolutely sure we couldn't copy anything, try harder
ldrb tmp1w, [srcin] USER_MC(9998f, ldrb tmp1w, [srcin])
USER(9998f, sttrb tmp1w, [dst]) USER(9998f, sttrb tmp1w, [dst])
add dst, dst, #1 add dst, dst, #1
9998: sub x0, end, dst // bytes not copied 9998: sub x0, end, dst // bytes not copied
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册