linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Engelmayer <christian.engelmayer@frequentis.com>
To: bzolnier@gmail.com, hancockrwd@gmail.com
Cc: christian.engelmayer@frequentis.com, linux-ide@vger.kernel.org
Subject: [PATCH 1/1] ide: memory overrun in ide_get_identity_ioctl() on big endian machines using ioctl HDIO_OBSOLETE_IDENTITY
Date: Sun, 21 Jun 2009 00:04:23 +0200	[thread overview]
Message-ID: <20090621000423.30c462d9@frequentis.com> (raw)
In-Reply-To: <20090619084105.4cdf78be@frequentis.com>

From: Christian Engelmayer <christian.engelmayer@frequentis.com>

This patch fixes a memory overrun in function ide_get_identity_ioctl() which
chooses the size of a memory buffer depending on the ioctl command that led
to the function call, however, passes that buffer to a function which needs the
buffer size to be always chosen unconditionally.

Due to conditional compilation the memory overrun can only happen on big endian
machines. The error can be triggered using ioctl HDIO_OBSOLETE_IDENTITY. Usage
of ioctl HDIO_GET_IDENTITY is safe.

Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
--
Proposed patch after comment by Robert Hancock who shares the view that buffer
'id' should be allocated unconditionally.

--- drivers/ide/ide-ioctls.c.orig	2009-06-20 23:22:45.000000000 +0200
+++ drivers/ide/ide-ioctls.c	2009-06-20 23:30:21.000000000 +0200
@@ -64,7 +64,8 @@ static int ide_get_identity_ioctl(ide_dr
 		goto out;
 	}
 
-	id = kmalloc(size, GFP_KERNEL);
+	/* ata_id_to_hd_driveid() relies on 'id' to be fully allocated. */
+	id = kmalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
 	if (id == NULL) {
 		rc = -ENOMEM;
 		goto out;

  parent reply	other threads:[~2009-06-20 22:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-19  6:41 potential memory overrun in ata_id_to_hd_driveid() on big endian machines Christian Engelmayer
2009-06-20 21:05 ` Robert Hancock
2009-06-20 22:04 ` Christian Engelmayer [this message]
2009-06-22  9:49   ` [PATCH 1/1] ide: memory overrun in ide_get_identity_ioctl() on big endian machines using ioctl HDIO_OBSOLETE_IDENTITY Bartlomiej Zolnierkiewicz
2009-06-30  2:31     ` David Miller

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=20090621000423.30c462d9@frequentis.com \
    --to=christian.engelmayer@frequentis.com \
    --cc=bzolnier@gmail.com \
    --cc=hancockrwd@gmail.com \
    --cc=linux-ide@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 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).