From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"dgilbert@interlog.com" <dgilbert@interlog.com>,
"dvyukov@google.com" <dvyukov@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"ben.hutchings@codethink.co.uk" <ben.hutchings@codethink.co.uk>
Cc: "syzkaller@googlegroups.com" <syzkaller@googlegroups.com>
Subject: Re: scsi: sg: assorted memory corruptions
Date: Mon, 22 Jan 2018 16:30:35 +0000 [thread overview]
Message-ID: <1516638634.2545.0.camel@wdc.com> (raw)
In-Reply-To: <CACT4Y+b0pizvOAxtWQ-TGCRAYvHXdv79BAEaXh50W6vF8gBvkQ@mail.gmail.com>
On Mon, 2018-01-22 at 12:06 +0100, Dmitry Vyukov wrote:
> general protection fault: 0000 [#1] SMP KASAN
How about the untested patch below?
Thanks,
Bart.
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cd9b6ebd7257..04a644b39d79 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -627,6 +627,10 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
mutex_unlock(&sfp->f_mutex);
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
"sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
+ if (cmd_size > sizeof(cmnd)) {
+ sg_remove_request(sfp, srp);
+ return -EFAULT;
+ }
/* Determine buffer size. */
input_size = count - cmd_size;
mxsize = max(input_size, old_hdr.reply_len);
next prev parent reply other threads:[~2018-01-22 16:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 11:06 scsi: sg: assorted memory corruptions Dmitry Vyukov
2018-01-22 16:30 ` Bart Van Assche [this message]
2018-01-22 18:57 ` Douglas Gilbert
2018-01-22 19:06 ` Dmitry Vyukov
2018-01-22 19:13 ` Bart Van Assche
2018-01-30 12:22 ` Dmitry Vyukov
2018-02-01 6:03 ` Douglas Gilbert
2018-02-01 7:04 ` Dmitry Vyukov
2018-02-01 16:17 ` Ben Hutchings
2018-02-01 16:21 ` Dmitry Vyukov
2018-02-04 9:07 ` Eric Biggers
2018-02-04 11:10 ` Dmitry Vyukov
2018-02-10 19:13 ` Eric Biggers
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=1516638634.2545.0.camel@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=ben.hutchings@codethink.co.uk \
--cc=dgilbert@interlog.com \
--cc=dvyukov@google.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=syzkaller@googlegroups.com \
/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