public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] block: export blk_verify_command for SG v4
@ 2006-12-15 15:18 FUJITA Tomonori
  2007-01-02 11:49 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: FUJITA Tomonori @ 2006-12-15 15:18 UTC (permalink / raw)
  To: linux-scsi; +Cc: dougg, jens.axboe

blk_fill_sghdr_rq doesn't work for SG v4 so verify_command needed to
be exported.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

---
 block/scsi_ioctl.c     |    7 ++++---
 include/linux/blkdev.h |    1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index e74f807..751f32b 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -110,7 +110,7 @@ #define CMD_WARNED	0x04
 #define safe_for_read(cmd)	[cmd] = CMD_READ_SAFE
 #define safe_for_write(cmd)	[cmd] = CMD_WRITE_SAFE
 
-static int verify_command(unsigned char *cmd, int has_write_perm)
+int blk_verify_command(unsigned char *cmd, int has_write_perm)
 {
 	static unsigned char cmd_type[256] = {
 
@@ -210,6 +210,7 @@ static int verify_command(unsigned char 
 	/* Otherwise fail it with an "Operation not permitted" */
 	return -EPERM;
 }
+EXPORT_SYMBOL_GPL(blk_verify_command);
 
 int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq,
 		      struct sg_io_hdr *hdr, int has_write_perm)
@@ -218,7 +219,7 @@ int blk_fill_sghdr_rq(request_queue_t *q
 
 	if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
 		return -EFAULT;
-	if (verify_command(rq->cmd, has_write_perm))
+	if (blk_verify_command(rq->cmd, has_write_perm))
 		return -EPERM;
 
 	/*
@@ -456,7 +457,7 @@ int sg_scsi_ioctl(struct file *file, str
 	if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
 		goto error;
 
-	err = verify_command(rq->cmd, file->f_mode & FMODE_WRITE);
+	err = blk_verify_command(rq->cmd, file->f_mode & FMODE_WRITE);
 	if (err)
 		goto error;
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 28ee679..492dc96 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -694,6 +694,7 @@ extern int blk_fill_sghdr_rq(request_que
 extern int blk_unmap_sghdr_rq(struct request *, struct sg_io_hdr *);
 extern int blk_complete_sghdr_rq(struct request *, struct sg_io_hdr *,
 			  struct bio *);
+extern int blk_verify_command(unsigned char *, int);
 
 static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
 {
-- 
1.4.1.1



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

* Re: [PATCH 1/3] block: export blk_verify_command for SG v4
  2006-12-15 15:18 [PATCH 1/3] block: export blk_verify_command for SG v4 FUJITA Tomonori
@ 2007-01-02 11:49 ` Christoph Hellwig
  2007-01-02 15:02   ` FUJITA Tomonori
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2007-01-02 11:49 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: linux-scsi, dougg, jens.axboe

On Sat, Dec 16, 2006 at 12:18:23AM +0900, FUJITA Tomonori wrote:
> blk_fill_sghdr_rq doesn't work for SG v4 so verify_command needed to
> be exported.

So fixup blk_fill_sghdr_rq to deal with SG v4 aswell.  We really
need to support all SGv4 features in the core code - bsg should
only be a small wrapper around core functionality at the end.

And while you're touching this code, is there any chance you could
unifity the command permission tables for the block layer code and
the sg driver?  This has been long overdue.

doug has a nice document somewhere that documents the differences
between command allowances for the block layer vs the sg driver.
Please go through these and take the more resonable version for
each command.


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

* Re: [PATCH 1/3] block: export blk_verify_command for SG v4
  2007-01-02 11:49 ` Christoph Hellwig
@ 2007-01-02 15:02   ` FUJITA Tomonori
  2007-01-02 15:20     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: FUJITA Tomonori @ 2007-01-02 15:02 UTC (permalink / raw)
  To: hch; +Cc: fujita.tomonori, linux-scsi, dougg, jens.axboe

From: Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH 1/3] block: export blk_verify_command for SG v4
Date: Tue, 2 Jan 2007 11:49:16 +0000

> On Sat, Dec 16, 2006 at 12:18:23AM +0900, FUJITA Tomonori wrote:
> > blk_fill_sghdr_rq doesn't work for SG v4 so verify_command needed to
> > be exported.
> 
> So fixup blk_fill_sghdr_rq to deal with SG v4 aswell.  We really
> need to support all SGv4 features in the core code - bsg should
> only be a small wrapper around core functionality at the end.

Should blk_fill_sghdr_rq take cmd pointer, cmd_len, timeout, etc
instead of sg_io_hdr structure?


> And while you're touching this code, is there any chance you could
> unifity the command permission tables for the block layer code and
> the sg driver?  This has been long overdue.

No problem.

You refer to unifying allow_ops in drivers/scsi/sg.c and
blk_verify_command in block/scsi_ioctl.c, right?


> doug has a nice document somewhere that documents the differences
> between command allowances for the block layer vs the sg driver.
> Please go through these and take the more resonable version for
> each command.

SCSI command permissions:

http://sg.torque.net/sg/sg_io.html

You mean that the sg driver and the block layer code share the same
tables (might break some user-space code)?

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

* Re: [PATCH 1/3] block: export blk_verify_command for SG v4
  2007-01-02 15:02   ` FUJITA Tomonori
@ 2007-01-02 15:20     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2007-01-02 15:20 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: hch, linux-scsi, dougg, jens.axboe

On Wed, Jan 03, 2007 at 12:02:20AM +0900, FUJITA Tomonori wrote:
> > > blk_fill_sghdr_rq doesn't work for SG v4 so verify_command needed to
> > > be exported.
> > 
> > So fixup blk_fill_sghdr_rq to deal with SG v4 aswell.  We really
> > need to support all SGv4 features in the core code - bsg should
> > only be a small wrapper around core functionality at the end.
> 
> Should blk_fill_sghdr_rq take cmd pointer, cmd_len, timeout, etc
> instead of sg_io_hdr structure?


Yes, that's what I meant.  But now that I actually took a look at
blk_fill_sghdr_rq again that doesn't make a lot of sense anymore :)

We probably should have blk_fill_sghdrv3_rq and blk_fill_sghdrv4_rq
in core code instead.

> > And while you're touching this code, is there any chance you could
> > unifity the command permission tables for the block layer code and
> > the sg driver?  This has been long overdue.
> 
> No problem.
> 
> You refer to unifying allow_ops in drivers/scsi/sg.c and
> blk_verify_command in block/scsi_ioctl.c, right?

Yes.

> > doug has a nice document somewhere that documents the differences
> > between command allowances for the block layer vs the sg driver.
> > Please go through these and take the more resonable version for
> > each command.
> 
> SCSI command permissions:
> 
> http://sg.torque.net/sg/sg_io.html

Exactly, that one.

> You mean that the sg driver and the block layer code share the same
> tables (might break some user-space code)?

I don't really see it that way.  Eiter the more relaxed of the two
permissions was wrong in which case we need to fix.  Or it was okay
and we should support it generally.

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

end of thread, other threads:[~2007-01-02 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-15 15:18 [PATCH 1/3] block: export blk_verify_command for SG v4 FUJITA Tomonori
2007-01-02 11:49 ` Christoph Hellwig
2007-01-02 15:02   ` FUJITA Tomonori
2007-01-02 15:20     ` Christoph Hellwig

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