History

vmalloc: fix NULL pointer dereference in is_vm_area_hugepages()

find_vm_area() can return NULL if the given address is not a valid vmalloc area. Check the return value before dereferencing it to avoid a kernel crash.

Hui Zhu committed 5 months ago

Commit c55dd3b1 parent d3d58e91 file · +3 −1Browse files

Unified · Split

include/linux/vmalloc.h+3−1
@@ -265,7 +265,9 @@ static inline bool is_vm_area_hugepages(const void *addr) · 264 unmodified lines
265265 * allocated in the vmalloc layer.
266266 */
267267 #ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC
268− return find_vm_area(addr)->page_order > 0;
268+ struct vm_struct *area = find_vm_area(addr);
269+
270+ return area && area->page_order > 0;
269271 #else
270272 return false;
271273 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t