Skip to contentSkip to conversation

usb: gadget: mass_storage: add READ_TOC cmd mask check

PATCH In review Neal Liu 3 participants 5 messages Jan 26, 2022 – Jan 27, 2022 USB

lore
Share & tools
lore

Neal Liu

author
#0 lore raw

PATCH 1/1 usb: gadget: mass_storage: add READ_TOC cmd mask check

READ_TOC cmnd[2] specifies Format Field which is defined in SCSI-3 spec. Add command mask to avoid marking this sense data as invalid.

---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +1 -1
index 46dd11dcb3a8..14d51695b8ae 100644
@@ -1944,7 +1944,7 @@ static int do_scsi_command(struct fsg_common *common)
 		common->data_size_from_cmnd =
 			get_unaligned_be16(&common->cmnd[7]);
 		reply = check_command(common, 10, DATA_DIR_TO_HOST,
-				      (7<<6) | (1<<1), 1,
+				      (7<<6) | (1<<1) | (1<<2), 1,
 				      "READ TOC");
 		if (reply == 0)
 			reply = do_read_toc(common, bh);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 14 lines · Neal Liu

READ_TOC cmnd[2] specifies Format Field which is defined in SCSI-3 spec. Add command mask to avoid marking this sense data as invalid.

---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +0 -0
index 46dd11dcb3a8..14d51695b8ae 100644

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common *common) · line 1947

Quoted 5 lines
drivers/usb/gadget/function/f_mass_storage.c +1 -1
@@ -1944,7 +1944,7 @@ static int do_scsi_command(struct fsg_common *common)
 		common->data_size_from_cmnd =
 			get_unaligned_be16(&common->cmnd[7]);
 		reply = check_command(common, 10, DATA_DIR_TO_HOST,
-				      (7<<6) | (1<<1), 1,
+				      (7<<6) | (1<<1) | (1<<2), 1,

Can we have real names here instead of magic numbers?

And what commit does this fix? Is it a regression or has it always never worked properly?

thanks,

greg k-h

author
#2 lore raw
Quoted 37 lines

-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Wednesday, January 26, 2022 6:51 PM
To: Neal Liu <[email protected]>
Cc: Felipe Balbi <[email protected]>; Alan Stern <[email protected]>; Chen Lin <[email protected]>; Wesley Cheng <[email protected]>; Nikita Yushchenko <[email protected]>; Cai Huoqing <[email protected]>; linux-usb at vger.kernel.org; linux-kernel at vger.kernel.org; linux-aspeed at lists.ozlabs.org; BMC-SW <[email protected]>
Subject: Re: [PATCH] usb: gadget: mass_storage: add READ_TOC cmd mask check

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common

Quoted 14 lines · Neal Liu

READ_TOC cmnd[2] specifies Format Field which is defined in SCSI-3 spec. Add command mask to avoid marking this sense data as invalid.

---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +0 -0
index 46dd11dcb3a8..14d51695b8ae 100644
@@ -1944,7 +1944,7 @@ static int do_scsi_command(struct fsg_common

*common)

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common *common) · line 1947

Quoted 5 lines
drivers/usb/gadget/function/f_mass_storage.c +1 -1
 		common->data_size_from_cmnd =
 			get_unaligned_be16(&common->cmnd[7]);
 		reply = check_command(common, 10, DATA_DIR_TO_HOST,
-				      (7<<6) | (1<<1), 1,
+				      (7<<6) | (1<<1) | (1<<2), 1,

Can we have real names here instead of magic numbers?

Quoted 6 lines

And what commit does this fix? Is it a regression or has it always never worked properly?

thanks,

greg k-h

This patch fix Windows Server OS installation failure problem. Since @Roger already sent similar patch fixed, I'll try it.
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=89ada0fe669a7abf8777b793b874202a0767a24f
Thanks

-Neal

#3 lore raw
In reply to Neal Liu
Quoted 14 lines · Neal Liu

READ_TOC cmnd[2] specifies Format Field which is defined in SCSI-3 spec. Add command mask to avoid marking this sense data as invalid.

---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +0 -0
index 46dd11dcb3a8..14d51695b8ae 100644

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common *common) · line 1950

Quoted 8 lines
drivers/usb/gadget/function/f_mass_storage.c +1 -1
@@ -1944,7 +1944,7 @@ static int do_scsi_command(struct fsg_common *common)
 		common->data_size_from_cmnd =
 			get_unaligned_be16(&common->cmnd[7]);
 		reply = check_command(common, 10, DATA_DIR_TO_HOST,
-				      (7<<6) | (1<<1), 1,
+				      (7<<6) | (1<<1) | (1<<2), 1,
 				      "READ TOC");
 		if (reply == 0)
 			reply = do_read_toc(common, bh);

You've been anticipated:

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=89ada0fe669a7abf8777b793b874202a0767a24f

Alan Stern

author
#4 lore raw
Quoted 40 lines

-----Original Message-----
From: Alan Stern <[email protected]>
Sent: Thursday, January 27, 2022 12:01 AM
To: Neal Liu <[email protected]>
Cc: Felipe Balbi <[email protected]>; Greg Kroah-Hartman <[email protected]>; Chen Lin <[email protected]>; Wesley Cheng <[email protected]>; Nikita Yushchenko <[email protected]>; Cai Huoqing <[email protected]>; linux-usb at vger.kernel.org; linux-kernel at vger.kernel.org; linux-aspeed at lists.ozlabs.org; BMC-SW <[email protected]>
Subject: Re: [PATCH] usb: gadget: mass_storage: add READ_TOC cmd mask check

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common

Quoted 14 lines · Neal Liu

READ_TOC cmnd[2] specifies Format Field which is defined in SCSI-3 spec. Add command mask to avoid marking this sense data as invalid.

---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +0 -0
index 46dd11dcb3a8..14d51695b8ae 100644
@@ -1944,7 +1944,7 @@ static int do_scsi_command(struct fsg_common

*common)

drivers/usb/gadget/function/f_mass_storage.c static int do_scsi_command(struct fsg_common *common) · line 1950

Quoted 8 lines
drivers/usb/gadget/function/f_mass_storage.c +1 -1
 		common->data_size_from_cmnd =
 			get_unaligned_be16(&common->cmnd[7]);
 		reply = check_command(common, 10, DATA_DIR_TO_HOST,
-				      (7<<6) | (1<<1), 1,
+				      (7<<6) | (1<<1) | (1<<2), 1,
 				      "READ TOC");
 		if (reply == 0)
 			reply = do_read_toc(common, bh);

You've been anticipated:

Quoted 4 lines

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb
-testing&id=89ada0fe669a7abf8777b793b874202a0767a24f

Alan Stern

Thanks for you info.

-Neal