mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Michael Brown <mebrown@michaels-house.net>
Cc: linux-kernel@vger.kernel.org, marcelo.tosatti@cyclades.com,
	michael_e_brown@dell.com
Subject: Re: [PATCH 2.4] add SMBIOS information to /proc/smbios -- UPDATED
Date: Fri, 30 Apr 2004 04:34:08 +0100	[thread overview]
Message-ID: <20040430033408.GR17014@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <1083291712.1203.2914.camel@debian>

On Thu, Apr 29, 2004 at 09:21:52PM -0500, Michael Brown wrote:
> +	u32 fp = 0xF0000;
> +	while (fp < 0xFFFFF) {
> +		isa_memcpy_fromio(table_eps, fp, sizeof(*table_eps));
> +		if (memcmp(table_eps->anchor, "_SM_", 4)==0 &&
> +					checksum_eps(table_eps)) {
> +			return 0;
> +		}
> +		fp += 16;
> +	}

Stilistic note:
	for (fp = 0xf0000; fp < 0xfffff; fp += 16) {
		isa_memcpy_fromio(table_eps, fp, sizeof(*table_eps));
		if (memcmp(table_eps->anchor, "_SM_", 4) != 0)
			continue;
		if (checksum_eps(table_eps))
			return 0;
	}

> +	while(keep_going && ((ptr - buf) <= max_length) && count < max_count){
> +		if (ptr[0] == 0x7F)   /* ptr[0] is type */
> +			keep_going = 0;
> +
> +		ptr += ptr[1]; /* ptr[1] is length, skip structure */
> +		/* skip strings at end of structure */
> +		while((ptr-buf) < max_length && (ptr[0] || ptr[1]))
> +			++ptr;

It looks like an off-by-one - if ptr reaches buf + max_length - 1, ptr[1]
appears to be beyond the area it's OK to dereference.

> +                size_t count, loff_t *ppos)
> +{
> +	unsigned long origppos = *ppos;
> +	unsigned long max_off = the_smbios_device.smbios_table_real_length;
> +	u8 *ptr;
> +
> +	if(*ppos >= max_off)
> +		return 0;

Note that *ppos is signed here.  llseek() to negative and you've got a problem.

> +	while (*ppos < max_off) {
> +		put_user(readb(ptr + *ppos), buf);
> +		++(*ppos); ++buf;
> +	}

Eeek...

	a) that's called copy_to_user()
	b) you'd better check the return value (either of put_user() or
copy_to_user()).

  reply	other threads:[~2004-04-30  3:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-30  2:21 Michael Brown
2004-04-30  3:34 ` viro [this message]
2004-04-30  4:37   ` Michael Brown
2004-05-03 23:40 ` Marcelo Tosatti
     [not found] <1QvX0-A4-29@gated-at.bofh.it>
2004-04-30 19:22 ` Andi Kleen
2004-05-01  3:30   ` Michael Brown
2004-05-01  3:43     ` Michael Brown
2004-05-01 15:01     ` Andi Kleen
2004-05-01 21:00 Lev Makhlis
2004-05-01 21:20 ` Andi Kleen
2004-05-03 23:49 Michael_E_Brown

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=20040430033408.GR17014@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=mebrown@michaels-house.net \
    --cc=michael_e_brown@dell.com \
    /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®