Hailong.Liu
c55d3564ad
mm/vmalloc: fix vmalloc which may return null if called with __GFP_NOFAIL
...
commit 8e0545c83d672750632f46e3f9ad95c48c91a0fc upstream.
commit a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc")
includes support for __GFP_NOFAIL, but it presents a conflict with commit
dd544141b9eb ("vmalloc: back off when the current task is OOM-killed"). A
possible scenario is as follows:
process-a
__vmalloc_node_range(GFP_KERNEL | __GFP_NOFAIL)
__vmalloc_area_node()
vm_area_alloc_pages()
--> oom-killer send SIGKILL to process-a
if (fatal_signal_pending(current)) break;
--> return NULL;
To fix this, do not check fatal_signal_pending() in vm_area_alloc_pages()
if __GFP_NOFAIL set.
This issue occurred during OPLUS KASAN TEST. Below is part of the log
-> oom-killer sends signal to process
[65731.222840] [ T1308] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/apps/uid_10198,task=gs.intelligence,pid=32454,uid=10198
[65731.259685] [T32454] Call trace:
[65731.259698] [T32454] dump_backtrace+0xf4/0x118
[65731.259734] [T32454] show_stack+0x18/0x24
[65731.259756] [T32454] dump_stack_lvl+0x60/0x7c
[65731.259781] [T32454] dump_stack+0x18/0x38
[65731.259800] [T32454] mrdump_common_die+0x250/0x39c [mrdump]
[65731.259936] [T32454] ipanic_die+0x20/0x34 [mrdump]
[65731.260019] [T32454] atomic_notifier_call_chain+0xb4/0xfc
[65731.260047] [T32454] notify_die+0x114/0x198
[65731.260073] [T32454] die+0xf4/0x5b4
[65731.260098] [T32454] die_kernel_fault+0x80/0x98
[65731.260124] [T32454] __do_kernel_fault+0x160/0x2a8
[65731.260146] [T32454] do_bad_area+0x68/0x148
[65731.260174] [T32454] do_mem_abort+0x151c/0x1b34
[65731.260204] [T32454] el1_abort+0x3c/0x5c
[65731.260227] [T32454] el1h_64_sync_handler+0x54/0x90
[65731.260248] [T32454] el1h_64_sync+0x68/0x6c
[65731.260269] [T32454] z_erofs_decompress_queue+0x7f0/0x2258
--> be->decompressed_pages = kvcalloc(be->nr_pages, sizeof(struct page *), GFP_KERNEL | __GFP_NOFAIL);
kernel panic by NULL pointer dereference.
erofs assume kvmalloc with __GFP_NOFAIL never return NULL.
[65731.260293] [T32454] z_erofs_runqueue+0xf30/0x104c
[65731.260314] [T32454] z_erofs_readahead+0x4f0/0x968
[65731.260339] [T32454] read_pages+0x170/0xadc
[65731.260364] [T32454] page_cache_ra_unbounded+0x874/0xf30
[65731.260388] [T32454] page_cache_ra_order+0x24c/0x714
[65731.260411] [T32454] filemap_fault+0xbf0/0x1a74
[65731.260437] [T32454] __do_fault+0xd0/0x33c
[65731.260462] [T32454] handle_mm_fault+0xf74/0x3fe0
[65731.260486] [T32454] do_mem_abort+0x54c/0x1b34
[65731.260509] [T32454] el0_da+0x44/0x94
[65731.260531] [T32454] el0t_64_sync_handler+0x98/0xb4
[65731.260553] [T32454] el0t_64_sync+0x198/0x19c
Link: https://lkml.kernel.org/r/20240510100131.1865-1-hailong.liu@oppo.com
Fixes: 9376130c390a ("mm/vmalloc: add support for __GFP_NOFAIL")
Signed-off-by: Hailong.Liu <hailong.liu@oppo.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Suggested-by: Barry Song <21cnbao@gmail.com>
Reported-by: Oven <liyangouwen1@oppo.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Gao Xiang <xiang@kernel.org>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-16 13:47:42 +02:00
..
2024-06-12 11:12:52 +02:00
2024-04-03 15:28:20 +02:00
2023-09-08 12:16:52 -07:00
2024-06-16 13:47:41 +02:00
2024-02-23 09:25:16 +01:00
2023-03-28 16:20:06 -07:00
2024-06-16 13:47:42 +02:00
2024-05-02 16:32:41 +02:00
2023-06-09 16:25:23 -07:00
2024-03-06 14:48:41 +00:00
2023-06-09 16:25:31 -07:00
2023-04-05 19:42:38 -07:00
2023-06-09 16:25:17 -07:00
2023-06-09 16:25:56 -07:00
2023-06-23 16:59:31 -07:00
2023-06-09 16:25:23 -07:00
2024-04-03 15:28:55 +02:00
2023-07-24 18:04:30 -04:00
2023-06-23 16:58:19 -07:00
2024-05-02 16:32:40 +02:00
2023-06-19 16:19:25 -07:00
2023-08-21 13:07:20 -07:00
2024-06-16 13:47:40 +02:00
2023-02-13 15:54:27 -08:00
2023-08-18 10:12:14 -07:00
2024-06-16 13:47:42 +02:00
2023-08-21 13:37:46 -07:00
2024-05-02 16:32:40 +02:00
2023-08-18 10:12:36 -07:00
2023-08-29 14:25:26 -07:00
2023-05-29 16:14:28 +01:00
2023-08-29 14:25:26 -07:00
2023-09-02 15:17:34 -07:00
2024-06-16 13:47:41 +02:00
2023-04-12 17:36:23 -07:00
2024-05-02 16:32:40 +02:00
2023-08-29 14:25:26 -07:00
2023-08-24 16:20:30 -07:00
2024-03-01 13:35:06 +01:00
2024-03-01 13:35:00 +01:00
2023-09-05 11:11:52 -07:00
2024-01-20 11:51:49 +01:00
2024-04-27 17:11:42 +02:00
2023-08-18 10:12:38 -07:00
2024-04-10 16:36:03 +02:00
2023-11-20 11:58:51 +01:00
2023-02-09 16:51:46 -08:00
2024-04-03 15:28:33 +02:00
2023-08-31 12:20:12 -07:00
2024-03-15 10:48:14 -04:00
2023-08-21 13:07:20 -07:00
2023-08-21 14:26:20 -07:00
2024-01-31 16:18:56 -08:00
2024-04-03 15:28:40 +02:00
2023-08-24 16:20:30 -07:00
2023-08-18 10:12:41 -07:00
2023-08-31 12:20:12 -07:00
2023-09-16 15:23:31 -07:00
2023-08-31 12:20:12 -07:00
2023-08-21 13:37:44 -07:00
2024-05-02 16:32:41 +02:00
2023-08-18 10:12:31 -07:00
2023-01-18 17:12:52 -08:00
2023-08-21 13:37:27 -07:00
2023-08-18 10:12:39 -07:00
2023-08-21 13:37:27 -07:00
2023-08-21 13:37:30 -07:00
2024-05-02 16:32:41 +02:00
2023-08-24 16:20:18 -07:00
2023-08-18 10:12:13 -07:00
2024-02-23 09:25:16 +01:00
2023-09-02 08:39:21 -07:00
2023-06-19 16:19:29 -07:00
2024-02-16 19:10:52 +01:00
2024-06-16 13:47:40 +02:00
2023-06-09 16:25:25 -07:00
2023-06-19 16:19:24 -07:00
2024-05-17 12:02:36 +02:00
2023-09-29 17:20:47 -07:00
2023-08-21 13:38:02 -07:00
2024-04-03 15:28:54 +02:00
2024-04-27 17:11:42 +02:00
2024-05-02 16:32:41 +02:00
2023-06-19 13:19:34 -07:00
2023-04-05 19:42:46 -07:00
2023-10-11 15:24:49 +02:00
2023-07-18 10:07:47 +02:00
2023-07-18 10:07:47 +02:00
2023-07-14 09:57:21 +02:00
2023-08-18 10:12:53 -07:00
2024-01-31 16:18:56 -08:00
2023-08-24 16:20:28 -07:00
2023-06-23 16:59:30 -07:00
2024-03-01 13:35:00 +01:00
2024-04-03 15:28:27 +02:00
2023-08-29 14:25:26 -07:00
2023-04-12 17:36:23 -07:00
2024-06-12 11:11:33 +02:00
2023-11-28 17:20:08 +00:00
2024-06-16 13:47:42 +02:00
2023-08-16 12:21:32 +01:00
2024-04-03 15:28:44 +02:00
2024-05-02 16:32:41 +02:00
2024-06-16 13:47:31 +02:00
2023-08-21 13:37:51 -07:00
2023-06-19 16:19:27 -07:00
2023-06-19 16:19:27 -07:00
2023-08-21 14:26:20 -07:00
2024-03-01 13:35:10 +01:00