All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
@ 2017-02-16  8:58 Franklin Snaipe Mathieu
  2017-02-17  0:50 ` Fam Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Franklin Snaipe Mathieu @ 2017-02-16  8:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, snaipe, Franklin "Snaipe" Mathieu,
	Riku Voipio, Aurelien Jarno

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>
---
 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 9be8e9530e..af0dd40631 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11061,11 +11061,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.11.0

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

* Re: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-16  8:58 [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM Franklin Snaipe Mathieu
@ 2017-02-17  0:50 ` Fam Zheng
  2017-02-17  8:05   ` Franklin "Snaipe" Mathieu
  2017-02-17  8:57 ` Franklin Snaipe Mathieu
  2017-02-28  6:08 ` Michael Tokarev
  2 siblings, 1 reply; 9+ messages in thread
From: Fam Zheng @ 2017-02-17  0:50 UTC (permalink / raw)
  To: Franklin Snaipe Mathieu
  Cc: qemu-devel, qemu-trivial, snaipe, Riku Voipio, Aurelien Jarno

On Thu, 02/16 08:58, Franklin Snaipe Mathieu wrote:
> +            p = lock_user_string(arg3)
> +            if (!p) {

Please compile test at least, even if it is a trivial patch.

Fam

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

* Re: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-17  0:50 ` Fam Zheng
@ 2017-02-17  8:05   ` Franklin "Snaipe" Mathieu
  0 siblings, 0 replies; 9+ messages in thread
From: Franklin "Snaipe" Mathieu @ 2017-02-17  8:05 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, qemu-trivial, snaipe, Riku Voipio, Aurelien Jarno

2017-02-17 0:50 GMT+00:00 Fam Zheng <famz@redhat.com>:
> On Thu, 02/16 08:58, Franklin Snaipe Mathieu wrote:
>> +            p = lock_user_string(arg3)
>> +            if (!p) {
>
> Please compile test at least, even if it is a trivial patch.
>

Whoops, sorry, I forgot to re-compile after fixing the checkpatch issues.

-- 
Franklin "Snaipe" Mathieu
🝰 https://diacritic.io

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

* [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-16  8:58 [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM Franklin Snaipe Mathieu
  2017-02-17  0:50 ` Fam Zheng
@ 2017-02-17  8:57 ` Franklin Snaipe Mathieu
  2017-02-17  8:58   ` [Qemu-devel] [PATCH v2] " Franklin Snaipe Mathieu
  2017-02-17  9:00   ` [Qemu-devel] [PATCH] " Franklin "Snaipe" Mathieu
  2017-02-28  6:08 ` Michael Tokarev
  2 siblings, 2 replies; 9+ messages in thread
From: Franklin Snaipe Mathieu @ 2017-02-17  8:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, snaipe, Franklin "Snaipe" Mathieu,
	Riku Voipio, Aurelien Jarno

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>
---
 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 9be8e9530e..733e0009e1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11061,11 +11061,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.11.0

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

* [Qemu-devel] [PATCH v2] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-17  8:57 ` Franklin Snaipe Mathieu
@ 2017-02-17  8:58   ` Franklin Snaipe Mathieu
  2017-02-26 13:12     ` Laurent Vivier
  2017-02-17  9:00   ` [Qemu-devel] [PATCH] " Franklin "Snaipe" Mathieu
  1 sibling, 1 reply; 9+ messages in thread
From: Franklin Snaipe Mathieu @ 2017-02-17  8:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, snaipe, Franklin "Snaipe" Mathieu,
	Riku Voipio, Aurelien Jarno

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>
---
 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 9be8e9530e..733e0009e1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11061,11 +11061,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.11.0

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

* Re: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-17  8:57 ` Franklin Snaipe Mathieu
  2017-02-17  8:58   ` [Qemu-devel] [PATCH v2] " Franklin Snaipe Mathieu
@ 2017-02-17  9:00   ` Franklin "Snaipe" Mathieu
  2017-02-17 10:17     ` Fam Zheng
  1 sibling, 1 reply; 9+ messages in thread
From: Franklin "Snaipe" Mathieu @ 2017-02-17  9:00 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, snaipe, Franklin Snaipe Mathieu, Riku Voipio,
	Aurelien Jarno

Ignore this patch, this was sent again by mistake.

2017-02-17 8:57 GMT+00:00 Franklin Snaipe Mathieu <snaipe@diacritic.io>:
> 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>
> ---
>  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 9be8e9530e..733e0009e1 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -11061,11 +11061,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.11.0
>



-- 
Franklin "Snaipe" Mathieu
🝰 https://diacritic.io

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

* Re: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-17  9:00   ` [Qemu-devel] [PATCH] " Franklin "Snaipe" Mathieu
@ 2017-02-17 10:17     ` Fam Zheng
  0 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-02-17 10:17 UTC (permalink / raw)
  To: Franklin "Snaipe" Mathieu
  Cc: qemu-devel, qemu-trivial, snaipe, Riku Voipio, Aurelien Jarno

On Fri, 02/17 09:00, Franklin "Snaipe" Mathieu wrote:
> Ignore this patch, this was sent again by mistake.

Hi Franklin, thanks for the re-submission. Next time please send consecutive
versions as top-level threads instead of replies to previous versions, with
proper 'v2", "v3" tags in the subject.

Fam

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

* Re: [Qemu-devel] [PATCH v2] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-17  8:58   ` [Qemu-devel] [PATCH v2] " Franklin Snaipe Mathieu
@ 2017-02-26 13:12     ` Laurent Vivier
  0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2017-02-26 13:12 UTC (permalink / raw)
  To: Franklin Snaipe Mathieu, qemu-devel
  Cc: qemu-trivial, snaipe, Riku Voipio, Aurelien Jarno

Le 17/02/2017 à 09:58, Franklin Snaipe Mathieu a écrit :
> 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>
> ---
>  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 9be8e9530e..733e0009e1 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -11061,11 +11061,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:
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

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

* Re: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM
  2017-02-16  8:58 [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM Franklin Snaipe Mathieu
  2017-02-17  0:50 ` Fam Zheng
  2017-02-17  8:57 ` Franklin Snaipe Mathieu
@ 2017-02-28  6:08 ` Michael Tokarev
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Tokarev @ 2017-02-28  6:08 UTC (permalink / raw)
  To: Franklin Snaipe Mathieu, qemu-devel; +Cc: qemu-trivial, snaipe, Riku Voipio

16.02.2017 11:58, Franklin Snaipe Mathieu wrote:
> 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.

Applied to -trivial, thanks!

/mjt

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

end of thread, other threads:[~2017-02-28  6:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16  8:58 [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM Franklin Snaipe Mathieu
2017-02-17  0:50 ` Fam Zheng
2017-02-17  8:05   ` Franklin "Snaipe" Mathieu
2017-02-17  8:57 ` Franklin Snaipe Mathieu
2017-02-17  8:58   ` [Qemu-devel] [PATCH v2] " Franklin Snaipe Mathieu
2017-02-26 13:12     ` Laurent Vivier
2017-02-17  9:00   ` [Qemu-devel] [PATCH] " Franklin "Snaipe" Mathieu
2017-02-17 10:17     ` Fam Zheng
2017-02-28  6:08 ` Michael Tokarev

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.