Skip to contentSkip to conversation

mmc: card: fixing an false identification of SANITIZE command

PATCH In review Yaniv Gardi 2 participants 2 messages Jun 5, 2013 – Jun 27, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: card: fixing an false identification of SANITIZE command

Inside the routine mmc_blk_ioctl_cmd() the sanitize command is identified according to the value of bits 16-23 of the argument.

but what happens if a different command is sent, and only by chance, bits 16-23 contain the value of SANITIZE command ?
In that case a SANITIZE command will be falsely identified. In order to prevent such a case, the condition is expanded and now it also checks the opcode itself, and verifies that it is an MMC_SWITCH opcode.

---
 drivers/mmc/card/block.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/mmc/card/block.c +3 -1
index c900d28..9775ae7 100644
@@ -542,7 +542,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 			goto cmd_rel_host;
 	}
 
-	if (MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) {
+	if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
+	     (cmd.opcode == MMC_SWITCH)) {
+
 		err = ioctl_do_sanitize(card);
 
 		if (err)
Signature · 1 line
1.7.6
#1 lore raw

Hi Yaniv,

Quoted 20 lines · Yaniv Gardi

Inside the routine mmc_blk_ioctl_cmd() the sanitize command is identified according to the value of bits 16-23 of the argument.

but what happens if a different command is sent, and only by chance, bits 16-23 contain the value of SANITIZE command ?
In that case a SANITIZE command will be falsely identified. In order to prevent such a case, the condition is expanded and now it also checks the opcode itself, and verifies that it is an MMC_SWITCH opcode.

---
 drivers/mmc/card/block.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/mmc/card/block.c +0 -0
index c900d28..9775ae7 100644

drivers/mmc/card/block.c static int mmc_blk_ioctl_cmd(struct block_device *bdev, · line 550

Quoted 10 lines
drivers/mmc/card/block.c +3 -1
@@ -542,7 +542,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 			goto cmd_rel_host;
 	}
 
-	if (MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) {
+	if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
+	     (cmd.opcode == MMC_SWITCH)) {
+
 		err = ioctl_do_sanitize(card);
 
 		if (err)

Thanks, pushed to mmc-next for 3.11.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child