All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haogang Chen <haogangchen@gmail.com>
To: aacraid@adaptec.com
Cc: JBottomley@parallels.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, haogangchen@gmail.com
Subject: [PATCH] SCSI: aacraid: potential integer overflow in aac_get_containers()
Date: Wed, 30 Nov 2011 21:30:01 -0500	[thread overview]
Message-ID: <1322706601-26181-1-git-send-email-haogangchen@gmail.com> (raw)

There is a potential integer overflow in aac_get_containers(). When
maximum_num_containers is large, the subsequent call to kzalloc() will
allocate a buffer smaller than expected, which leads to memory
corruption in the for loop.

The patch replaces kzalloc with kcalloc.

Signed-off-by: Haogang Chen <haogangchen@gmail.com>
---
 drivers/scsi/aacraid/aachba.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 409f580..440b84d 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -381,7 +381,7 @@ int aac_get_containers(struct aac_dev *dev)
 
 	if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
 		maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
-	fsa_dev_ptr = kzalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers,
+	fsa_dev_ptr = kcalloc(maximum_num_containers, sizeof(*fsa_dev_ptr), 
 			GFP_KERNEL);
 	if (!fsa_dev_ptr)
 		return -ENOMEM;
-- 
1.7.5.4

             reply	other threads:[~2011-12-01  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01  2:30 Haogang Chen [this message]
2011-12-01 10:07 ` [PATCH] SCSI: aacraid: potential integer overflow in aac_get_containers() Achim Leubner
2011-12-01 10:07   ` Achim Leubner
2011-12-02 16:03 ` Mark Salyzyn
2011-12-02 16:03   ` Mark Salyzyn
2011-12-03 19:30   ` Haogang Chen
2011-12-03 19:30     ` Haogang Chen

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=1322706601-26181-1-git-send-email-haogangchen@gmail.com \
    --to=haogangchen@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=aacraid@adaptec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.