diff mbox series

scsi_debug: num_tgts must be >= 0

Message ID 20191115163727.24626-1-mlombard@redhat.com (mailing list archive)
State Mainlined
Commit aa5334c4f3014940f11bf876e919c956abef4089
Headers show
Series scsi_debug: num_tgts must be >= 0 | expand

Commit Message

Maurizio Lombardi Nov. 15, 2019, 4:37 p.m. UTC
Passing the parameter "num_tgts=-1" will start
an infinite loop that exhausts the system memory

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 drivers/scsi/scsi_debug.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Douglas Gilbert Nov. 16, 2019, 3:30 a.m. UTC | #1
On 2019-11-16 3:37 a.m., Maurizio Lombardi wrote:
> Passing the parameter "num_tgts=-1" will start
> an infinite loop that exhausts the system memory

Ouch.

> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>

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

> ---
>   drivers/scsi/scsi_debug.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index d323523f5f9d..32965ec76965 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5263,6 +5263,11 @@ static int __init scsi_debug_init(void)
>   		return -EINVAL;
>   	}
>   
> +	if (sdebug_num_tgts < 0) {
> +		pr_err("num_tgts must be >= 0\n");
> +		return -EINVAL;
> +	}
> +
>   	if (sdebug_guard > 1) {
>   		pr_err("guard must be 0 or 1\n");
>   		return -EINVAL;
>
Martin K. Petersen Nov. 19, 2019, 4:41 a.m. UTC | #2
Maurizio,

> Passing the parameter "num_tgts=-1" will start an infinite loop that
> exhausts the system memory

Applied to 5.5/scsi-queue, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d323523f5f9d..32965ec76965 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5263,6 +5263,11 @@  static int __init scsi_debug_init(void)
 		return -EINVAL;
 	}
 
+	if (sdebug_num_tgts < 0) {
+		pr_err("num_tgts must be >= 0\n");
+		return -EINVAL;
+	}
+
 	if (sdebug_guard > 1) {
 		pr_err("guard must be 0 or 1\n");
 		return -EINVAL;