From: Andy Grover <agrover@redhat.com>
To: stgt@vger.kernel.org
Subject: [PATCH] Fix segfault if device_type set to pt but bstype not sg or bsg
Date: Tue, 18 Mar 2014 11:02:02 -0700 [thread overview]
Message-ID: <1395165722-25402-1-git-send-email-agrover@redhat.com> (raw)
If bstype not set to sg or bsg, it will default to rdwr, and we will
call target_cmd_perform instead of target_cmd_perform_passthrough when
accessing the device, which crashes tgtd. There's an existing check for
setting bstype without setting dev_type, but also add a check the other
way, setting dev_type without setting bstype to a valid value for pt.
Add an error message to the existing check, as well.
Signed-off-by: Andy Grover <agrover@redhat.com>
---
usr/target.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/usr/target.c b/usr/target.c
index 0f3066b..6dce46b 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -547,6 +547,16 @@ tgtadm_err tgt_device_create(int tid, int dev_type, uint64_t lun, char *params,
if ((!strncmp(bst->bs_name, "bsg", 3) ||
!strncmp(bst->bs_name, "sg", 2)) &&
dev_type != TYPE_PT) {
+ eprintf("Must set device type to pt for bsg/sg bstype\n");
+ adm_err = TGTADM_INVALID_REQUEST;
+ goto out;
+ }
+
+ if (!(!strncmp(bst->bs_name, "bsg", 3) ||
+ !strncmp(bst->bs_name, "sg", 2)) &&
+ dev_type == TYPE_PT) {
+ eprintf("Must set bstype to bsg or sg for devicetype pt, not %s\n",
+ bst->bs_name);
adm_err = TGTADM_INVALID_REQUEST;
goto out;
}
--
1.8.5.3
next reply other threads:[~2014-03-18 18:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 18:02 Andy Grover [this message]
2014-03-22 11:57 ` [PATCH] Fix segfault if device_type set to pt but bstype not sg or bsg FUJITA Tomonori
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=1395165722-25402-1-git-send-email-agrover@redhat.com \
--to=agrover@redhat.com \
--cc=stgt@vger.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).