From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [SCSI] sd: Ensure we correctly disable devices with unknown protection type
Date: Wed, 6 Feb 2013 22:29:03 +0300 [thread overview]
Message-ID: <20130206192903.GW4989@mwanda> (raw)
In-Reply-To: <yq1txuk9ojz.fsf@sermon.lab.mkp.net>
This patch wasn't applied. Probably because it didn't have
[PATCH] in the email subject.
regards,
dan carpenter
On Wed, Sep 26, 2012 at 10:39:44PM -0400, Martin K. Petersen wrote:
> >>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> writes:
>
> Dan,
>
> Dan> warn: buffer overflow 'cap' 4 <= 4
>
> Argh, yes. Type 3 is 4 because it's a bitmask.
>
> --
> Martin K. Petersen Oracle Linux Engineering
>
>
> SCSI: Fix range check in scsi_host.h
>
> The range checking from fe542396 was bad. We would still end up walking
> beyond the array as Type 3 is defined to be 4 in the protection
> bitmask. Instead use ARRAY_SIZE() for the range check.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 4908480..2b6956e 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -873,7 +873,7 @@ static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsign
> SHOST_DIF_TYPE2_PROTECTION,
> SHOST_DIF_TYPE3_PROTECTION };
>
> - if (target_type > SHOST_DIF_TYPE3_PROTECTION)
> + if (target_type >= ARRAY_SIZE(cap))
> return 0;
>
> return shost->prot_capabilities & cap[target_type] ? target_type : 0;
> @@ -887,7 +887,7 @@ static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsign
> SHOST_DIX_TYPE2_PROTECTION,
> SHOST_DIX_TYPE3_PROTECTION };
>
> - if (target_type > SHOST_DIX_TYPE3_PROTECTION)
> + if (target_type >= ARRAY_SIZE(cap))
> return 0;
>
> return shost->prot_capabilities & cap[target_type];
next prev parent reply other threads:[~2013-02-06 19:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-26 8:26 [SCSI] sd: Ensure we correctly disable devices with unknown protection type Dan Carpenter
2012-09-27 2:39 ` Martin K. Petersen
2013-02-06 19:29 ` Dan Carpenter [this message]
2013-02-07 19:24 ` Martin K. Petersen
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=20130206192903.GW4989@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).