mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bodo Strößer" <bostroesser@gmail.com>
To: shao.mingyin@zte.com.cn, mkp@kernel.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Cc: michael.christie@oracle.com, bvanassche@acm.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: target: tcmu: Fix divide-by-zero in data_pages_per_blk store
Date: Thu, 29 Oct 2026 16:15:40 +0100	[thread overview]
Message-ID: <57e4f2c2-d692-4130-835f-e507574c7252@gmail.com> (raw)
In-Reply-To: <20261026195245337ktSXy9G17VCcXyw760g9s@zte.com.cn>

On 26/10/2026 12:52, shao.mingyin@zte.com.cn wrote:

> From: Shao Mingyin <shao.mingyin@zte.com.cn>
>
> tcmu_set_data_pages_per_blk() only validates the upper bound of the value
> parsed from data_pages_per_blk=. Zero passes that check and is then used
> as the divisor when computing udev->max_blocks:
>
>    divide error: 0000 [#1] SMP
>    ...
>    tcmu_set_data_pages_per_blk
>    tcmu_configure_device
>
> Reject non-positive values, as the neighbouring max_data_area_mb and
> cmd_ring_size setters already do.
>
> Fixes: 08976cb548d6 ("scsi: target: tcmu: Make data_pages_per_blk changeable via configfs")
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> Cc: stable@vger.kernel.org
> ---
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 425ad1246a75..07b514678176 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -2524,6 +2524,11 @@ static int tcmu_set_data_pages_per_blk(struct tcmu_dev *udev, substring_t *arg)
>   		return ret;
>   	}
>
> +	if (val <= 0) {
> +		pr_err("Invalid data_pages_per_blk %d.\n", val);
> +		return -EINVAL;
> +	}
> +
>   	if (val > TCMU_MBS_TO_PAGES(udev->data_area_mb)) {
>   		pr_err("Invalid data_pages_per_blk %d: greater than max_data_area_mb %d -> %zd pages).\n",
>   		       val, udev->data_area_mb,

Reviewed-by: Bodo Stroesser <bostroesser@gmail.com>

Thank you.

Regards,
Bodo Stroesser


      reply	other threads:[~2026-10-29 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 11:52 shao.mingyin
2026-10-29 15:15 ` Bodo Strößer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57e4f2c2-d692-4130-835f-e507574c7252@gmail.com \
    --to=bostroesser@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michael.christie@oracle.com \
    --cc=mkp@kernel.org \
    --cc=shao.mingyin@zte.com.cn \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®