From: Douglas Gilbert <dgilbert@interlog.com>
To: Hannes Reinecke <hare@suse.de>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org,
Alexander Potapenko <glider@google.com>,
Ingo Molnar <mingo@redhat.com>,
Dmitry Vyukov <dvyukov@google.com>,
security@kernel.org, Hannes Reinecke <hare@suse.com>
Subject: Re: [PATCH 1/2] sg: factor out sg_fill_request_table()
Date: Fri, 15 Sep 2017 15:44:21 -0400 [thread overview]
Message-ID: <0d09af9d-3a82-e6b0-3707-c184b9f72331@interlog.com> (raw)
In-Reply-To: <1505477116-75013-2-git-send-email-hare@suse.de>
On 2017-09-15 08:05 AM, Hannes Reinecke wrote:
> Factor our sg_fill_request_table() for better readability.
>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Thanks.
> ---
> drivers/scsi/sg.c | 62 ++++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 36 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 03194c4..f1e20ca0 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -857,6 +857,40 @@ static int max_sectors_bytes(struct request_queue *q)
> return max_sectors << 9;
> }
>
> +static void
> +sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
> +{
> + Sg_request *srp;
> + int val;
> + unsigned int ms;
> +
> + val = 0;
> + list_for_each_entry(srp, &sfp->rq_list, entry) {
> + if (val > SG_MAX_QUEUE)
> + break;
> + memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
> + rinfo[val].req_state = srp->done + 1;
> + rinfo[val].problem =
> + srp->header.masked_status &
> + srp->header.host_status &
> + srp->header.driver_status;
> + if (srp->done)
> + rinfo[val].duration =
> + srp->header.duration;
> + else {
> + ms = jiffies_to_msecs(jiffies);
> + rinfo[val].duration =
> + (ms > srp->header.duration) ?
> + (ms - srp->header.duration) : 0;
> + }
> + rinfo[val].orphan = srp->orphan;
> + rinfo[val].sg_io_owned = srp->sg_io_owned;
> + rinfo[val].pack_id = srp->header.pack_id;
> + rinfo[val].usr_ptr = srp->header.usr_ptr;
> + val++;
> + }
> +}
> +
> static long
> sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
> {
> @@ -1041,39 +1075,15 @@ static int max_sectors_bytes(struct request_queue *q)
> return -EFAULT;
> else {
> sg_req_info_t *rinfo;
> - unsigned int ms;
>
> rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
> GFP_KERNEL);
> if (!rinfo)
> return -ENOMEM;
> read_lock_irqsave(&sfp->rq_list_lock, iflags);
> - val = 0;
> - list_for_each_entry(srp, &sfp->rq_list, entry) {
> - if (val > SG_MAX_QUEUE)
> - break;
> - memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
> - rinfo[val].req_state = srp->done + 1;
> - rinfo[val].problem =
> - srp->header.masked_status &
> - srp->header.host_status &
> - srp->header.driver_status;
> - if (srp->done)
> - rinfo[val].duration =
> - srp->header.duration;
> - else {
> - ms = jiffies_to_msecs(jiffies);
> - rinfo[val].duration =
> - (ms > srp->header.duration) ?
> - (ms - srp->header.duration) : 0;
> - }
> - rinfo[val].orphan = srp->orphan;
> - rinfo[val].sg_io_owned = srp->sg_io_owned;
> - rinfo[val].pack_id = srp->header.pack_id;
> - rinfo[val].usr_ptr = srp->header.usr_ptr;
> - val++;
> - }
> + sg_fill_request_table(sfp, rinfo);
> read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
> +
> result = __copy_to_user(p, rinfo,
> SZ_SG_REQ_INFO * SG_MAX_QUEUE);
> result = result ? -EFAULT : 0;
>
next prev parent reply other threads:[~2017-09-15 19:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 12:05 [PATCH 0/2] sg: fix infoleak when using SG_GET_REQUEST_TABLE Hannes Reinecke
2017-09-15 12:05 ` [PATCH 1/2] sg: factor out sg_fill_request_table() Hannes Reinecke
2017-09-15 14:26 ` Bart Van Assche
2017-09-15 17:54 ` Christoph Hellwig
2017-09-15 19:24 ` Martin K. Petersen
2017-09-15 19:44 ` Douglas Gilbert [this message]
2017-09-15 12:05 ` [PATCH 2/2] sg: fixup infoleak when using SG_GET_REQUEST_TABLE Hannes Reinecke
2017-09-15 14:29 ` Bart Van Assche
2017-09-15 17:54 ` Christoph Hellwig
2017-09-15 18:03 ` Eric Dumazet
2017-09-15 18:49 ` Linus Torvalds
2017-09-15 19:24 ` Martin K. Petersen
2017-09-15 19:44 ` Douglas Gilbert
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=0d09af9d-3a82-e6b0-3707-c184b9f72331@interlog.com \
--to=dgilbert@interlog.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hare@suse.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mingo@redhat.com \
--cc=security@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