lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1501751520-2598-1-git-send-email-wen.yang99@zte.com.cn>
Date:   Thu, 3 Aug 2017 17:12:00 +0800
From:   Wen Yang <wen.yang99@....com.cn>
To:     linux-mm@...ck.org
Cc:     akpm@...ux-foundation.org, mhocko@...e.com, vbabka@...e.cz,
        kirill.shutemov@...ux.intel.com, hannes@...xchg.org,
        linux-kernel@...r.kernel.org, wen.yang99@....com.cn,
        jiang.biao2@....com.cn
Subject: [PATCH] mm/vmstat: fix divide error at __fragmentation_index

When order is -1 or too big, *1UL << order* will be 0, which will
cause divide error. Although it seems that all callers of
__fragmentation_index() will only do so with a valid order, the
patch can make it more robust.

Sugguested-by: VlastimilBabka <vbabka@...e.cz>
Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@....com.cn>
---
 mm/vmstat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 76f7367..6f0f1ae 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -870,6 +870,9 @@ static int __fragmentation_index(unsigned int order, struct contig_page_info *in
 {
 	unsigned long requested = 1UL << order;
 
+	if (WARN_ON_ONCE(order >= MAX_ORDER))
+		return 0;
+
 	if (!info->free_blocks_total)
 		return 0;
 
-- 
2.7.4


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ