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: <1635147078-2409190-1-git-send-email-jiasheng@iscas.ac.cn>
Date:   Mon, 25 Oct 2021 07:31:18 +0000
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     viro@...iv.linux.org.uk
Cc:     linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] seq_file: Fix potential addition overflow

After seq_hlist_start_percpu(), the value of &iter->li_cpu might be
MAX_UINT.
In that case, there will be addition overflow in the cpumask_next().
Therefore, it might be better to add the check before.

Fixes: 0bc7738 ("seq_file: add seq_list_*_percpu helpers")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 fs/seq_file.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/seq_file.c b/fs/seq_file.c
index 5059248..f768c28 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -1105,6 +1105,9 @@ seq_hlist_next_percpu(void *v, struct hlist_head __percpu *head,
 	if (node->next)
 		return node->next;
 
+	if (*cpu >= nr_cpu_ids)
+		return NULL;
+
 	for (*cpu = cpumask_next(*cpu, cpu_possible_mask); *cpu < nr_cpu_ids;
 	     *cpu = cpumask_next(*cpu, cpu_possible_mask)) {
 		struct hlist_head *bucket = per_cpu_ptr(head, *cpu);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ