All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v1 1/3] /dev/mem: disallow access to explicitly excluded system RAM regions
@ 2021-08-12  1:42 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-08-12  1:42 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3944 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210811203612.138506-2-david@redhat.com>
References: <20210811203612.138506-2-david@redhat.com>
TO: David Hildenbrand <david@redhat.com>
TO: linux-kernel(a)vger.kernel.org
CC: David Hildenbrand <david@redhat.com>
CC: Arnd Bergmann <arnd@arndb.de>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Jason Wang <jasowang@redhat.com>
CC: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
CC: Dan Williams <dan.j.williams@intel.com>

Hi David,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on char-misc/char-misc-testing soc/for-next linus/master v5.14-rc5 next-20210811]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-Hildenbrand/virtio-mem-disallow-mapping-virtio-mem-memory-via-dev-mem/20210812-043834
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 349a2d52ffe59b7a0c5876fa7ee9f3eaf188b830
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20210810 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/char/mem.c:70 page_is_allowed() warn: should 'pfn << 12' be a 64 bit type?
drivers/char/mem.c:87 range_is_allowed() warn: should 'pfn << 12' be a 64 bit type?

vim +70 drivers/char/mem.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  63  
a4866aa812518e Kees Cook         2017-04-05  64  static inline int page_is_allowed(unsigned long pfn)
a4866aa812518e Kees Cook         2017-04-05  65  {
19e42009961255 David Hildenbrand 2021-08-11  66  #ifdef CONFIG_STRICT_DEVMEM
19e42009961255 David Hildenbrand 2021-08-11  67  	if (!devmem_is_allowed(pfn))
19e42009961255 David Hildenbrand 2021-08-11  68  		return 0;
19e42009961255 David Hildenbrand 2021-08-11  69  #endif /* CONFIG_STRICT_DEVMEM */
19e42009961255 David Hildenbrand 2021-08-11 @70  	return !iomem_range_contains_excluded(PFN_PHYS(pfn), PAGE_SIZE);
a4866aa812518e Kees Cook         2017-04-05  71  }
19e42009961255 David Hildenbrand 2021-08-11  72  
e2beb3eae62721 Venki Pallipadi   2008-03-06  73  static inline int range_is_allowed(unsigned long pfn, unsigned long size)
ae531c26c5c2a2 Arjan van de Ven  2008-04-24  74  {
19e42009961255 David Hildenbrand 2021-08-11  75  #ifdef CONFIG_STRICT_DEVMEM
e2beb3eae62721 Venki Pallipadi   2008-03-06  76  	u64 from = ((u64)pfn) << PAGE_SHIFT;
e2beb3eae62721 Venki Pallipadi   2008-03-06  77  	u64 to = from + size;
e2beb3eae62721 Venki Pallipadi   2008-03-06  78  	u64 cursor = from;
e2beb3eae62721 Venki Pallipadi   2008-03-06  79  
e2beb3eae62721 Venki Pallipadi   2008-03-06  80  	while (cursor < to) {
39380b80d72723 Jiri Kosina       2016-07-08  81  		if (!devmem_is_allowed(pfn))
ae531c26c5c2a2 Arjan van de Ven  2008-04-24  82  			return 0;
e2beb3eae62721 Venki Pallipadi   2008-03-06  83  		cursor += PAGE_SIZE;
e2beb3eae62721 Venki Pallipadi   2008-03-06  84  		pfn++;
ae531c26c5c2a2 Arjan van de Ven  2008-04-24  85  	}
19e42009961255 David Hildenbrand 2021-08-11  86  #endif /* CONFIG_STRICT_DEVMEM */
19e42009961255 David Hildenbrand 2021-08-11 @87  	return !iomem_range_contains_excluded(PFN_PHYS(pfn), size);
ae531c26c5c2a2 Arjan van de Ven  2008-04-24  88  }
ae531c26c5c2a2 Arjan van de Ven  2008-04-24  89  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35188 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH v1 0/3] virtio-mem: disallow mapping virtio-mem memory via /dev/mem
@ 2021-08-11 20:36 David Hildenbrand
  2021-08-11 20:36   ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2021-08-11 20:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Jason Wang, Rafael J. Wysocki, Andrew Morton,
	Dan Williams, Hanjun Guo, Andy Shevchenko, virtualization,
	linux-mm

Let's add the basic infrastructure to exclude some physical memory
regions completely from /dev/mem access, on any architecture and under
any system configuration (independent of CONFIG_STRICT_DEVMEM and
independent of "iomem=").

Use it for virtio-mem, to disallow mapping any virtio-mem memory via
/dev/mem to user space after the virtio-mem driver was loaded: there is
no sane use case to access the device-managed memory region via /dev/mem
once the driver is actively (un)plugging memory within that region and
we want to make sure that nobody will accidentially access unplugged
memory in a sane environment.

Details can be found in patch #1.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: virtualization@lists.linux-foundation.org
Cc: linux-mm@kvack.org

David Hildenbrand (3):
  /dev/mem: disallow access to explicitly excluded system RAM regions
  virtio-mem: disallow mapping virtio-mem memory via /dev/mem
  kernel/resource: cleanup and optimize iomem_is_exclusive()

 drivers/char/mem.c          | 22 ++++++-------
 drivers/virtio/virtio_mem.c |  4 ++-
 include/linux/ioport.h      |  1 +
 kernel/resource.c           | 61 ++++++++++++++++++++++++++++++++-----
 lib/Kconfig.debug           |  4 ++-
 5 files changed, 69 insertions(+), 23 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-12  1:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12  1:42 [PATCH v1 1/3] /dev/mem: disallow access to explicitly excluded system RAM regions kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-08-11 20:36 [PATCH v1 0/3] virtio-mem: disallow mapping virtio-mem memory via /dev/mem David Hildenbrand
2021-08-11 20:36 ` [PATCH v1 1/3] /dev/mem: disallow access to explicitly excluded system RAM regions David Hildenbrand
2021-08-11 20:36   ` David Hildenbrand
2021-08-11 20:50   ` Andy Shevchenko
2021-08-11 20:50     ` Andy Shevchenko

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.