From f61472c3f4a7c3d4832f4fc735575bf4634935c7 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Fri, 26 Feb 2021 03:19:17 -0500 Subject: [PATCH] Validate seq cutoff threshold value Signed-off-by: Michal Mielewczyk --- inc/ocf_def.h | 2 ++ src/mngt/ocf_mngt_core.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/inc/ocf_def.h b/inc/ocf_def.h index 26934d4..5d9c95a 100644 --- a/inc/ocf_def.h +++ b/inc/ocf_def.h @@ -176,6 +176,8 @@ typedef enum { } ocf_cache_mode_t; #define OCF_SEQ_CUTOFF_MAX_STREAMS 256 +#define OCF_SEQ_CUTOFF_MIN_THRESHOLD 1 +#define OCF_SEQ_CUTOFF_MAX_THRESHOLD 4194181 typedef enum { ocf_seq_cutoff_policy_always = 0, diff --git a/src/mngt/ocf_mngt_core.c b/src/mngt/ocf_mngt_core.c index c76d54c..19300b6 100644 --- a/src/mngt/ocf_mngt_core.c +++ b/src/mngt/ocf_mngt_core.c @@ -898,6 +898,13 @@ static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx uint32_t threshold = *(uint32_t*) cntx; uint32_t threshold_old = ocf_core_get_seq_cutoff_threshold(core); + if (threshold < OCF_SEQ_CUTOFF_MIN_THRESHOLD || + threshold > OCF_SEQ_CUTOFF_MAX_THRESHOLD) { + ocf_core_log(core, log_info, + "Invalid sequential cutoff threshold!\n"); + return -OCF_ERR_INVAL; + } + if (threshold_old == threshold) { ocf_core_log(core, log_info, "Sequential cutoff threshold %u bytes is "