Skip to content

Commit 73bdf0a

Browse files
torvaldsH. Peter Anvin
authored andcommitted
Introduce is_vmalloc_or_module_addr() and use with DEBUG_VIRTUAL
Impact: crash on module insertion with CONFIG_DEBUG_VIRTUAL We would incorrectly BUG due to: VIRTUAL_BUG_ON(!is_vmalloc_addr(vmalloc_addr) && !is_module_address(addr)); ... because, at least on x86-64, is_module_address() doesn't do what it should. This patch introduces is_vmalloc_or_module_addr(), which is what we really want anyway, and uses it instead. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent f61f1b5 commit 73bdf0a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎mm/vmalloc.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
168168
}
169169
EXPORT_SYMBOL_GPL(map_vm_area);
170170

171+
static inline int is_vmalloc_or_module_addr(const void *x)
172+
{
173+
/*
174+
* x86-64 and sparc64 put modules in a special place,
175+
* and fall back on vmalloc() if that fails. Others
176+
* just put it in the vmalloc space.
177+
*/
178+
#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
179+
unsigned long addr = (unsigned long)x;
180+
if (addr >= MODULES_VADDR && addr < MODULES_END)
181+
return 1;
182+
#endif
183+
return is_vmalloc_addr(x);
184+
}
185+
171186
/*
172187
* Map a vmalloc()-space virtual address to the physical page.
173188
*/
@@ -184,8 +199,7 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
184199
* XXX we might need to change this if we add VIRTUAL_BUG_ON for
185200
* architectures that do not vmalloc module space
186201
*/
187-
VIRTUAL_BUG_ON(!is_vmalloc_addr(vmalloc_addr) &&
188-
!is_module_address(addr));
202+
VIRTUAL_BUG_ON(!is_vmalloc_or_module_addr(vmalloc_addr));
189203

190204
if (!pgd_none(*pgd)) {
191205
pud = pud_offset(pgd, addr);

0 commit comments

Comments
 (0)