* [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems
@ 2016-07-04 16:06 Peter Maydell
2016-07-04 16:06 ` [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peter Maydell @ 2016-07-04 16:06 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Riku Voipio, Chanho Park, Chanho Park
This patchset fixes a couple of ioctl bugs which were
causing problems with running kpartx:
(1) add the missing ioctls for the loop-control device
(2) fix the BLKSSZGET ioctl not to trash memory on
64-bit guests
Peter Maydell (2):
linux-user: Add loop control ioctls
linux-user: Correct type for BLKSSZGET
linux-user/ioctls.h | 6 +++++-
linux-user/linux_loop.h | 11 ++++++++++-
linux-user/syscall_defs.h | 4 ++++
3 files changed, 19 insertions(+), 2 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls
2016-07-04 16:06 [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Peter Maydell
@ 2016-07-04 16:06 ` Peter Maydell
2016-07-05 7:45 ` Laurent Vivier
2016-07-04 16:06 ` [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET Peter Maydell
2016-07-05 1:17 ` [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Chanho Park
2 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2016-07-04 16:06 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Riku Voipio, Chanho Park, Chanho Park
Add support for the /dev/loop-control ioctls:
LOOP_CTL_ADD
LOOP_CTL_REMOVE
LOOP_CTL_GET_FREE
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/ioctls.h | 4 ++++
linux-user/linux_loop.h | 11 ++++++++++-
linux-user/syscall_defs.h | 4 ++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 804f099..72cd32a 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -356,6 +356,10 @@
IOCTL(LOOP_GET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64)))
IOCTL(LOOP_CHANGE_FD, 0, TYPE_INT)
+ IOCTL(LOOP_CTL_ADD, 0, TYPE_INT)
+ IOCTL(LOOP_CTL_REMOVE, 0, TYPE_INT)
+ IOCTL(LOOP_CTL_GET_FREE, 0, TYPE_NULL)
+
IOCTL(MTIOCTOP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_mtop)))
IOCTL(MTIOCGET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtget)))
IOCTL(MTIOCPOS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtpos)))
diff --git a/linux-user/linux_loop.h b/linux-user/linux_loop.h
index 8974caa..fd7608b 100644
--- a/linux-user/linux_loop.h
+++ b/linux-user/linux_loop.h
@@ -1,4 +1,6 @@
-/* Copied from 2.6.25 kernel headers to avoid problems on older hosts. */
+/* Copied from 2.6.25 kernel headers to avoid problems on older hosts,
+ * and subsequently updated to match newer additions to the API.
+ */
#ifndef _LINUX_LOOP_H
#define _LINUX_LOOP_H
@@ -91,5 +93,12 @@ struct loop_info64 {
#define LOOP_SET_STATUS64 0x4C04
#define LOOP_GET_STATUS64 0x4C05
#define LOOP_CHANGE_FD 0x4C06
+#define LOOP_SET_CAPACITY 0x4C07
+#define LOOP_SET_DIRECT_IO 0x4C08
+
+/* /dev/loop-control interface */
+#define LOOP_CTL_ADD 0x4C80
+#define LOOP_CTL_REMOVE 0x4C81
+#define LOOP_CTL_GET_FREE 0x4C82
#endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 6650e26..0591abc 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1129,6 +1129,10 @@ struct target_pollfd {
#define TARGET_LOOP_GET_STATUS64 0x4C05
#define TARGET_LOOP_CHANGE_FD 0x4C06
+#define TARGET_LOOP_CTL_ADD 0x4C80
+#define TARGET_LOOP_CTL_REMOVE 0x4C81
+#define TARGET_LOOP_CTL_GET_FREE 0x4C82
+
/* fb ioctls */
#define TARGET_FBIOGET_VSCREENINFO 0x4600
#define TARGET_FBIOPUT_VSCREENINFO 0x4601
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET
2016-07-04 16:06 [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Peter Maydell
2016-07-04 16:06 ` [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls Peter Maydell
@ 2016-07-04 16:06 ` Peter Maydell
2016-07-04 16:17 ` Laurent Vivier
2016-07-05 1:17 ` [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Chanho Park
2 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2016-07-04 16:06 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Riku Voipio, Chanho Park, Chanho Park
The BLKSSZGET ioctl takes an argument which is a pointer to an int.
We were incorrectly declaring it to take a pointer to a long, which
meant that we would incorrectly write to memory which we should not
if the guest is a 64-bit architecture.
In particular, kpartx uses this ioctl to write to an int on the
stack, which tends to result in it crashing immediately.
Reported-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/ioctls.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 72cd32a..8978eb3 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -76,7 +76,7 @@
IOCTL(BLKFLSBUF, 0, TYPE_NULL)
IOCTL(BLKRASET, 0, TYPE_INT)
IOCTL(BLKRAGET, IOC_R, MK_PTR(TYPE_LONG))
- IOCTL(BLKSSZGET, IOC_R, MK_PTR(TYPE_LONG))
+ IOCTL(BLKSSZGET, IOC_R, MK_PTR(TYPE_INT))
IOCTL(BLKBSZGET, IOC_R, MK_PTR(TYPE_INT))
IOCTL_SPECIAL(BLKPG, IOC_W, do_ioctl_blkpg,
MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg)))
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET
2016-07-04 16:06 ` [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET Peter Maydell
@ 2016-07-04 16:17 ` Laurent Vivier
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2016-07-04 16:17 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Chanho Park, Riku Voipio, Chanho Park, patches
Le 04/07/2016 à 18:06, Peter Maydell a écrit :
> The BLKSSZGET ioctl takes an argument which is a pointer to an int.
> We were incorrectly declaring it to take a pointer to a long, which
> meant that we would incorrectly write to memory which we should not
> if the guest is a 64-bit architecture.
>
> In particular, kpartx uses this ioctl to write to an int on the
> stack, which tends to result in it crashing immediately.
>
> Reported-by: Chanho Park <chanho61.park@samsung.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/ioctls.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
> index 72cd32a..8978eb3 100644
> --- a/linux-user/ioctls.h
> +++ b/linux-user/ioctls.h
> @@ -76,7 +76,7 @@
> IOCTL(BLKFLSBUF, 0, TYPE_NULL)
> IOCTL(BLKRASET, 0, TYPE_INT)
> IOCTL(BLKRAGET, IOC_R, MK_PTR(TYPE_LONG))
> - IOCTL(BLKSSZGET, IOC_R, MK_PTR(TYPE_LONG))
> + IOCTL(BLKSSZGET, IOC_R, MK_PTR(TYPE_INT))
> IOCTL(BLKBSZGET, IOC_R, MK_PTR(TYPE_INT))
> IOCTL_SPECIAL(BLKPG, IOC_W, do_ioctl_blkpg,
> MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg)))
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems
2016-07-04 16:06 [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Peter Maydell
2016-07-04 16:06 ` [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls Peter Maydell
2016-07-04 16:06 ` [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET Peter Maydell
@ 2016-07-05 1:17 ` Chanho Park
2 siblings, 0 replies; 6+ messages in thread
From: Chanho Park @ 2016-07-05 1:17 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches, Riku Voipio, Chanho Park
Hi Peter,
On Tuesday, July 5, 2016, Peter Maydell <peter.maydell@linaro.org> wrote:
> This patchset fixes a couple of ioctl bugs which were
> causing problems with running kpartx:
> (1) add the missing ioctls for the loop-control device
> (2) fix the BLKSSZGET ioctl not to trash memory on
> 64-bit guests
>
> Peter Maydell (2):
> linux-user: Add loop control ioctls
> linux-user: Correct type for BLKSSZGET
>
> linux-user/ioctls.h | 6 +++++-
> linux-user/linux_loop.h | 11 ++++++++++-
> linux-user/syscall_defs.h | 4 ++++
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> --
> 1.9.1
>
>
I've verified it's fixed and kpartx is working well.
Tested-by: Chanho Park <parkch98@gmail.com>
--
Best Regards,
Chanho Park
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls
2016-07-04 16:06 ` [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls Peter Maydell
@ 2016-07-05 7:45 ` Laurent Vivier
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2016-07-05 7:45 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Chanho Park, Riku Voipio, Chanho Park, patches
Le 04/07/2016 à 18:06, Peter Maydell a écrit :
> Add support for the /dev/loop-control ioctls:
> LOOP_CTL_ADD
> LOOP_CTL_REMOVE
> LOOP_CTL_GET_FREE
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/ioctls.h | 4 ++++
> linux-user/linux_loop.h | 11 ++++++++++-
> linux-user/syscall_defs.h | 4 ++++
> 3 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
> index 804f099..72cd32a 100644
> --- a/linux-user/ioctls.h
> +++ b/linux-user/ioctls.h
> @@ -356,6 +356,10 @@
> IOCTL(LOOP_GET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64)))
> IOCTL(LOOP_CHANGE_FD, 0, TYPE_INT)
>
> + IOCTL(LOOP_CTL_ADD, 0, TYPE_INT)
> + IOCTL(LOOP_CTL_REMOVE, 0, TYPE_INT)
> + IOCTL(LOOP_CTL_GET_FREE, 0, TYPE_NULL)
> +
> IOCTL(MTIOCTOP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_mtop)))
> IOCTL(MTIOCGET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtget)))
> IOCTL(MTIOCPOS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtpos)))
> diff --git a/linux-user/linux_loop.h b/linux-user/linux_loop.h
> index 8974caa..fd7608b 100644
> --- a/linux-user/linux_loop.h
> +++ b/linux-user/linux_loop.h
> @@ -1,4 +1,6 @@
> -/* Copied from 2.6.25 kernel headers to avoid problems on older hosts. */
> +/* Copied from 2.6.25 kernel headers to avoid problems on older hosts,
> + * and subsequently updated to match newer additions to the API.
> + */
> #ifndef _LINUX_LOOP_H
> #define _LINUX_LOOP_H
>
> @@ -91,5 +93,12 @@ struct loop_info64 {
> #define LOOP_SET_STATUS64 0x4C04
> #define LOOP_GET_STATUS64 0x4C05
> #define LOOP_CHANGE_FD 0x4C06
> +#define LOOP_SET_CAPACITY 0x4C07
> +#define LOOP_SET_DIRECT_IO 0x4C08
> +
> +/* /dev/loop-control interface */
> +#define LOOP_CTL_ADD 0x4C80
> +#define LOOP_CTL_REMOVE 0x4C81
> +#define LOOP_CTL_GET_FREE 0x4C82
>
> #endif
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 6650e26..0591abc 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -1129,6 +1129,10 @@ struct target_pollfd {
> #define TARGET_LOOP_GET_STATUS64 0x4C05
> #define TARGET_LOOP_CHANGE_FD 0x4C06
>
> +#define TARGET_LOOP_CTL_ADD 0x4C80
> +#define TARGET_LOOP_CTL_REMOVE 0x4C81
> +#define TARGET_LOOP_CTL_GET_FREE 0x4C82
> +
> /* fb ioctls */
> #define TARGET_FBIOGET_VSCREENINFO 0x4600
> #define TARGET_FBIOPUT_VSCREENINFO 0x4601
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-05 7:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 16:06 [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Peter Maydell
2016-07-04 16:06 ` [Qemu-devel] [PATCH 1/2] linux-user: Add loop control ioctls Peter Maydell
2016-07-05 7:45 ` Laurent Vivier
2016-07-04 16:06 ` [Qemu-devel] [PATCH 2/2] linux-user: Correct type for BLKSSZGET Peter Maydell
2016-07-04 16:17 ` Laurent Vivier
2016-07-05 1:17 ` [Qemu-devel] [PATCH 0/2] linux-user: fix kpartx ioctl problems Chanho Park
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.