All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: jbarnes@virtuousgeek.org, mingo@elte.hu, tglx@linutronix.de,
	hpa@zytor.com, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, arjan@linux.intel.com,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
Date: Sat, 27 Sep 2008 00:16:46 -0700	[thread overview]
Message-ID: <48DDDDDE.7060707@goop.org> (raw)
In-Reply-To: <20080926014334.GF15609@linux-os.sc.intel.com>

Suresh Siddha wrote:
> +int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
> +{
> +	struct resource *p = &iomem_resource;
> +	int err = 0;
> +	loff_t l;
> +
> +	read_lock(&resource_lock);
> +	for (p = p->child; p ; p = r_next(NULL, p, &l)) {
> +		/*
> +		 * We can probably skip the resources with out
> +		 * IORESOURCE_IO attribute?
>   

Any attempt to use ioremap on memory is a bug, so you should warn about
that too.

> +		 */
> +		if (p->start >= addr + size)
> +			continue;
> +		if (p->end < addr)
> +			continue;
> +		if (p->start <= addr && (p->end >= addr + size - 1))
> +			continue;
> +		printk(KERN_WARNING "resource map sanity check conflict "
> +		       " 0x%llx 0x%llx 0x%llx 0x%llx %s\n",
> +		       addr, addr + size - 1, p->start, p->end, p->name);
> +		err = -1;
> +		break;
> +	}
> +	read_unlock(&resource_lock);
> +
> +	return err;

    J

  parent reply	other threads:[~2008-09-27  7:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-26  1:43 [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes Suresh Siddha
2008-09-26  7:39 ` Ingo Molnar
2008-09-26  8:10   ` Yinghai Lu
2008-09-26  8:12   ` Ingo Molnar
2008-09-26  8:35     ` Ingo Molnar
2008-09-26  9:46       ` [PATCH] x86, pci-hotplug, calgary / rio: fix EBDA ioremap() Ingo Molnar
2008-09-26 11:14         ` Arjan van de Ven
2008-09-27 16:35           ` Ingo Molnar
2008-09-27  7:16 ` Jeremy Fitzhardinge [this message]
2008-09-27 11:21   ` [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes Alan Cox
2008-09-27 14:43     ` Jeremy Fitzhardinge
2008-09-27 15:09       ` Arjan van de Ven
2008-09-27 16:17         ` Jeremy Fitzhardinge
2008-09-27 16:25       ` Alan Cox
2008-09-27 19:24         ` Arjan van de Ven

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=48DDDDDE.7060707@goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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.