if (flags & MAP_FIXED) { /* Even MAP_FIXED mappings must reside within TASK_SIZE */ if (TASK_SIZE - len < addr) return -EINVAL;
/* * We do not accept a shared mapping if it would violate * cache aliasing constraints.
*/ if ((flags & MAP_SHARED) &&
((addr - (pgoff << PAGE_SHIFT)) & SHM_ALIGN_MASK)) return -EINVAL; return addr;
}
/* * A failed mmap() very likely causes application failure, * so fall back to the bottom-up function here. This scenario * can happen with large stack limits and large mmap() * allocations.
*/
}
/* * There is no need to export this but sched.h declares the function as * extern so making it static here results in an error.
*/ unsignedlong arch_get_unmapped_area_topdown(struct file *filp, unsignedlong addr0, unsignedlong len, unsignedlong pgoff, unsignedlong flags, vm_flags_t vm_flags)
{ return arch_get_unmapped_area_common(filp,
addr0, len, pgoff, flags, DOWN);
}
int __virt_addr_valid(volatilevoid *kaddr)
{ unsignedlong vaddr = (unsignedlong)kaddr;
if (is_kfence_address((void *)kaddr)) return 1;
if ((vaddr < PAGE_OFFSET) || (vaddr >= vm_map_base)) return 0;
/* * You really shouldn't be using read() or write() on /dev/mem. This might go * away in the future.
*/ int valid_phys_addr_range(phys_addr_t addr, size_t size)
{ /* * Check whether addr is covered by a memory region without the * MEMBLOCK_NOMAP attribute, and whether that region covers the * entire range. In theory, this could lead to false negatives * if the range is covered by distinct but adjacent memory regions * that only differ in other attributes. However, few of such * attributes have been defined, and it is debatable whether it * follows that /dev/mem read() calls should be able traverse * such boundaries.
*/ return memblock_is_region_memory(addr, size) && memblock_is_map_memory(addr);
}
/* * Do not allow /dev/mem mappings beyond the supported physical range.
*/ int valid_mmap_phys_addr_range(unsignedlong pfn, size_t size)
{ return !(((pfn << PAGE_SHIFT) + size) & ~(GENMASK_ULL(cpu_pabits, 0)));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.