public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix blktrace setup 32-bit ioctl on 64-bit kernels
@ 2007-10-02  7:39 Jens Axboe
  2007-10-02  7:52 ` David Miller
  2007-10-02  8:15 ` Arnd Bergmann
  0 siblings, 2 replies; 14+ messages in thread
From: Jens Axboe @ 2007-10-02  7:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: abhishekrai, Linus Torvalds

Hi,

The layout of struct blk_user_trace_setup is a bit unfortunate, it gets
padded differently on 32-bit and 64-bit archs. So right now it's not
possible to trace 64-bit kernels with a 32-bit app. This patch fixes
that up by adding a compat ioctl handler for BLKTRACESETUP.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 5a5b711..b18b9cc 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -2052,6 +2052,51 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
         }
         return ret;
 }
+
+struct blk_user_trace_setup32 {
+	char name[32];
+	u16 act_mask;
+	u16 pad;
+	u32 buf_size;
+	u32 buf_nr;
+	u64 start_lba;
+	u64 end_lba;
+	u32 pid;
+} __attribute__((packed));
+
+#define BLKTRACESETUP32 _IOWR(0x12,115,struct blk_user_trace_setup32)
+
+static int blktrace32_setup(int fd, unsigned cmd, unsigned long arg)
+{
+	struct blk_user_trace_setup __user *buts = compat_alloc_user_space(sizeof(*buts));
+	struct blk_user_trace_setup32 __user *buts32 = compat_ptr(arg);
+	int err;
+
+	if (copy_in_user(&buts->name, &buts32->name, BDEVNAME_SIZE) ||
+	    get_user(buts->act_mask, &buts32->act_mask) ||
+	    get_user(buts->buf_size, &buts32->buf_size) ||
+	    get_user(buts->buf_nr, &buts32->buf_nr) ||
+	    get_user(buts->start_lba, &buts32->start_lba) ||
+	    get_user(buts->end_lba, &buts32->end_lba) ||
+	    get_user(buts->pid, &buts32->pid))
+		return -EFAULT;
+
+	err = sys_ioctl(fd, BLKTRACESETUP, (unsigned long) buts);
+	if (err)
+		return err;
+
+	if (copy_to_user(&buts32->name, &buts->name, BDEVNAME_SIZE) ||
+	    put_user(buts32->act_mask, &buts->act_mask) ||
+	    put_user(buts32->buf_size, &buts->buf_size) ||
+	    put_user(buts32->buf_nr, &buts->buf_nr) ||
+	    put_user(buts32->start_lba, &buts->start_lba) ||
+	    put_user(buts32->end_lba, &buts->end_lba) ||
+	    put_user(buts32->pid, &buts->pid))
+		return -EFAULT;
+
+	return err;
+}
+
 #endif /* CONFIG_BLOCK */
 
 struct serial_struct32 {
@@ -2555,7 +2600,7 @@ COMPATIBLE_IOCTL(BLKSECTSET)
 COMPATIBLE_IOCTL(BLKSSZGET)
 COMPATIBLE_IOCTL(BLKTRACESTART)
 COMPATIBLE_IOCTL(BLKTRACESTOP)
-COMPATIBLE_IOCTL(BLKTRACESETUP)
+HANDLE_IOCTL(BLKTRACESETUP32, blktrace32_setup)
 COMPATIBLE_IOCTL(BLKTRACETEARDOWN)
 ULONG_IOCTL(BLKRASET)
 ULONG_IOCTL(BLKFRASET)

-- 
Jens Axboe


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

end of thread, other threads:[~2007-10-05 12:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-02  7:39 [PATCH] Fix blktrace setup 32-bit ioctl on 64-bit kernels Jens Axboe
2007-10-02  7:52 ` David Miller
2007-10-02  8:15 ` Arnd Bergmann
2007-10-02  8:37   ` Jens Axboe
2007-10-02  9:28     ` Jens Axboe
2007-10-03  9:34       ` Arnd Bergmann
2007-10-03 15:55       ` Arnd Bergmann
2007-10-03 22:48         ` Arnd Bergmann
2007-10-04 18:16           ` Jens Axboe
2007-10-04 18:44             ` Arnd Bergmann
2007-10-05 10:41               ` Jens Axboe
2007-10-05 12:30                 ` [PATCH] block: move ioctl conversion to compat_blkdev_ioctl Arnd Bergmann
2007-10-05 12:41                   ` Jens Axboe
2007-10-05 12:41                     ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox