linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Engelmayer <christian.engelmayer@frequentis.com>
To: bzolnier@gmail.com
Cc: christian.engelmayer@frequentis.com, linux-ide@vger.kernel.org
Subject: potential memory overrun in ata_id_to_hd_driveid() on big endian machines
Date: Fri, 19 Jun 2009 08:41:05 +0200	[thread overview]
Message-ID: <20090619084105.4cdf78be@frequentis.com> (raw)

Please have a look at the usage of ata_id_to_hd_driveid() in ide-ioctls.c.

u16 array 'id' is allocated depending on the command, which might result in
142 byte. Indexing into the array at position 'ATA_ID_LBA_CAPACITY_2' in
ata_id_to_hd_driveid() would overrun the allocated memory in that case.

Regards,
 Christian

ide-ioctls.c:

	static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
					  unsigned long arg)

	u16 *id = NULL;
	int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142;

	..

	id = kmalloc(size, GFP_KERNEL);

	..

	ata_id_to_hd_driveid(id);

	..

ata.h:

	static inline void ata_id_to_hd_driveid(u16 *id)
	{
	#ifdef __BIG_ENDIAN

	..

	*(u64 *)&id[ATA_ID_LBA_CAPACITY_2] =
		ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);

             reply	other threads:[~2009-06-19  6:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-19  6:41 Christian Engelmayer [this message]
2009-06-20 21:05 ` potential memory overrun in ata_id_to_hd_driveid() on big endian machines Robert Hancock
2009-06-20 22:04 ` [PATCH 1/1] ide: memory overrun in ide_get_identity_ioctl() on big endian machines using ioctl HDIO_OBSOLETE_IDENTITY Christian Engelmayer
2009-06-22  9:49   ` 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=20090619084105.4cdf78be@frequentis.com \
    --to=christian.engelmayer@frequentis.com \
    --cc=bzolnier@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).