* [PATCH] Emulex FC HBA driver: fix overflow of statically allocated array
@ 2007-08-09 18:47 Jesper Juhl
2007-08-09 19:32 ` James Smart
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2007-08-09 18:47 UTC (permalink / raw)
To: James Smart; +Cc: linux-scsi, Linux Kernel Mailing List, Jesper Juhl
Hi,
The Coverity checker noticed that we may overrun a statically allocated
array in drivers/scsi/lpfc/lpfc_sli.c::lpfc_sli_hbqbuf_find().
The case is this; In 'struct lpfc_hba' we have
#define LPFC_MAX_HBQS 4
...
struct lpfc_hba {
...
struct hbq_s hbqs[LPFC_MAX_HBQS];
...
};
But then in lpfc_sli_hbqbuf_find() we have this code
hbqno = tag >> 16;
if (hbqno > LPFC_MAX_HBQS)
return NULL;
if 'hbqno' ends up as exactely 4, then we won't return, and then this
list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) {
will cause an overflow of the statically allocated array at index 4,
since the valid indices are only 0-3.
I propose this patch, that simply changes the 'hbqno > LPFC_MAX_HBQS'
into 'hbqno >= LPFC_MAX_HBQS' as a possible fix.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/scsi/lpfc/lpfc_sli.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index ce5ff2b..e5337ad 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -675,7 +675,7 @@ lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag)
uint32_t hbqno;
hbqno = tag >> 16;
- if (hbqno > LPFC_MAX_HBQS)
+ if (hbqno >= LPFC_MAX_HBQS)
return NULL;
list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Emulex FC HBA driver: fix overflow of statically allocated array
2007-08-09 18:47 [PATCH] Emulex FC HBA driver: fix overflow of statically allocated array Jesper Juhl
@ 2007-08-09 19:32 ` James Smart
0 siblings, 0 replies; 2+ messages in thread
From: James Smart @ 2007-08-09 19:32 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-scsi, Linux Kernel Mailing List
ACK
-- james s
Jesper Juhl wrote:
> I propose this patch, that simply changes the 'hbqno > LPFC_MAX_HBQS'
> into 'hbqno >= LPFC_MAX_HBQS' as a possible fix.
>
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>
> drivers/scsi/lpfc/lpfc_sli.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-09 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-09 18:47 [PATCH] Emulex FC HBA driver: fix overflow of statically allocated array Jesper Juhl
2007-08-09 19:32 ` James Smart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox