mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Hood <jdthood@mail.com>
To: linux-kernel@vger.kernel.org
Cc: Chris Rankin <cj.rankin@ntlworld.com>,
	Zwane Mwaikambo <zwane@linuxpower.ca>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Dave Jones <davej@codemonkey.org.uk>
Subject: [PATCH] Fix error in pnpbios escd read routine
Date: 09 Aug 2002 10:47:16 -0300	[thread overview]
Message-ID: <1028900843.919.14.camel@thanatos> (raw)

Alan, Dave:

This patch fixes an error in the pnpbios driver's routine
for reading ESCD data.  (Note the 'buf' changed to 'tmpbuf'.)
Also, it adds another sanity check.

This bug probably caused the crashes reported by Chris Rankin
and Zwane Mwaikambo some weeks ago.

--
Thomas Hood


--- linux-2.4.19-ac4/drivers/pnp/pnpbios_proc.c_ORIG	Wed Aug  7 23:31:08 2002
+++ linux-2.4.19-ac4/drivers/pnp/pnpbios_proc.c	Fri Aug  9 10:38:29 2002
@@ -62,39 +62,47 @@
 		"ESCD_size %d\n"
 		"NVRAM_base 0x%x\n",
 		escd.min_escd_write_size,
 		escd.escd_size,
 		escd.nv_storage_base
 	);
 }
 
+#define MAX_SANE_ESCD_SIZE (32*1024)
 static int proc_read_escd(char *buf, char **start, off_t pos,
                           int count, int *eof, void *data)
 {
 	struct escd_info_struc escd;
 	char *tmpbuf;
 	int escd_size, escd_left_to_read, n;
 
 	if (pnp_bios_escd_info(&escd))
 		return -EIO;
 
 	/* sanity check */
-	if (escd.escd_size > (32*1024)) {
-		printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size is too great\n");
+	if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
+		printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n");
 		return -EFBIG;
 	}
 
 	tmpbuf = pnpbios_kmalloc(escd.escd_size, GFP_KERNEL);
 	if (!tmpbuf) return -ENOMEM;
 
 	if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base))
 		return -EIO;
 
-	escd_size = (unsigned char)(buf[0]) + (unsigned char)(buf[1])*256;
+	escd_size = (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1])*256;
+
+	/* sanity check */
+	if (escd_size > MAX_SANE_ESCD_SIZE) {
+		printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n");
+		return -EFBIG;
+	}
+
 	escd_left_to_read = escd_size - pos;
 	if (escd_left_to_read < 0) escd_left_to_read = 0;
 	if (escd_left_to_read == 0) *eof = 1;
 	n = min(count,escd_left_to_read);
 	memcpy(buf, tmpbuf + pos, n);
 	kfree(tmpbuf);
 	*start = buf;
 	return n;


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

                 reply	other threads:[~2002-08-09 12:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1028900843.919.14.camel@thanatos \
    --to=jdthood@mail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=cj.rankin@ntlworld.com \
    --cc=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zwane@linuxpower.ca \
    /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

all inboxes | Powered by JetHome®