All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target/s390x/translate: Do not leak stack address in translate_one()
@ 2020-01-23  7:05 Thomas Huth
  2020-01-23  7:49 ` David Hildenbrand
  2020-01-23 10:25 ` Cornelia Huck
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Huth @ 2020-01-23  7:05 UTC (permalink / raw)
  To: qemu-devel, Richard Henderson, David Hildenbrand
  Cc: qemu-s390x, Cornelia Huck

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.

Buglink: https://bugs.launchpad.net/qemu/+bug/1661815
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 target/s390x/translate.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 4292bb0dd0..9122fb36da 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -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;
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-23 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-23  7:05 [PATCH] target/s390x/translate: Do not leak stack address in translate_one() Thomas Huth
2020-01-23  7:49 ` David Hildenbrand
2020-01-23 10:25 ` Cornelia Huck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.