aboutsummaryrefslogtreecommitdiff
path: root/src/vm_arm.dasc
diff options
context:
space:
mode:
authorMike Pall <mike>2023-11-12 14:42:24 +0100
committerMike Pall <mike>2023-11-12 14:42:24 +0100
commita4c1640432a9d8a60624cdc8065b15078c228e36 (patch)
treea0c6f0d4fe83927dff1f7042a077631c1bcf52c1 /src/vm_arm.dasc
parent65c849390702b1150d52e64db86cbc6b3c98413e (diff)
downloadluajit-a4c1640432a9d8a60624cdc8065b15078c228e36.tar.gz
luajit-a4c1640432a9d8a60624cdc8065b15078c228e36.tar.bz2
luajit-a4c1640432a9d8a60624cdc8065b15078c228e36.zip
Add stack check to pcall/xpcall.
Analyzed by Peter Cawley. #1048
Diffstat (limited to 'src/vm_arm.dasc')
-rw-r--r--src/vm_arm.dasc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc
index 7dae1a53..872de45a 100644
--- a/src/vm_arm.dasc
+++ b/src/vm_arm.dasc
@@ -1155,8 +1155,11 @@ static void build_subroutines(BuildCtx *ctx)
1155 |//-- Base library: catch errors ---------------------------------------- 1155 |//-- Base library: catch errors ----------------------------------------
1156 | 1156 |
1157 |.ffunc pcall 1157 |.ffunc pcall
1158 | ldr RB, L->maxstack
1159 | add INS, BASE, NARGS8:RC
1158 | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] 1160 | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)]
1159 | cmp NARGS8:RC, #8 1161 | cmp NARGS8:RC, #8
1162 | cmphs RB, INS
1160 | blo ->fff_fallback 1163 | blo ->fff_fallback
1161 | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. 1164 | tst RA, #HOOK_ACTIVE // Remember active hook before pcall.
1162 | mov RB, BASE 1165 | mov RB, BASE
@@ -1167,7 +1170,11 @@ static void build_subroutines(BuildCtx *ctx)
1167 | b ->vm_call_dispatch 1170 | b ->vm_call_dispatch
1168 | 1171 |
1169 |.ffunc_2 xpcall 1172 |.ffunc_2 xpcall
1173 | ldr RB, L->maxstack
1174 | add INS, BASE, NARGS8:RC
1170 | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] 1175 | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)]
1176 | cmp RB, INS
1177 | blo ->fff_fallback
1171 | checkfunc CARG4, ->fff_fallback // Traceback must be a function. 1178 | checkfunc CARG4, ->fff_fallback // Traceback must be a function.
1172 | mov RB, BASE 1179 | mov RB, BASE
1173 | strd CARG12, [BASE, #8] // Swap function and traceback. 1180 | strd CARG12, [BASE, #8] // Swap function and traceback.