diff mbox series

[v1,1/1] linux-user/syscall: Fix missing target_to_host_timespec64() check

Message ID cad74fae734d2562746b94acd9c34b00081c89bf.1604432881.git.alistair.francis@wdc.com
State New
Headers show
Series [v1,1/1] linux-user/syscall: Fix missing target_to_host_timespec64() check | expand

Commit Message

Alistair Francis Nov. 3, 2020, 7:48 p.m. UTC
Coverity pointed out (CID 1432339) that target_to_host_timespec64() can
fail with -TARGET_EFAULT but we never check the return value. This patch
checks the return value and handles the error.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Nov. 3, 2020, 8:39 p.m. UTC | #1
On 11/3/20 8:48 PM, Alistair Francis wrote:
> Coverity pointed out (CID 1432339) that target_to_host_timespec64() can

> fail with -TARGET_EFAULT but we never check the return value. This patch

> checks the return value and handles the error.

> 

> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

>  linux-user/syscall.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/linux-user/syscall.c b/linux-user/syscall.c

> index 6fef8181e7..3160a9ba06 100644

> --- a/linux-user/syscall.c

> +++ b/linux-user/syscall.c

> @@ -7592,7 +7592,9 @@ static int do_futex_time64(target_ulong uaddr, int op, int val, target_ulong tim

>      case FUTEX_WAIT_BITSET:

>          if (timeout) {

>              pts = &ts;

> -            target_to_host_timespec64(pts, timeout);

> +            if (target_to_host_timespec64(pts, timeout)) {

> +                return -TARGET_EFAULT;

> +            }

>          } else {

>              pts = NULL;

>          }

>
Laurent Vivier Nov. 4, 2020, 9:27 p.m. UTC | #2
Le 03/11/2020 à 20:48, Alistair Francis a écrit :
> Coverity pointed out (CID 1432339) that target_to_host_timespec64() can

> fail with -TARGET_EFAULT but we never check the return value. This patch

> checks the return value and handles the error.

> 

> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

> ---

>  linux-user/syscall.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/linux-user/syscall.c b/linux-user/syscall.c

> index 6fef8181e7..3160a9ba06 100644

> --- a/linux-user/syscall.c

> +++ b/linux-user/syscall.c

> @@ -7592,7 +7592,9 @@ static int do_futex_time64(target_ulong uaddr, int op, int val, target_ulong tim

>      case FUTEX_WAIT_BITSET:

>          if (timeout) {

>              pts = &ts;

> -            target_to_host_timespec64(pts, timeout);

> +            if (target_to_host_timespec64(pts, timeout)) {

> +                return -TARGET_EFAULT;

> +            }

>          } else {

>              pts = NULL;

>          }

> 


Applied to my linux-user-for-5.2 branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6fef8181e7..3160a9ba06 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7592,7 +7592,9 @@  static int do_futex_time64(target_ulong uaddr, int op, int val, target_ulong tim
     case FUTEX_WAIT_BITSET:
         if (timeout) {
             pts = &ts;
-            target_to_host_timespec64(pts, timeout);
+            if (target_to_host_timespec64(pts, timeout)) {
+                return -TARGET_EFAULT;
+            }
         } else {
             pts = NULL;
         }