* [PATCH 2/2] Return the result from user admin command IOCTL even in case of failure
@ 2013-02-28 19:49 Chayan Biswas
2013-03-01 22:05 ` [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX Keith Busch
0 siblings, 1 reply; 4+ messages in thread
From: Chayan Biswas @ 2013-02-28 19:49 UTC (permalink / raw)
We copy the result to user irrespective of the completion status of
the user Admin command. The user application may expect the error
code in the result field in case of failure.
Signed-off-by: Chayan Biswas <Chayan.Biswas at sandisk.com>
---
drivers/block/nvme.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 4b706b5..311d753 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -1248,8 +1248,7 @@ static int nvme_user_admin_cmd(struct nvme_dev *dev,
nvme_free_iod(dev, iod);
}
- if (!status && copy_to_user(&ucmd->result, &cmd.result,
- sizeof(cmd.result)))
+ if (copy_to_user(&ucmd->result, &cmd.result, sizeof(cmd.result)))
status = -EFAULT;
return status;
--
1.7.1
________________________________
PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX
2013-02-28 19:49 [PATCH 2/2] Return the result from user admin command IOCTL even in case of failure Chayan Biswas
@ 2013-03-01 22:05 ` Keith Busch
2013-05-22 20:23 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2013-03-01 22:05 UTC (permalink / raw)
On Thu, 28 Feb 2013, Chayan Biswas wrote:
> - if (!status && copy_to_user(&ucmd->result, &cmd.result,
> - sizeof(cmd.result)))
> + if (copy_to_user(&ucmd->result, &cmd.result, sizeof(cmd.result)))
> status = -EFAULT;
I think you want to change this to a check for 'status >= 0' before
copying the result to the user since a status < 0 means the command was
not completed by the controller (successfully or otherwise) and you'd
be copying uninitialized data to the user in that case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX
2013-03-01 22:05 ` [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX Keith Busch
@ 2013-05-22 20:23 ` Matthew Wilcox
2013-05-22 21:12 ` Chayan Biswas
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2013-05-22 20:23 UTC (permalink / raw)
On Fri, Mar 01, 2013@03:05:06PM -0700, Keith Busch wrote:
> On Thu, 28 Feb 2013, Chayan Biswas wrote:
> >- if (!status && copy_to_user(&ucmd->result, &cmd.result,
> >- sizeof(cmd.result)))
> >+ if (copy_to_user(&ucmd->result, &cmd.result, sizeof(cmd.result)))
> > status = -EFAULT;
>
> I think you want to change this to a check for 'status >= 0' before
> copying the result to the user since a status < 0 means the command was
> not completed by the controller (successfully or otherwise) and you'd
> be copying uninitialized data to the user in that case.
Going back through my old patches ... Chayan, do you want to make the
change Keith suggested and resubmit? Or do you think he's wrong?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX
2013-05-22 20:23 ` Matthew Wilcox
@ 2013-05-22 21:12 ` Chayan Biswas
0 siblings, 0 replies; 4+ messages in thread
From: Chayan Biswas @ 2013-05-22 21:12 UTC (permalink / raw)
I am going to resubmit the patch today.
Thanks,
Chayan
> -----Original Message-----
> From: Matthew Wilcox [mailto:willy at linux.intel.com]
> Sent: Wednesday, May 22, 2013 1:24 PM
> To: Keith Busch
> Cc: Chayan Biswas; linux-nvme at lists.infradead.org
> Subject: Re: [PATCH 2/2] Return the result from user admin command IOCTL
> even in case of failureX
>
> On Fri, Mar 01, 2013@03:05:06PM -0700, Keith Busch wrote:
> > On Thu, 28 Feb 2013, Chayan Biswas wrote:
> > >- if (!status && copy_to_user(&ucmd->result, &cmd.result,
> > >-
> sizeof(cmd.result)))
> > >+ if (copy_to_user(&ucmd->result, &cmd.result,
> sizeof(cmd.result)))
> > > status = -EFAULT;
> >
> > I think you want to change this to a check for 'status >= 0' before
> > copying the result to the user since a status < 0 means the command was
> > not completed by the controller (successfully or otherwise) and you'd
> > be copying uninitialized data to the user in that case.
>
> Going back through my old patches ... Chayan, do you want to make the
> change Keith suggested and resubmit? Or do you think he's wrong?
________________________________
PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-22 21:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-28 19:49 [PATCH 2/2] Return the result from user admin command IOCTL even in case of failure Chayan Biswas
2013-03-01 22:05 ` [PATCH 2/2] Return the result from user admin command IOCTL even in case of failureX Keith Busch
2013-05-22 20:23 ` Matthew Wilcox
2013-05-22 21:12 ` Chayan Biswas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.