]> git.karo-electronics.de Git - karo-tx-linux.git/commit
Check mapped ranges on sysfs resource files
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Oct 2008 22:09:14 +0000 (18:09 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 22 Oct 2008 21:13:27 +0000 (14:13 -0700)
commitfe2615638c671468e28b15d5e15f9b594b1fa23c
tree37676bda9e9a05cd0e7bd328476b67cd11c354fa
parent76d8cb9a1e102231935e586e888b10ea6ca41101
Check mapped ranges on sysfs resource files

commit b5ff7df3df9efab511244d5a299fce706c71af48 upstream

Check mapped ranges on sysfs resource files

This is loosely based on a patch by Jesse Barnes to check the user-space
PCI mappings though the sysfs interfaces.  Quoting Jesse's original
explanation:

  It's fairly common for applications to map PCI resources through sysfs.
  However, with the current implementation, it's possible for an application
  to map far more than the range corresponding to the resourceN file it
  opened.  This patch plugs that hole by checking the range at mmap time,
  similar to what is done on platforms like sparc64 in their lower level
  PCI remapping routines.

  It was initially put together to help debug the e1000e NVRAM corruption
  problem, since we initially thought an X driver might be walking past the
  end of one of its mappings and clobbering the NVRAM.  It now looks like
  that's not the case, but doing the check is still important for obvious
  reasons.

and this version of the patch differs in that it uses a helper function
to clarify the code, and does all the checks in pages (instead of bytes)
in order to avoid overflows when doing "<< PAGE_SHIFT" etc.

[cebbert@redhat.com: backport, changing WARN() to printk()]

Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/pci-sysfs.c