123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifdef HAVE_KVMALLOC
- void *lkm_realloc(void *ptr, size_t newsize) {
- void *nptr;
- size_t oldsize;
- if (unlikely(newsize == 0)) {
- kvfree(ptr);
- return ZERO_SIZE_PTR;
- }
- if (unlikely(ptr == NULL))
- return kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE);
- if (is_vmalloc_addr(ptr)) {
-
- return NULL;
- } else {
- #ifndef __PIE__
- struct page *page;
- page = virt_to_head_page(ptr);
- if (PageSlab(page) || PageCompound(page)) {
- if (newsize < PAGE_SIZE)
- #endif
- return krealloc(ptr, newsize, GFP_KERNEL);
- #ifndef __PIE__
- oldsize = ksize(ptr);
- } else {
- oldsize = page->private;
- if (newsize <= oldsize)
- return ptr;
- }
- #endif
- }
- nptr = kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE);
- if (nptr != NULL) {
- memcpy(nptr, ptr, oldsize);
- kvfree(ptr);
- }
- return nptr;
- }
- #endif
- #if defined(__PIE__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
- void my__show_free_areas(
- unsigned int flags,
- nodemask_t *nodemask,
- int max_zone_idx)
- {
- (void)flags;
- (void)nodemask;
- (void)max_zone_idx;
- return;
- }
- #endif
- #if defined(__PIE__) && defined(CONFIG_FORTIFY_SOURCE)
- void __my_fortify_panic(const char *name) {
- pr_emerg("__my_fortify_panic in %s\n", name);
- BUG();
- }
- #endif
|