public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Smart <James.Smart@Emulex.Com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: "James.Bottomley@HansenPartnership.com"
	<James.Bottomley@HansenPartnership.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] fc_transport: Write outside array bounds
Date: Tue, 28 Jul 2009 09:28:22 -0400	[thread overview]
Message-ID: <4A6EFCF6.4040105@emulex.com> (raw)
In-Reply-To: <4A6EF1A3.6040607@gmail.com>

This shouldn't be the case, and if it is, isn't the right way to handle it.
It may simply be someone forgot to update FC_HOST_NUM_ATTRS. I'll double
check and get back shortly.

-- james s


Roel Kluin wrote:
> If it's possible to turn on all the optional attributes, there are more
> attributes than the length of array i->private_host_attrs[], so the last one
> will be out-of-bounds. (There is a BUG_ON there, but it's after the write,
> rather than before).
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Found with Parfait, http://research.sun.com/projects/parfait/
> 
> in fc_attach_transport()
> ...
> count=0;
> 14 x SETUP_HOST_ATTRIBUTE_RD()
> if (ft->vport_create)
> 	2 x SETUP_HOST_ATTRIBUTE_RD_NS()
> 1 x SETUP_HOST_ATTRIBUTE_RW()
> 1 - 4 x SETUP_PRIVATE_HOST_ATTRIBUTE_RW()
> 
> all these definitions set private_host_attrs[count] (21 elements)
> and increase the index count thereafter.
> 
> diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
> index 292c02f..8092e56 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -2123,8 +2123,12 @@ fc_attach_transport(struct fc_function_template *ft)
>  		SETUP_PRIVATE_HOST_ATTRIBUTE_RW(issue_lip);
>  	if (ft->vport_create)
>  		SETUP_PRIVATE_HOST_ATTRIBUTE_RW(vport_create);
> -	if (ft->vport_delete)
> -		SETUP_PRIVATE_HOST_ATTRIBUTE_RW(vport_delete);
> +	if (ft->vport_delete) {
> +		if(count < FC_HOST_NUM_ATTRS)
> +			SETUP_PRIVATE_HOST_ATTRIBUTE_RW(vport_delete);
> +		else
> +			count++;
> +	}
>  
>  	BUG_ON(count > FC_HOST_NUM_ATTRS);
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      reply	other threads:[~2009-07-28 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-28 12:40 [PATCH] fc_transport: Write outside array bounds Roel Kluin
2009-07-28 13:28 ` James Smart [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=4A6EFCF6.4040105@emulex.com \
    --to=james.smart@emulex.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=roel.kluin@gmail.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