Skip to contentSkip to conversation

Return the result from user admin command IOCTL even in case of failure

PATCH Superseded Chayan Biswas 3 participants 4 messages Feb 28, 2013 – May 22, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Return the result from user admin command IOCTL even in case of failure

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(-)
drivers/block/nvme.c +1 -2
index 4b706b5..311d753 100644
@@ -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).

#1 lore raw

PATCH 2/2 Return the result from user admin command IOCTL even in case of failureX

drivers/block/nvme.c static int nvme_user_admin_cmd(struct nvme_dev *dev, · line 1252

Quoted 4 lines · Chayan Biswas
drivers/block/nvme.c +1 -2
-       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.

#2 lore raw

PATCH 2/2 Return the result from user admin command IOCTL even in case of failureX

Quoted 10 lines · Keith Busch

drivers/block/nvme.c static int nvme_user_admin_cmd(struct nvme_dev *dev, · line 1252

Quoted 4 lines · Chayan Biswas
drivers/block/nvme.c +1 -2
-       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?

#3 lore raw

PATCH 2/2 Return the result from user admin command IOCTL even in case of failureX

I am going to resubmit the patch today.

Thanks,
Chayan

Quoted 17 lines

-----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

Quoted 3 lines · Keith Busch

Review

Quoted 2 lines · Chayan Biswas
(quoted diff) +0 -2
-       if (!status && copy_to_user(&ucmd->result, &cmd.result,
-

sizeof(cmd.result)))

Quoted 1 line
Quoted 1 line

+ if (copy_to_user(&ucmd->result, &cmd.result,

sizeof(cmd.result)))

Quoted 2 lines
Quoted 1 line
              status = -EFAULT;
Quoted 7 lines
Quoted 4 lines

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).