euleros inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7JI6K CVE: NA
------------------------------------------------------------
In the swapcache recycling process, the number of pages to be reclaimed on each node is obtained as follows:
nr_to_reclaim[nid_num] = (swapcache_to_reclaim / (swapcache_total_reclaimable / nr[nid_num]));
However, nr[nid_num] is obtained by traversing the number of swapcache pages on each node. If there are multiple nodes in the environment and no swap process occurs on a node, no swapcache page exists. The value of nr[nid_num] may be 0.
Therefore, division by zero errors may occur.
Signed-off-by: liubo liubo254@huawei.com --- mm/vmscan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c index f5671facdc51..00ed94bfea78 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4819,9 +4819,12 @@ int do_swapcache_reclaim(unsigned long *swapcache_watermark, for_each_node_state(nid, N_MEMORY) { cond_resched();
- nr_to_reclaim[nid_num] = (swapcache_to_reclaim / (swapcache_total_reclaimable / nr[nid_num])); + nr_to_reclaim[nid_num] = (swapcache_total_reclaimable == 0) ? 0 : + ((swapcache_to_reclaim * nr[nid_num]) / + swapcache_total_reclaimable); reclaim_page_count += reclaim_swapcache_pages_from_list(nid, - &swapcache_list[nid_num], nr_to_reclaim[nid_num], false); + &swapcache_list[nid_num], + nr_to_reclaim[nid_num], false); nid_num++; }
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/1374 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/1374 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z...