From: Tejun Heo <tj@kernel.org>
To: James Bottomley <James.Bottomley@suse.de>,
Linux SCSI List <linux-scsi@vger.kernel.org>
Cc: stable@kernel.org
Subject: [PATCH] scsi: fix use-after-free in scsi_init_io()
Date: Mon, 16 Aug 2010 16:15:01 +0200 [thread overview]
Message-ID: <4C6947E5.2080208@kernel.org> (raw)
scsi_init_io() dereferences scsi_cmnd after putting it in the error
path leading to oops. Fix it.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@kernel.org
---
drivers/scsi/scsi_lib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: block/drivers/scsi/scsi_lib.c
===================================================================
--- block.orig/drivers/scsi/scsi_lib.c
+++ block/drivers/scsi/scsi_lib.c
@@ -968,7 +968,9 @@ static int scsi_init_sgtable(struct requ
*/
int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
{
+ struct request *req = cmd->request;
int error = scsi_init_sgtable(cmd->request, &cmd->sdb, gfp_mask);
+
if (error)
goto err_exit;
@@ -1012,7 +1014,7 @@ int scsi_init_io(struct scsi_cmnd *cmd,
err_exit:
scsi_release_buffers(cmd);
scsi_put_command(cmd);
- cmd->request->special = NULL;
+ req->special = NULL;
return error;
}
EXPORT_SYMBOL(scsi_init_io);
next reply other threads:[~2010-08-16 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 14:15 Tejun Heo [this message]
2010-08-16 15:06 ` [PATCH] scsi: fix use-after-free in scsi_init_io() James Bottomley
2010-08-16 15:04 ` Tejun Heo
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=4C6947E5.2080208@kernel.org \
--to=tj@kernel.org \
--cc=James.Bottomley@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=stable@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 NNTP newsgroup(s).