From: Ingo Molnar <mingo@elte.hu>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: jbarnes@virtuousgeek.org, tglx@linutronix.de, hpa@zytor.com,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, linux-kernel@vger.kernel.org,
Yinghai Lu <yhlu.kernel@gmail.com>
Subject: Re: [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
Date: Fri, 26 Sep 2008 09:39:02 +0200 [thread overview]
Message-ID: <20080926073902.GA30041@elte.hu> (raw)
In-Reply-To: <20080926014334.GF15609@linux-os.sc.intel.com>
* Suresh Siddha <suresh.b.siddha@intel.com> wrote:
> [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
>
> Go through the iomem resource tree to check if any of the ioremap() requests
> span more than any slot in the iomem resource tree and do a WARN_ON() if we hit
> this check.
>
> This will raise a red-flag, if some driver is mapping more than what
> is needed. And hopefully identify possible corruptions much earlier.
>
> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
applied to tip/core/resources, thanks Suresh.
one question:
> + for (p = p->child; p ; p = r_next(NULL, p, &l)) {
> + /*
> + * We can probably skip the resources with out
> + * IORESOURCE_IO attribute?
> + */
> + 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;
i think all the checks you added are precise to the byte and you allow
all the sensible ioremaps: which nest fully inside a single resource -
and you reject all the other partial overlap or multiple overlap
scenarios.
One potential thing to check for would be whether addr+size overlaps a
4GB boundary? That would almost always be a bug, and it could also cause
problems with the checks above if resource_t is 32 bits. The ioremap
code should already prevent it though.
Ingo
next prev parent reply other threads:[~2008-09-26 7:39 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 [this message]
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 ` [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes Jeremy Fitzhardinge
2008-09-27 11:21 ` 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=20080926073902.GA30041@elte.hu \
--to=mingo@elte.hu \
--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=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yhlu.kernel@gmail.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