From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, msnitzer@redhat.com, ksievers@redhat.com,
jbottomley@parallels.com, axboe@kernel.dk,
linux-scsi@vger.kernel.org
Subject: [RFC PATCH 2/4] scsi: create an all-zero filter for scanners
Date: Mon, 27 May 2013 15:50:20 +0200 [thread overview]
Message-ID: <1369662622-5959-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1369662622-5959-1-git-send-email-pbonzini@redhat.com>
Using /dev/sg for scanners is blocked from unprivileged users. Reimplement
this using customizable command filters, so that the sysfs knobs will work
in this case too.
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
drivers/scsi/scsi_scan.c | 8 +++++++-
drivers/scsi/sg.c | 3 ---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 3e58b22..de5751b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -783,13 +783,19 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
}
switch (sdev->type) {
+ case TYPE_SCANNER:
+ sdev->request_queue->cmd_filter =
+ kzalloc(sizeof(struct blk_cmd_filter), GFP_ATOMIC);
+ if (sdev->request_queue->cmd_filter == NULL)
+ return SCSI_SCAN_NO_RESPONSE;
+ /* fallthrough */
+
case TYPE_RBC:
case TYPE_TAPE:
case TYPE_DISK:
case TYPE_PRINTER:
case TYPE_MOD:
case TYPE_PROCESSOR:
- case TYPE_SCANNER:
case TYPE_MEDIUM_CHANGER:
case TYPE_ENCLOSURE:
case TYPE_COMM:
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 5f64202..f7f5c11 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -220,9 +220,6 @@ static int sg_allow_access(struct file *filp, unsigned char *cmd)
struct sg_fd *sfp = filp->private_data;
struct request_queue *q = sfp->parentdp->device->request_queue;
- if (sfp->parentdp->device->type == TYPE_SCANNER)
- return 0;
-
return blk_verify_command(q->cmd_filter,
cmd, filp->f_mode & FMODE_WRITE);
}
--
1.8.1.4
next prev parent reply other threads:[~2013-05-27 13:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-27 13:50 [RFC PATCH 0/4] SG_IO filtering via sysfs and minimal whitelist Paolo Bonzini
2013-05-27 13:50 ` [RFC PATCH 1/4] block: add back queue-private command filter Paolo Bonzini
2013-05-27 13:50 ` Paolo Bonzini [this message]
2013-05-27 13:50 ` [RFC PATCH 3/4] block: add back command filter modification via sysfs Paolo Bonzini
2013-05-27 13:50 ` [RFC PATCH 4/4] scsi: lock out SG_IO by default to unprivileged users Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369662622-5959-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=axboe@kernel.dk \
--cc=jbottomley@parallels.com \
--cc=ksievers@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=msnitzer@redhat.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®