qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/6] linux-user updates
@ 2014-02-19 10:35 riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 1/6] linux-user: sync syscall numbers upto 3.13 riku.voipio
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

The following changes since commit 46eef33b89e936ca793e13c4aeea1414e97e8dbb:

  Fix QEMU build on OpenBSD on x86 archs (2014-02-17 11:44:00 +0000)

are available in the git repository at:

  git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream

for you to fetch changes up to 69d4c703a549f0630793a67b16a8fc6bc14c8654:

  linux-user: Fix error handling in target_to_host_semarray() (2014-02-19 12:29:23 +0200)

Andreas Färber (1):
  linux-user: Implement BLKPG ioctl

Peter Maydell (4):
  linux-user/elfload.c: Avoid calling g_free() on uninitialized data
  linux-user/signal.c: Don't pass sigaction uninitialised sa_flags
  linux-user: Fix error handling in lock_iovec()
  linux-user: Fix error handling in target_to_host_semarray()

Riku Voipio (1):
  linux-user: sync syscall numbers upto 3.13

 linux-user/alpha/syscall_nr.h      |  7 +++++++
 linux-user/arm/syscall_nr.h        |  6 ++++++
 linux-user/cris/syscall_nr.h       |  1 +
 linux-user/elfload.c               | 16 ++++++++++++----
 linux-user/i386/syscall_nr.h       |  6 ++++++
 linux-user/ioctls.h                |  1 +
 linux-user/m68k/syscall_nr.h       |  5 +++++
 linux-user/microblaze/syscall_nr.h |  7 ++++++-
 linux-user/mips/syscall_nr.h       |  6 ++++++
 linux-user/mips64/syscall_nr.h     | 13 +++++++++++++
 linux-user/openrisc/syscall_nr.h   |  6 +++++-
 linux-user/ppc/syscall_nr.h        |  6 ++++++
 linux-user/s390x/syscall_nr.h      |  7 ++++++-
 linux-user/sh4/syscall_nr.h        |  6 ++++++
 linux-user/signal.c                |  1 +
 linux-user/sparc/syscall_nr.h      |  7 +++++++
 linux-user/sparc64/syscall_nr.h    |  7 +++++++
 linux-user/syscall.c               | 20 ++++++++++++++------
 linux-user/syscall_defs.h          |  1 +
 linux-user/syscall_types.h         | 13 +++++++++++++
 linux-user/x86_64/syscall_nr.h     |  7 +++++++
 21 files changed, 136 insertions(+), 13 deletions(-)

-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 1/6] linux-user: sync syscall numbers upto 3.13
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 2/6] linux-user/elfload.c: Avoid calling g_free() on uninitialized data riku.voipio
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

All others updated except unicore, which doesn't look right to
begin with.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/alpha/syscall_nr.h      |  7 +++++++
 linux-user/arm/syscall_nr.h        |  6 ++++++
 linux-user/cris/syscall_nr.h       |  1 +
 linux-user/i386/syscall_nr.h       |  6 ++++++
 linux-user/m68k/syscall_nr.h       |  5 +++++
 linux-user/microblaze/syscall_nr.h |  7 ++++++-
 linux-user/mips/syscall_nr.h       |  6 ++++++
 linux-user/mips64/syscall_nr.h     | 13 +++++++++++++
 linux-user/openrisc/syscall_nr.h   |  6 +++++-
 linux-user/ppc/syscall_nr.h        |  6 ++++++
 linux-user/s390x/syscall_nr.h      |  7 ++++++-
 linux-user/sh4/syscall_nr.h        |  6 ++++++
 linux-user/sparc/syscall_nr.h      |  7 +++++++
 linux-user/sparc64/syscall_nr.h    |  7 +++++++
 linux-user/x86_64/syscall_nr.h     |  7 +++++++
 15 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/linux-user/alpha/syscall_nr.h b/linux-user/alpha/syscall_nr.h
index d52d76e..625f301 100644
--- a/linux-user/alpha/syscall_nr.h
+++ b/linux-user/alpha/syscall_nr.h
@@ -433,3 +433,10 @@
 #define TARGET_NR_open_by_handle_at             498
 #define TARGET_NR_clock_adjtime                 499
 #define TARGET_NR_syncfs                        500
+#define TARGET_NR_setns                         501
+#define TARGET_NR_accept4                       502
+#define TARGET_NR_sendmmsg                      503
+#define TARGET_NR_process_vm_readv              504
+#define TARGET_NR_process_vm_writev             505
+#define TARGET_NR_kcmp                          506
+#define TARGET_NR_finit_module                  507
diff --git a/linux-user/arm/syscall_nr.h b/linux-user/arm/syscall_nr.h
index 42d6855..bef847c 100644
--- a/linux-user/arm/syscall_nr.h
+++ b/linux-user/arm/syscall_nr.h
@@ -378,3 +378,9 @@
 #define TARGET_NR_open_by_handle_at            (371)
 #define TARGET_NR_clock_adjtime                (372)
 #define TARGET_NR_syncfs                       (373)
+#define TARGET_NR_sendmmsg                     (374)
+#define TARGET_NR_setns                        (375)
+#define TARGET_NR_process_vm_readv             (376)
+#define TARGET_NR_process_vm_writev            (377)
+#define TARGET_NR_kcmp                         (378)
+#define TARGET_NR_finit_module                 (379)
diff --git a/linux-user/cris/syscall_nr.h b/linux-user/cris/syscall_nr.h
index 98f1a0b..694bd02 100644
--- a/linux-user/cris/syscall_nr.h
+++ b/linux-user/cris/syscall_nr.h
@@ -335,3 +335,4 @@
 #define TARGET_NR_inotify_init1      332
 #define TARGET_NR_preadv             333
 #define TARGET_NR_pwritev            334
+#define TARGET_NR_setns              335
diff --git a/linux-user/i386/syscall_nr.h b/linux-user/i386/syscall_nr.h
index f080305..c8f7302 100644
--- a/linux-user/i386/syscall_nr.h
+++ b/linux-user/i386/syscall_nr.h
@@ -347,3 +347,9 @@
 #define TARGET_NR_open_by_handle_at     342
 #define TARGET_NR_clock_adjtime         343
 #define TARGET_NR_syncfs                344
+#define TARGET_NR_sendmmsg              345
+#define TARGET_NR_setns                 346
+#define TARGET_NR_process_vm_readv      347
+#define TARGET_NR_process_vm_writev     348
+#define TARGET_NR_kcmp                  349
+#define TARGET_NR_finit_module          350
diff --git a/linux-user/m68k/syscall_nr.h b/linux-user/m68k/syscall_nr.h
index 4d0937e..25f8521 100644
--- a/linux-user/m68k/syscall_nr.h
+++ b/linux-user/m68k/syscall_nr.h
@@ -344,3 +344,8 @@
 #define TARGET_NR_open_by_handle_at     341
 #define TARGET_NR_clock_adjtime         342
 #define TARGET_NR_syncfs                343
+#define TARGET_NR_setns                 344
+#define TARGET_NR_process_vm_readv      345
+#define TARGET_NR_process_vm_writev     346
+#define TARGET_NR_kcmp                  347
+#define TARGET_NR_finit_module          348
diff --git a/linux-user/microblaze/syscall_nr.h b/linux-user/microblaze/syscall_nr.h
index f1fe0e7..6f530f9 100644
--- a/linux-user/microblaze/syscall_nr.h
+++ b/linux-user/microblaze/syscall_nr.h
@@ -376,4 +376,9 @@
 #define TARGET_NR_open_by_handle_at     372
 #define TARGET_NR_clock_adjtime         373
 #define TARGET_NR_syncfs                374
-
+#define TARGET_NR_setns                 375
+#define TARGET_NR_sendmmsg              376
+#define TARGET_NR_process_vm_readv      377
+#define TARGET_NR_process_vm_writev     378
+#define TARGET_NR_kcmp                  379
+#define TARGET_NR_finit_module          380
diff --git a/linux-user/mips/syscall_nr.h b/linux-user/mips/syscall_nr.h
index fbdc348..2d1a13e 100644
--- a/linux-user/mips/syscall_nr.h
+++ b/linux-user/mips/syscall_nr.h
@@ -345,3 +345,9 @@
 #define TARGET_NR_open_by_handle_at     (TARGET_NR_Linux + 340)
 #define TARGET_NR_clock_adjtime         (TARGET_NR_Linux + 341)
 #define TARGET_NR_syncfs                (TARGET_NR_Linux + 342)
+#define TARGET_NR_sendmmsg              (TARGET_NR_Linux + 343)
+#define TARGET_NR_setns                 (TARGET_NR_Linux + 344)
+#define TARGET_NR_process_vm_readv      (TARGET_NR_Linux + 345)
+#define TARGET_NR_process_vm_writev     (TARGET_NR_Linux + 346)
+#define TARGET_NR_kcmp                  (TARGET_NR_Linux + 347)
+#define TARGET_NR_finit_module          (TARGET_NR_Linux + 348)
diff --git a/linux-user/mips64/syscall_nr.h b/linux-user/mips64/syscall_nr.h
index 0f4a6b1..004232a 100644
--- a/linux-user/mips64/syscall_nr.h
+++ b/linux-user/mips64/syscall_nr.h
@@ -310,6 +310,12 @@
 #define TARGET_NR_open_by_handle_at     (TARGET_NR_Linux + 304)
 #define TARGET_NR_clock_adjtime         (TARGET_NR_Linux + 305)
 #define TARGET_NR_syncfs                (TARGET_NR_Linux + 306)
+#define TARGET_NR_sendmmsg              (TARGET_NR_Linux + 307)
+#define TARGET_NR_setns                 (TARGET_NR_Linux + 308)
+#define TARGET_NR_process_vm_readv      (TARGET_NR_Linux + 309)
+#define TARGET_NR_process_vm_writev     (TARGET_NR_Linux + 310)
+#define TARGET_NR_kcmp                  (TARGET_NR_Linux + 311)
+#define TARGET_NR_finit_module          (TARGET_NR_Linux + 312)
 #else
 /*
  * Linux 64-bit syscalls are in the range from 5000 to 5999.
@@ -617,4 +623,11 @@
 #define TARGET_NR_open_by_handle_at     (TARGET_NR_Linux + 299)
 #define TARGET_NR_clock_adjtime         (TARGET_NR_Linux + 300)
 #define TARGET_NR_syncfs                (TARGET_NR_Linux + 301)
+#define TARGET_NR_sendmmsg              (TARGET_NR_Linux + 302)
+#define TARGET_NR_setns                 (TARGET_NR_Linux + 303)
+#define TARGET_NR_process_vm_readv      (TARGET_NR_Linux + 304)
+#define TARGET_NR_process_vm_writev     (TARGET_NR_Linux + 305)
+#define TARGET_NR_kcmp                  (TARGET_NR_Linux + 306)
+#define TARGET_NR_finit_module          (TARGET_NR_Linux + 307)
+#define TARGET_NR_getdents64            (TARGET_NR_Linux + 308)
 #endif
diff --git a/linux-user/openrisc/syscall_nr.h b/linux-user/openrisc/syscall_nr.h
index f4ac91e..4c386ea 100644
--- a/linux-user/openrisc/syscall_nr.h
+++ b/linux-user/openrisc/syscall_nr.h
@@ -378,9 +378,13 @@
 #define TARGET_NR_syncfs 267
 #define TARGET_NR_setns 268
 #define TARGET_NR_sendmmsg 269
+#define TARGET_NR_process_vm_readv 270
+#define TARGET_NR_process_vm_writev 271
+#define TARGET_NR_kcmp 272
+#define TARGET_NR_finit_module 273
 
 #undef TARGET_NR_syscalls
-#define TARGET_NR_syscalls 270
+#define TARGET_NR_syscalls 274
 
 /*
  * All syscalls below here should go away really,
diff --git a/linux-user/ppc/syscall_nr.h b/linux-user/ppc/syscall_nr.h
index 0673b7d..1e1736e 100644
--- a/linux-user/ppc/syscall_nr.h
+++ b/linux-user/ppc/syscall_nr.h
@@ -362,3 +362,9 @@
 #define TARGET_NR_open_by_handle_at     346
 #define TARGET_NR_clock_adjtime         347
 #define TARGET_NR_syncfs                348
+#define TARGET_NR_sendmmsg              349
+#define TARGET_NR_setns                 350
+#define TARGET_NR_process_vm_readv      351
+#define TARGET_NR_process_vm_writev     352
+#define TARGET_NR_finit_module          353
+#define TARGET_NR_kcmp                  354
diff --git a/linux-user/s390x/syscall_nr.h b/linux-user/s390x/syscall_nr.h
index d4529ac..7c0b8b2 100644
--- a/linux-user/s390x/syscall_nr.h
+++ b/linux-user/s390x/syscall_nr.h
@@ -265,6 +265,12 @@
 #define TARGET_NR_open_by_handle_at     336
 #define TARGET_NR_clock_adjtime         337
 #define TARGET_NR_syncfs                338
+#define TARGET_NR_setns                 339
+#define TARGET_NR_process_vm_readv      340
+#define TARGET_NR_process_vm_writev     341
+#define TARGET_NR_s390_runtime_instr    342
+#define TARGET_NR_kcmp                  343
+#define TARGET_NR_finit_module          344
 
 /*
  * There are some system calls that are not present on 64 bit, some
@@ -355,4 +361,3 @@
 #define TARGET_NR_newfstatat		293
 
 #endif
-
diff --git a/linux-user/sh4/syscall_nr.h b/linux-user/sh4/syscall_nr.h
index 365db58..bdf8742 100644
--- a/linux-user/sh4/syscall_nr.h
+++ b/linux-user/sh4/syscall_nr.h
@@ -366,3 +366,9 @@
 #define TARGET_NR_open_by_handle_at     360
 #define TARGET_NR_clock_adjtime         361
 #define TARGET_NR_syncfs                362
+#define TARGET_NR_sendmmsg              363
+#define TARGET_NR_setns                 364
+#define TARGET_NR_process_vm_readv      365
+#define TARGET_NR_process_vm_writev     366
+#define TARGET_NR_kcmp                  367
+#define TARGET_NR_finit_module          368
diff --git a/linux-user/sparc/syscall_nr.h b/linux-user/sparc/syscall_nr.h
index 534e6e9..181cd32 100644
--- a/linux-user/sparc/syscall_nr.h
+++ b/linux-user/sparc/syscall_nr.h
@@ -302,3 +302,10 @@
 #define TARGET_NR_open_by_handle_at     333
 #define TARGET_NR_clock_adjtime         334
 #define TARGET_NR_syncfs                335
+#define TARGET_NR_sendmmsg              336
+#define TARGET_NR_setns                 337
+#define TARGET_NR_process_vm_readv      338
+#define TARGET_NR_process_vm_writev     339
+#define TARGET_NR_kern_features         340
+#define TARGET_NR_kcmp                  341
+#define TARGET_NR_finit_module          342
diff --git a/linux-user/sparc64/syscall_nr.h b/linux-user/sparc64/syscall_nr.h
index 70988b2..34a984c 100644
--- a/linux-user/sparc64/syscall_nr.h
+++ b/linux-user/sparc64/syscall_nr.h
@@ -334,3 +334,10 @@
 #define TARGET_NR_open_by_handle_at     333
 #define TARGET_NR_clock_adjtime         334
 #define TARGET_NR_syncfs                335
+#define TARGET_NR_sendmmsg              336
+#define TARGET_NR_setns                 337
+#define TARGET_NR_process_vm_readv      338
+#define TARGET_NR_process_vm_writev     339
+#define TARGET_NR_kern_features         340
+#define TARGET_NR_kcmp                  341
+#define TARGET_NR_finit_module          342
diff --git a/linux-user/x86_64/syscall_nr.h b/linux-user/x86_64/syscall_nr.h
index 947e961..7c59e3a 100644
--- a/linux-user/x86_64/syscall_nr.h
+++ b/linux-user/x86_64/syscall_nr.h
@@ -305,3 +305,10 @@
 #define TARGET_NR_open_by_handle_at     304
 #define TARGET_NR_clock_adjtime         305
 #define TARGET_NR_syncfs                306
+#define TARGET_NR_sendmmsg              307
+#define TARGET_NR_setns                 308
+#define TARGET_NR_getcpu                309
+#define TARGET_NR_process_vm_readv      310
+#define TARGET_NR_process_vm_writev     311
+#define TARGET_NR_kcmp                  312
+#define TARGET_NR_finit_module          313
-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 2/6] linux-user/elfload.c: Avoid calling g_free() on uninitialized data
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 1/6] linux-user: sync syscall numbers upto 3.13 riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 3/6] linux-user/signal.c: Don't pass sigaction uninitialised sa_flags riku.voipio
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

Avoid calling g_free() on unintialized data in the error-handling
paths in elf_core_dump() by splitting the initialization of the
elf_note_info struct out of fill_note_info() so that it's always
valid to call free_note_info() whether we got to the point of
being able to fill_note_info() or not.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/elfload.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 5902f16..c0687e3 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2636,6 +2636,16 @@ static void fill_thread_info(struct elf_note_info *info, const CPUArchState *env
     info->notes_size += note_size(&ets->notes[0]);
 }
 
+static void init_note_info(struct elf_note_info *info)
+{
+    /* Initialize the elf_note_info structure so that it is at
+     * least safe to call free_note_info() on it. Must be
+     * called before calling fill_note_info().
+     */
+    memset(info, 0, sizeof (*info));
+    QTAILQ_INIT(&info->thread_list);
+}
+
 static int fill_note_info(struct elf_note_info *info,
                           long signr, const CPUArchState *env)
 {
@@ -2644,10 +2654,6 @@ static int fill_note_info(struct elf_note_info *info,
     TaskState *ts = (TaskState *)env->opaque;
     int i;
 
-    (void) memset(info, 0, sizeof (*info));
-
-    QTAILQ_INIT(&info->thread_list);
-
     info->notes = g_malloc0(NUMNOTES * sizeof (struct memelfnote));
     if (info->notes == NULL)
         return (-ENOMEM);
@@ -2781,6 +2787,8 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     int segs = 0;
     int fd = -1;
 
+    init_note_info(&info);
+
     errno = 0;
     getrlimit(RLIMIT_CORE, &dumpsize);
     if (dumpsize.rlim_cur == 0)
-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 3/6] linux-user/signal.c: Don't pass sigaction uninitialised sa_flags
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 1/6] linux-user: sync syscall numbers upto 3.13 riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 2/6] linux-user/elfload.c: Avoid calling g_free() on uninitialized data riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 4/6] linux-user: Fix error handling in lock_iovec() riku.voipio
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

When forcing a fatal signal, we weren't initialising the sa_flags
field in the struct sigaction we used to reset the signal handler
to SIG_DFL.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/signal.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 82e8592..04638e2 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -420,6 +420,7 @@ static void QEMU_NORETURN force_sig(int target_sig)
      * it to arrive. */
     sigfillset(&act.sa_mask);
     act.sa_handler = SIG_DFL;
+    act.sa_flags = 0;
     sigaction(host_sig, &act, NULL);
 
     /* For some reason raise(host_sig) doesn't send the signal when
-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 4/6] linux-user: Fix error handling in lock_iovec()
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
                   ` (2 preceding siblings ...)
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 3/6] linux-user/signal.c: Don't pass sigaction uninitialised sa_flags riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 5/6] linux-user: Implement BLKPG ioctl riku.voipio
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

In lock_iovec() if lock_user() failed we were doing an unlock_user
but not a free(vec), which is the wrong way round. We were also
assuming that free() and unlock_user() don't touch errno, which
is not guaranteed. Fix both these problems.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f370087..bb3e4b1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1707,6 +1707,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
     struct iovec *vec;
     abi_ulong total_len, max_len;
     int i;
+    int err = 0;
 
     if (count == 0) {
         errno = 0;
@@ -1726,7 +1727,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
     target_vec = lock_user(VERIFY_READ, target_addr,
                            count * sizeof(struct target_iovec), 1);
     if (target_vec == NULL) {
-        errno = EFAULT;
+        err = EFAULT;
         goto fail2;
     }
 
@@ -1740,7 +1741,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
         abi_long len = tswapal(target_vec[i].iov_len);
 
         if (len < 0) {
-            errno = EINVAL;
+            err = EINVAL;
             goto fail;
         } else if (len == 0) {
             /* Zero length pointer is ignored.  */
@@ -1748,7 +1749,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
         } else {
             vec[i].iov_base = lock_user(type, base, len, copy);
             if (!vec[i].iov_base) {
-                errno = EFAULT;
+                err = EFAULT;
                 goto fail;
             }
             if (len > max_len - total_len) {
@@ -1763,9 +1764,10 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
     return vec;
 
  fail:
-    free(vec);
- fail2:
     unlock_user(target_vec, target_addr, 0);
+ fail2:
+    free(vec);
+    errno = err;
     return NULL;
 }
 
-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 5/6] linux-user: Implement BLKPG ioctl
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
                   ` (3 preceding siblings ...)
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 4/6] linux-user: Fix error handling in lock_iovec() riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 6/6] linux-user: Fix error handling in target_to_host_semarray() riku.voipio
  2014-02-21 14:32 ` [Qemu-devel] [PULL 0/6] linux-user updates Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber

From: Andreas Färber <afaerber@suse.de>

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/ioctls.h        |  1 +
 linux-user/syscall.c       |  1 +
 linux-user/syscall_defs.h  |  1 +
 linux-user/syscall_types.h | 13 +++++++++++++
 4 files changed, 16 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 7381012..309fb21 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -77,6 +77,7 @@
      IOCTL(BLKRAGET, IOC_R, MK_PTR(TYPE_LONG))
      IOCTL(BLKSSZGET, IOC_R, MK_PTR(TYPE_LONG))
      IOCTL(BLKBSZGET, IOC_R, MK_PTR(TYPE_INT))
+     IOCTL(BLKPG, IOC_W, MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg)))
 #ifdef FIBMAP
      IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bb3e4b1..8f5a58e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -107,6 +107,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <linux/reboot.h>
 #include <linux/route.h>
 #include <linux/filter.h>
+#include <linux/blkpg.h>
 #include "linux_loop.h"
 #include "cpu-uname.h"
 
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index ae30476..3c8869e 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -901,6 +901,7 @@ struct target_pollfd {
 #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
 #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
 #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
+#define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
 /* A jump here: 108-111 have been used for various private purposes. */
 #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
 #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 44b6a58..9d0c92d 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -240,3 +240,16 @@ STRUCT(fiemap,
        TYPE_INT, /* fm_mapped_extents */
        TYPE_INT, /* fm_extent_count */
        TYPE_INT) /* fm_reserved */
+
+STRUCT(blkpg_partition,
+       TYPE_LONGLONG, /* start */
+       TYPE_LONGLONG, /* length */
+       TYPE_INT, /* pno */
+       MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
+       MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
+
+STRUCT(blkpg_ioctl_arg,
+       TYPE_INT, /* op */
+       TYPE_INT, /* flags */
+       TYPE_INT, /* datalen */
+       MK_PTR(MK_STRUCT(STRUCT_blkpg_partition))) /* data */
-- 
1.8.1.2

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

* [Qemu-devel] [PATCH 6/6] linux-user: Fix error handling in target_to_host_semarray()
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
                   ` (4 preceding siblings ...)
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 5/6] linux-user: Implement BLKPG ioctl riku.voipio
@ 2014-02-19 10:35 ` riku.voipio
  2014-02-21 14:32 ` [Qemu-devel] [PULL 0/6] linux-user updates Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2014-02-19 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

Fix two issues in error handling in target_to_host_semarray():
 * don't leak the host_array buffer if lock_user fails
 * return an error if malloc() fails

v2: added missing * -Riku Voipio

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8f5a58e..1407b7a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2430,10 +2430,15 @@ static inline abi_long target_to_host_semarray(int semid, unsigned short **host_
     nsems = semid_ds.sem_nsems;
 
     *host_array = malloc(nsems*sizeof(unsigned short));
+    if (!*host_array) {
+        return -TARGET_ENOMEM;
+    }
     array = lock_user(VERIFY_READ, target_addr,
                       nsems*sizeof(unsigned short), 1);
-    if (!array)
+    if (!array) {
+        free(*host_array);
         return -TARGET_EFAULT;
+    }
 
     for(i=0; i<nsems; i++) {
         __get_user((*host_array)[i], &array[i]);
-- 
1.8.1.2

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

* Re: [Qemu-devel] [PULL 0/6] linux-user updates
  2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
                   ` (5 preceding siblings ...)
  2014-02-19 10:35 ` [Qemu-devel] [PATCH 6/6] linux-user: Fix error handling in target_to_host_semarray() riku.voipio
@ 2014-02-21 14:32 ` Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2014-02-21 14:32 UTC (permalink / raw)
  To: Riku Voipio; +Cc: QEMU Developers

On 19 February 2014 10:35,  <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The following changes since commit 46eef33b89e936ca793e13c4aeea1414e97e8dbb:
>
>   Fix QEMU build on OpenBSD on x86 archs (2014-02-17 11:44:00 +0000)
>
> are available in the git repository at:
>
>   git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream
>
> for you to fetch changes up to 69d4c703a549f0630793a67b16a8fc6bc14c8654:
>
>   linux-user: Fix error handling in target_to_host_semarray() (2014-02-19 12:29:23 +0200)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2014-02-21 14:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 10:35 [Qemu-devel] [PULL 0/6] linux-user updates riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 1/6] linux-user: sync syscall numbers upto 3.13 riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 2/6] linux-user/elfload.c: Avoid calling g_free() on uninitialized data riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 3/6] linux-user/signal.c: Don't pass sigaction uninitialised sa_flags riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 4/6] linux-user: Fix error handling in lock_iovec() riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 5/6] linux-user: Implement BLKPG ioctl riku.voipio
2014-02-19 10:35 ` [Qemu-devel] [PATCH 6/6] linux-user: Fix error handling in target_to_host_semarray() riku.voipio
2014-02-21 14:32 ` [Qemu-devel] [PULL 0/6] linux-user updates Peter Maydell

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).