public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sg: add sg_remove_request in sg_common_write
@ 2020-04-13 11:28 Li Bin
  0 siblings, 0 replies; 4+ messages in thread
From: Li Bin @ 2020-04-13 11:28 UTC (permalink / raw)
  To: dgilbert, jejb, martin.petersen, hare, jthumshirn
  Cc: linux-scsi, linux-kernel, huawei.libin, xiexiuqi

If the dxfer_len is greater than 256M that the request is invalid,
it should call sg_remove_request in sg_common_write.

Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")
Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
 drivers/scsi/sg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4e6af592..9c0ee19 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -793,8 +793,10 @@ static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count)
 			"sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",
 			(int) cmnd[0], (int) hp->cmd_len));
 
-	if (hp->dxfer_len >= SZ_256M)
+	if (hp->dxfer_len >= SZ_256M) {
+		sg_remove_request(sfp, srp);
 		return -EINVAL;
+	}
 
 	k = sg_start_req(srp, cmnd);
 	if (k) {
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] scsi: sg: add sg_remove_request in sg_common_write
@ 2020-04-13 11:29 Li Bin
  2020-04-14  1:17 ` Douglas Gilbert
  2020-04-14  1:59 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Li Bin @ 2020-04-13 11:29 UTC (permalink / raw)
  To: dgilbert, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, huawei.libin, xiexiuqi

If the dxfer_len is greater than 256M that the request is invalid,
it should call sg_remove_request in sg_common_write.

Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")
Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
 drivers/scsi/sg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4e6af592..9c0ee19 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -793,8 +793,10 @@ static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count)
 			"sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",
 			(int) cmnd[0], (int) hp->cmd_len));
 
-	if (hp->dxfer_len >= SZ_256M)
+	if (hp->dxfer_len >= SZ_256M) {
+		sg_remove_request(sfp, srp);
 		return -EINVAL;
+	}
 
 	k = sg_start_req(srp, cmnd);
 	if (k) {
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sg: add sg_remove_request in sg_common_write
  2020-04-13 11:29 [PATCH] scsi: sg: add sg_remove_request in sg_common_write Li Bin
@ 2020-04-14  1:17 ` Douglas Gilbert
  2020-04-14  1:59 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Douglas Gilbert @ 2020-04-14  1:17 UTC (permalink / raw)
  To: Li Bin, jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, xiexiuqi

On 2020-04-13 7:29 a.m., Li Bin wrote:
> If the dxfer_len is greater than 256M that the request is invalid,
s/that/then/
> it should call sg_remove_request in sg_common_write.
> 
> Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")

Code fix is fine, please replace the "that" in the first comment line
above with "then".

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> Signed-off-by: Li Bin <huawei.libin@huawei.com>
> ---
>   drivers/scsi/sg.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 4e6af592..9c0ee19 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -793,8 +793,10 @@ static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count)
>   			"sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",
>   			(int) cmnd[0], (int) hp->cmd_len));
>   
> -	if (hp->dxfer_len >= SZ_256M)
> +	if (hp->dxfer_len >= SZ_256M) {
> +		sg_remove_request(sfp, srp);
>   		return -EINVAL;
> +	}
>   
>   	k = sg_start_req(srp, cmnd);
>   	if (k) {
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sg: add sg_remove_request in sg_common_write
  2020-04-13 11:29 [PATCH] scsi: sg: add sg_remove_request in sg_common_write Li Bin
  2020-04-14  1:17 ` Douglas Gilbert
@ 2020-04-14  1:59 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2020-04-14  1:59 UTC (permalink / raw)
  To: Li Bin; +Cc: dgilbert, jejb, martin.petersen, linux-scsi, linux-kernel,
	xiexiuqi


Li,

> If the dxfer_len is greater than 256M that the request is invalid,
> it should call sg_remove_request in sg_common_write.

Applied to 5.7/scsi-fixes with a tweak to the commit description. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14  1:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-13 11:29 [PATCH] scsi: sg: add sg_remove_request in sg_common_write Li Bin
2020-04-14  1:17 ` Douglas Gilbert
2020-04-14  1:59 ` Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2020-04-13 11:28 Li Bin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox