[Ocfs2-tools-devel] [PATCH] mkfs.ocfs2: return failed when heartbeat file corruption

piaojun piaojun at huawei.com
Sun Jan 27 17:26:26 PST 2019


LGTM

On 2019/1/25 16:26, Jia Guo wrote:
> 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, &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>
Reviewed-by: Jun Piao <piaojun 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;
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
> 



More information about the Ocfs2-tools-devel mailing list