target/s390x/translate: Do not leak stack address in translate_one()
PATCH 1/1 target/s390x/translate: Do not leak stack address in translate_one()
The code in translate_one() leaks a stack address via "s->field" parameter:
static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
{
DisasJumpType ret = DISAS_NEXT;
DisasFields f;
[...]
s->fields = &f;
[...]
return ret;}
It's currently harmless since the caller does not seem to use "fields" anymore, but let's better play safe (and please static code analyzers) by setting the fields back to NULL before returning.
--- target/s390x/translate.c | 2 ++ 1 file changed, 2 insertions(+)
target/s390x/translate.c +2 -0
@@ -6435,6 +6435,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) }#endif + s->fields =NULL ; +/* Advance to the next instruction. */ s->base.pc_next = s->pc_tmp;return ret;
Signature · 1 line
2.18.1
Quoted 16 lines
Am 23.01.2020 um 08:05 schrieb Thomas Huth <[email protected]>:
The code in
translate_one()leaks a stack address via "s->field" parameter:static DisasJumpType
translate_one(CPUS390XState *env, DisasContext *s){ DisasJumpType ret = DISAS_NEXT; DisasFields f; [...] s->fields = &f; [...] return ret; }
Quoted 6 lines
It's currently harmless since the caller does not seem to use "fields" anymore, but let's better play safe (and please static code analyzers) by setting the fields back to NULL before returning.
Signed-off-by Thomas Huth <[email protected]>
Quoted 20 lines
---
target/s390x/translate.c| 2 ++1 file changed, 2 insertions(+)target/s390x/translate.c +2
-0@@ -6435,6 +6435,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) }#endif + s->fields =NULL ; +/* Advance to the next instruction. */ s->base.pc_next = s->pc_tmp;return ret;Signature · 1 line
2.18.1
Cornelia Huck
AppliedQuoted 16 lines · On Thu, 23 Jan 2020 08:05:33 +0100 Thomas Huth <[email protected]> wrote:
The code in
translate_one()leaks a stack address via "s->field" parameter:static DisasJumpType
translate_one(CPUS390XState *env, DisasContext *s){ DisasJumpType ret = DISAS_NEXT; DisasFields f; [...] s->fields = &f; [...] return ret;}
It's currently harmless since the caller does not seem to use "fields" anymore, but let's better play safe (and please static code analyzers) by setting the fields back to NULL before returning.
Quoted 5 lines
Signed-off-by Thomas Huth <[email protected]>--- target/s390x/translate.c | 2 ++ 1 file changed, 2 insertions(+)
Thanks, applied.