qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>,
	"Franklin \\\"Snaipe\\\" Mathieu" <snaipe@diacritic.io>,
	Riku Voipio <riku.voipio@linaro.org>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PULL 6/6] syscall: fixed mincore(2) not failing with ENOMEM
Date: Mon, 27 Feb 2017 23:33:37 +0100	[thread overview]
Message-ID: <20170227223337.17434-7-laurent@vivier.eu> (raw)
In-Reply-To: <20170227223337.17434-1-laurent@vivier.eu>

From: "Franklin \\\"Snaipe\\\" Mathieu" <snaipe@diacritic.io>

The current implementation of the mincore(2) syscall sets errno to
EFAULT when the region identified by the first two parameters is
invalid.

This goes against the man page specification, where mincore(2) should
only fail with EFAULT when the third parameter is an invalid address;
and fail with ENOMEM when the checked region does not point to mapped
memory.

Signed-off-by: Franklin "Snaipe" Mathieu <snaipe@diacritic.io>
Cc: Riku Voipio <riku.voipio@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20170217085800.28873-2-snaipe@diacritic.io>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2bba500..cec8428 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11194,11 +11194,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_mincore:
         {
             void *a;
+            ret = -TARGET_ENOMEM;
+            a = lock_user(VERIFY_READ, arg1, arg2, 0);
+            if (!a) {
+                goto fail;
+            }
             ret = -TARGET_EFAULT;
-            if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
-                goto efault;
-            if (!(p = lock_user_string(arg3)))
+            p = lock_user_string(arg3);
+            if (!p) {
                 goto mincore_fail;
+            }
             ret = get_errno(mincore(a, arg2, p));
             unlock_user(p, arg3, ret);
             mincore_fail:
-- 
2.9.3

  parent reply	other threads:[~2017-02-27 22:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27 22:33 [Qemu-devel] [PULL 0/6] Linux user for upstream patches Laurent Vivier
2017-02-27 22:33 ` [Qemu-devel] [PULL 1/6] linux-user: fix fork() Laurent Vivier
2017-02-27 22:33 ` [Qemu-devel] [PULL 2/6] linux-user: Add sockopts for IPv6 ping and IPv6 traceroute Laurent Vivier
2017-02-27 22:33 ` [Qemu-devel] [PULL 3/6] linux-user: Add signal handling support for x86_64 Laurent Vivier
2017-02-27 22:33 ` [Qemu-devel] [PULL 4/6] linux-user: correctly manage SR in ucontext Laurent Vivier
2017-02-27 22:33 ` [Qemu-devel] [PULL 5/6] linux-user: fix do_rt_sigreturn on m68k linux userspace emulation Laurent Vivier
2017-02-27 22:33 ` Laurent Vivier [this message]
2017-02-28 13:01 ` [Qemu-devel] [PULL 0/6] Linux user for upstream patches Peter Maydell

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=20170227223337.17434-7-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=riku.voipio@linaro.org \
    --cc=snaipe@diacritic.io \
    /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).