diff options
| author | Vijayanand Jitta <[email protected]> | 2021-04-30 05:59:07 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2021-04-30 18:20:40 +0000 |
| commit | ad216c0316ad6391d90f4de0a7f59396b2925a06 (patch) | |
| tree | 478afea7154377d038c9e306bb737292b986d9ac /lib/test_vmalloc.c | |
| parent | mm/vmalloc: improve allocation failure error messages (diff) | |
| download | kernel-ad216c0316ad6391d90f4de0a7f59396b2925a06.tar.gz kernel-ad216c0316ad6391d90f4de0a7f59396b2925a06.zip | |
mm: vmalloc: prevent use after free in _vm_unmap_aliases
A potential use after free can occur in _vm_unmap_aliases where an already
freed vmap_area could be accessed, Consider the following scenario:
Process 1 Process 2
__vm_unmap_aliases __vm_unmap_aliases
purge_fragmented_blocks_allcpus rcu_read_lock()
rcu_read_lock()
list_del_rcu(&vb->free_list)
list_for_each_entry_rcu(vb .. )
__purge_vmap_area_lazy
kmem_cache_free(va)
va_start = vb->va->va_start
Here Process 1 is in purge path and it does list_del_rcu on vmap_block and
later frees the vmap_area, since Process 2 was holding the rcu lock at
this time vmap_block will still be present in and Process 2 accesse it and
thereby it tries to access vmap_area of that vmap_block which was already
freed by Process 1 and this results in use after free.
Fix this by adding a check for vb->dirty before accessing vmap_area
structure since vb->dirty will be set to VMAP_BBMAP_BITS in purge path
checking for this will prevent the use after free.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vijayanand Jitta <[email protected]>
Reviewed-by: Uladzislau Rezki (Sony) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/test_vmalloc.c')
0 files changed, 0 insertions, 0 deletions
