diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-01 07:26:39 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-01 07:26:39 +0000 |
commit | 232f31ca12a94eb9f51182955285a4474f876af7 (patch) | |
tree | 7643d2e3ccdf0323633e23f45aab5707ac871dff /vm_insnhelper.h | |
parent | 8a098051c58446db8be3dcaea3447ce83e16df99 (diff) | |
download | ruby-232f31ca12a94eb9f51182955285a4474f876af7.tar.gz |
on-smash canary detection
In addition to detect dead canary, we try to detect the very moment
when we smash the stack top. Requested by k0kubun:
https://twitter.com/k0kubun/status/1085180749899194368
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.h')
-rw-r--r-- | vm_insnhelper.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/vm_insnhelper.h b/vm_insnhelper.h index b96c794d4f..c004e5ecd6 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -137,14 +137,22 @@ enum vm_regan_acttype { #if VM_CHECK_MODE > 0 #define SETUP_CANARY() \ - VALUE * canary; \ + VALUE *canary; \ if (leaf) { \ canary = GET_SP(); \ SET_SV(vm_stack_canary); \ + } \ + else {\ + SET_SV(Qfalse); /* cleanup */ \ } #define CHECK_CANARY() \ - if (leaf && (*canary != vm_stack_canary)) { \ - vm_canary_is_found_dead(INSN_ATTR(bin), *canary); \ + if (leaf) { \ + if (*canary == vm_stack_canary) { \ + *canary = Qfalse; /* cleanup */ \ + } \ + else { \ + vm_canary_is_found_dead(INSN_ATTR(bin), *canary); \ + } \ } #else #define SETUP_CANARY() /* void */ |