[Ocfs2-tools-devel] [PATCH] mkfs.ocfs2: return failed when heartbeat file corruption
Jia Guo
guojia12 at huawei.com
Fri Jan 25 00:26:41 PST 2019
It will cause kernel panic if we set the heartbeat slot number
less than O2NM_MAX_NODES. The panic stack is generated as follows:
o2hb_thread
\-o2hb_do_disk_heartbeat
|-membership_change |= o2hb_check_slot(reg, ®->hr_slots[i]);
The value of i will out of array range(reg->hr_slots) when there is
a node number greater than the heartbeat slot number we set.
We need check the value of heartbeat slot number.
Signed-off-by: Jia Guo <guojia12 at huawei.com>
---
libocfs2/heartbeat.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libocfs2/heartbeat.c b/libocfs2/heartbeat.c
index b83cdfb..aa5afa5 100644
--- a/libocfs2/heartbeat.c
+++ b/libocfs2/heartbeat.c
@@ -98,7 +98,10 @@ errcode_t ocfs2_fill_heartbeat_desc(ocfs2_filesys *fs,
blocks = ocfs2_rec_clusters(0, rec) << cluster_bits;
blocks >>= block_bits;
- if (blocks > O2NM_MAX_NODES)
+ if (blocks < O2NM_MAX_NODES) {
+ ret = OCFS2_ET_BAD_HEARTBEAT_FILE;
+ goto leave;
+ } else
blocks = O2NM_MAX_NODES;
start_block = rec->e_blkno << block_bits;
More information about the Ocfs2-tools-devel
mailing list