mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Sathya Prakash <sathya.prakash@broadcom.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	leit@meta.com,
	"open list:LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)"
	<MPT-FusionLinux.pdl@broadcom.com>,
	"open list:LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)"
	<linux-scsi@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mpt3sas: Avoid test/set_bit() operating in non-allocated memory
Date: Fri, 31 May 2024 15:10:45 -0600	[thread overview]
Message-ID: <Zlo81SBdvflQ_38O@kbusch-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20240531180055.950704-1-leitao@debian.org>

On Fri, May 31, 2024 at 11:00:54AM -0700, Breno Leitao wrote:
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 258647fc6bdd..fe9f4a4175d1 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -8512,6 +8512,12 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
>  	ioc->pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
>  	if (ioc->facts.MaxDevHandle % 8)
>  		ioc->pd_handles_sz++;
> +	/* pd_handles_sz should have, at least, the minimal room
> +	 * for set_bit()/test_bit(), otherwise out-of-memory touch
> +	 * may occur
> +	 */
> +	ioc->pd_handles_sz = ALIGN(ioc->pd_handles_sz, sizeof(unsigned long));
> +
>  	ioc->pd_handles = kzalloc(ioc->pd_handles_sz,
>  	    GFP_KERNEL);
>  	if (!ioc->pd_handles) {
> @@ -8529,6 +8535,12 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
>  	ioc->pend_os_device_add_sz = (ioc->facts.MaxDevHandle / 8);
>  	if (ioc->facts.MaxDevHandle % 8)
>  		ioc->pend_os_device_add_sz++;
> +
> +	/* pend_os_device_add_sz should have, at least, the minimal room
> +	 * for set_bit()/test_bit(), otherwise out-of-memory may occur
> +	 */
> +	ioc->pend_os_device_add_sz = ALIGN(ioc->pend_os_device_add_sz,
> +					   sizeof(unsigned long));
>  	ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz,
>  	    GFP_KERNEL);
>  	if (!ioc->pend_os_device_add) {

Do we need similiar ALIGN for _base_check_ioc_facts_changes() too?
Otherwise, yeah, the {test,set,clear}_bit() ops expect an address to
something aligned to 'unsigned long'.

  reply	other threads:[~2024-05-31 21:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31 18:00 Breno Leitao
2024-05-31 21:10 ` Keith Busch [this message]
2024-06-05  8:33   ` Breno Leitao

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=Zlo81SBdvflQ_38O@kbusch-mbp.dhcp.thefacebook.com \
    --to=kbusch@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=leit@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    /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®