From: Gen Zhang <blackgod016574@gmail.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: dgilbert@interlog.com, jejb@linux.ibm.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sg: fix a double-fetch bug in sg_write()
Date: Wed, 5 Jun 2019 23:35:32 +0800 [thread overview]
Message-ID: <20190605153532.GA4051@zhanggen-UX430UQ> (raw)
In-Reply-To: <38bbd54f-d85b-e529-36ad-5c1809bb435f@suse.cz>
On Wed, Jun 05, 2019 at 08:41:11AM +0200, Jiri Slaby wrote:
> On 31. 05. 19, 3:27, Gen Zhang wrote:
> > In sg_write(), the opcode of the command is fetched the first time from
> > the userspace by __get_user(). Then the whole command, the opcode
> > included, is fetched again from userspace by __copy_from_user().
> > However, a malicious user can change the opcode between the two fetches.
> > This can cause inconsistent data and potential errors as cmnd is used in
> > the following codes.
> >
> > Thus we should check opcode between the two fetches to prevent this.
> >
> > Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> > ---
> > diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> > index d3f1531..a2971b8 100644
> > --- a/drivers/scsi/sg.c
> > +++ b/drivers/scsi/sg.c
> > @@ -694,6 +694,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
> > hp->flags = input_size; /* structure abuse ... */
> > hp->pack_id = old_hdr.pack_id;
> > hp->usr_ptr = NULL;
> > + if (opcode != cmnd[0])
> > + return -EINVAL;
> > if (__copy_from_user(cmnd, buf, cmd_size))
> > return -EFAULT;
>
> You are sending the same patches like a broken machine. Please STOP this
> and give people some time to actually review your patches! (Don't expect
> replies in days.)
>
Thanks for your reply. I resubmitted this one after 8-day-no-reply. I
don't judge whether this is a short time period or not. I politely hope
that you can reply more kindly.
I am just a PhD candidate. All I did is submitting patches, discussing
with maintainers in accordance with linux community rules for academic papers.
I guess that you might be busy person and hope that submitting patches
didn't bother you.
Thanks
Gen
> I already commented on this apparently broken one earlier...
>
> thanks,
> --
> js
> suse labs
next prev parent reply other threads:[~2019-06-05 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 1:27 [PATCH] sg: fix a double-fetch bug in sg_write() Gen Zhang
2019-06-05 6:41 ` Jiri Slaby
2019-06-05 15:35 ` Gen Zhang [this message]
2019-06-06 5:01 ` Jiri Slaby
2019-06-06 7:43 ` Gen Zhang
-- strict thread matches above, loose matches on Subject: below --
2019-05-27 1:03 Gen Zhang
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=20190605153532.GA4051@zhanggen-UX430UQ \
--to=blackgod016574@gmail.com \
--cc=dgilbert@interlog.com \
--cc=jejb@linux.ibm.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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