qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Jim Meyering" <meyering@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Riku Voipio" <riku.voipio@linaro.org>,
	"Cédric VINCENT" <cedric.vincent@st.com>
Subject: [Qemu-devel] [PATCH 5/6] arm-semi: don't leak 1kb user string lock buffer upon TARGET_SYS_OPEN
Date: Wed, 16 May 2012 15:08:00 +0200	[thread overview]
Message-ID: <1337173681-25891-6-git-send-email-jim@meyering.net> (raw)
In-Reply-To: <1337173681-25891-1-git-send-email-jim@meyering.net>

From: Jim Meyering <meyering@redhat.com>

Always call unlock_user before returning.

.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 arm-semi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arm-semi.c b/arm-semi.c
index 88ca9bb..5d2a2d2 100644
--- a/arm-semi.c
+++ b/arm-semi.c
@@ -194,18 +194,19 @@ uint32_t do_arm_semihosting(CPUARMState *env)
         if (!(s = lock_user_string(ARG(0))))
             /* FIXME - should this error code be -TARGET_EFAULT ? */
             return (uint32_t)-1;
-        if (ARG(1) >= 12)
+        if (ARG(1) >= 12) {
+            unlock_user(s, ARG(0), 0);
             return (uint32_t)-1;
+        }
         if (strcmp(s, ":tt") == 0) {
-            if (ARG(1) < 4)
-                return STDIN_FILENO;
-            else
-                return STDOUT_FILENO;
+            int result_fileno = ARG(1) < 4 ? STDIN_FILENO : STDOUT_FILENO;
+            unlock_user(s, ARG(0), 0);
+            return result_fileno;
         }
         if (use_gdb_syscalls()) {
             gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
 			   (int)ARG(2)+1, gdb_open_modeflags[ARG(1)]);
-            return env->regs[0];
+            ret = env->regs[0];
         } else {
             ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644));
         }
-- 
1.7.10.2.520.g6a4a482

  parent reply	other threads:[~2012-05-16 13:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 13:07 [Qemu-devel] [PATCH 0/6] plug memory and file-descriptor leaks Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 1/6] qcow2: don't leak buffer for unexpected qcow_version in header Jim Meyering
2012-05-21 10:57   ` Kevin Wolf
2012-05-21 11:06     ` [Qemu-devel] [PATCHv2 " Jim Meyering
2012-05-21 11:24       ` Kevin Wolf
2012-05-21 11:07     ` [Qemu-devel] [PATCH " Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 2/6] qemu-ga: avoid unconditional lockfile file descriptor leak Jim Meyering
2012-05-16 18:15   ` Michael Roth
2012-05-16 20:17     ` Jim Meyering
2012-05-16 20:19   ` [Qemu-devel] [PATCHv2 2/6] qemu-ga: don't leak a file descriptor upon failed lockf Jim Meyering
2012-05-16 20:58     ` Michael Roth
2012-05-16 13:07 ` [Qemu-devel] [PATCH 3/6] linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure Jim Meyering
2012-05-16 13:21   ` Peter Maydell
2012-05-16 13:50     ` Jim Meyering
2012-05-16 13:52   ` [Qemu-devel] [PATCHv2 " Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 4/6] sheepdog: don't leak socket file descriptor upon connection failure Jim Meyering
2012-05-21 11:00   ` Kevin Wolf
2012-08-17 13:30     ` Jim Meyering
2012-08-17 13:40       ` Kevin Wolf
2012-08-17 13:42         ` Jim Meyering
2012-05-16 13:08 ` Jim Meyering [this message]
2012-05-16 13:15   ` [Qemu-devel] [PATCH 5/6] arm-semi: don't leak 1kb user string lock buffer upon TARGET_SYS_OPEN Peter Maydell
2012-05-16 13:08 ` [Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM Jim Meyering
2012-05-19  7:13   ` Matthew Fernandez
2012-05-19 15:46   ` Peter Maydell
2012-05-24 14:46     ` Jim Meyering
2012-05-24 14:46   ` [Qemu-devel] [PATCH v2 " Jim Meyering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337173681-25891-6-git-send-email-jim@meyering.net \
    --to=jim@meyering.net \
    --cc=aliguori@us.ibm.com \
    --cc=cedric.vincent@st.com \
    --cc=meyering@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@linaro.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).