Revision b71871395cf3a0ca7c0a7d79b4faa584ac872809 authored by Linus Torvalds on 23 March 2024, 15:43:21 UTC, committed by Linus Torvalds on 23 March 2024, 15:43:21 UTC
Pull more hardening updates from Kees Cook:

 - CONFIG_MEMCPY_SLOW_KUNIT_TEST is no longer needed (Guenter Roeck)

 - Fix needless UTF-8 character in arch/Kconfig (Liu Song)

 - Improve __counted_by warning message in LKDTM (Nathan Chancellor)

 - Refactor DEFINE_FLEX() for default use of __counted_by

 - Disable signed integer overflow sanitizer on GCC < 8

* tag 'hardening-v6.9-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  lkdtm/bugs: Improve warning message for compilers without counted_by support
  overflow: Change DEFINE_FLEX to take __counted_by member
  Revert "kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST"
  arch/Kconfig: eliminate needless UTF-8 character in Kconfig help
  ubsan: Disable signed integer overflow sanitizer on GCC < 8
2 parent s bfa8f18 + 231dc3f
Raw File
io-mapping.c
// SPDX-License-Identifier: GPL-2.0-only

#include <linux/mm.h>
#include <linux/io-mapping.h>

/**
 * io_mapping_map_user - remap an I/O mapping to userspace
 * @iomap: the source io_mapping
 * @vma: user vma to map to
 * @addr: target user address to start at
 * @pfn: physical address of kernel memory
 * @size: size of map area
 *
 *  Note: this is only safe if the mm semaphore is held when called.
 */
int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma,
		unsigned long addr, unsigned long pfn, unsigned long size)
{
	vm_flags_t expected_flags = VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;

	if (WARN_ON_ONCE((vma->vm_flags & expected_flags) != expected_flags))
		return -EINVAL;

	/* We rely on prevalidation of the io-mapping to skip track_pfn(). */
	return remap_pfn_range_notrack(vma, addr, pfn, size,
		__pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) |
			 (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK)));
}
EXPORT_SYMBOL_GPL(io_mapping_map_user);
back to top