* [dpdk-dev] [PATCH v1 0/1] power: check freq count before filling the freqs array @ 2021-07-21 9:27 Richael Zhuang 2021-07-21 9:27 ` [dpdk-dev] [PATCH v1 1/1] " Richael Zhuang 0 siblings, 1 reply; 10+ messages in thread From: Richael Zhuang @ 2021-07-21 9:27 UTC (permalink / raw) To: dev v1: adding check for freq count Richael Zhuang (1): power: check freq count before filling the freqs array lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v1 1/1] power: check freq count before filling the freqs array 2021-07-21 9:27 [dpdk-dev] [PATCH v1 0/1] power: check freq count before filling the freqs array Richael Zhuang @ 2021-07-21 9:27 ` Richael Zhuang 2021-07-22 19:43 ` Thomas Monjalon 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 0/1] power: check freq count before filling the freqs Richael Zhuang 0 siblings, 2 replies; 10+ messages in thread From: Richael Zhuang @ 2021-07-21 9:27 UTC (permalink / raw) To: dev; +Cc: David Hunt The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the array with num_freqs elements, restrict the total num to RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue like: Overrunning array "pi->freqs" of 256 bytes by passing it to a function which accesses it at byte offset 464. Coverity issue: 371913 Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> --- lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index e92973ab54..db63c2cc10 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -246,6 +246,11 @@ power_get_available_freqs(struct cppc_power_info *pi) pi->nominal_perf * UNIT_DIFF : pi->nominal_perf; num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. */ for (i = 0, pi->nb_freqs = 0; i < num_freqs; i++) { diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 3b607515fd..619090c8d1 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -419,6 +419,11 @@ power_get_available_freqs(struct pstate_power_info *pi) */ num_freqs = (base_max_freq - sys_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. * If turbo is available the freq bucket[0] value is base_max +1 -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v1 1/1] power: check freq count before filling the freqs array 2021-07-21 9:27 ` [dpdk-dev] [PATCH v1 1/1] " Richael Zhuang @ 2021-07-22 19:43 ` Thomas Monjalon 2021-07-23 2:07 ` Richael Zhuang 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 0/1] power: check freq count before filling the freqs Richael Zhuang 1 sibling, 1 reply; 10+ messages in thread From: Thomas Monjalon @ 2021-07-22 19:43 UTC (permalink / raw) To: Richael Zhuang; +Cc: dev, David Hunt 21/07/2021 11:27, Richael Zhuang: > The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the > array with num_freqs elements, restrict the total num to > RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue > like: > Overrunning array "pi->freqs" of 256 bytes by passing it to a > function which accesses it at byte offset 464. > > Coverity issue: 371913 > > Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> Please provide "Fixes:" lines. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v1 1/1] power: check freq count before filling the freqs array 2021-07-22 19:43 ` Thomas Monjalon @ 2021-07-23 2:07 ` Richael Zhuang 0 siblings, 0 replies; 10+ messages in thread From: Richael Zhuang @ 2021-07-23 2:07 UTC (permalink / raw) To: thomas; +Cc: dev, David Hunt, nd, nd > -----Original Message----- > From: Thomas Monjalon <thomas@monjalon.net> > Sent: Friday, July 23, 2021 3:43 AM > To: Richael Zhuang <Richael.Zhuang@arm.com> > Cc: dev@dpdk.org; David Hunt <david.hunt@intel.com> > Subject: Re: [dpdk-dev] [PATCH v1 1/1] power: check freq count before filling > the freqs array > > 21/07/2021 11:27, Richael Zhuang: > > The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the array > > with num_freqs elements, restrict the total num to > > RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue > > like: > > Overrunning array "pi->freqs" of 256 bytes by passing it to a function > > which accesses it at byte offset 464. > > > > Coverity issue: 371913 > > > > Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> > > Please provide "Fixes:" lines. > > Thanks, I will add it. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2 0/1] power: check freq count before filling the freqs 2021-07-21 9:27 ` [dpdk-dev] [PATCH v1 1/1] " Richael Zhuang 2021-07-22 19:43 ` Thomas Monjalon @ 2021-07-23 2:13 ` Richael Zhuang 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 1/1] power: check freq count before filling the freqs array Richael Zhuang 1 sibling, 1 reply; 10+ messages in thread From: Richael Zhuang @ 2021-07-23 2:13 UTC (permalink / raw) To: dev v1: add check for freq count v2: add "Fixes" tag in commit message Richael Zhuang (1): power: check freq count before filling the freqs array lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2 1/1] power: check freq count before filling the freqs array 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 0/1] power: check freq count before filling the freqs Richael Zhuang @ 2021-07-23 2:13 ` Richael Zhuang 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 0/1] " Richael Zhuang 0 siblings, 1 reply; 10+ messages in thread From: Richael Zhuang @ 2021-07-23 2:13 UTC (permalink / raw) To: dev; +Cc: richael.zhuang, stable, David Hunt The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the array with num_freqs elements, restrict the total num to RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue like: Overrunning array "pi->freqs" of 256 bytes by passing it to a function which accesses it at byte offset 464. Coverity issue: 371913 Fixes: 82432c45d631 ("power: check freq count before filling") Cc: richael.zhuang@arm.com Cc: stable@dpdk.org Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> --- lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index e92973ab54..db63c2cc10 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -246,6 +246,11 @@ power_get_available_freqs(struct cppc_power_info *pi) pi->nominal_perf * UNIT_DIFF : pi->nominal_perf; num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. */ for (i = 0, pi->nb_freqs = 0; i < num_freqs; i++) { diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 3b607515fd..619090c8d1 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -419,6 +419,11 @@ power_get_available_freqs(struct pstate_power_info *pi) */ num_freqs = (base_max_freq - sys_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. * If turbo is available the freq bucket[0] value is base_max +1 -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v3 0/1] power: check freq count before filling the freqs array 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 1/1] power: check freq count before filling the freqs array Richael Zhuang @ 2021-07-23 2:22 ` Richael Zhuang 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 1/1] " Richael Zhuang 0 siblings, 1 reply; 10+ messages in thread From: Richael Zhuang @ 2021-07-23 2:22 UTC (permalink / raw) To: dev v1: add check for freq count v2: add "Fixes" tag in commit message v3: update commit message Richael Zhuang (1): power: check freq count before filling the freqs array lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v3 1/1] power: check freq count before filling the freqs array 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 0/1] " Richael Zhuang @ 2021-07-23 2:22 ` Richael Zhuang 2021-07-23 8:37 ` David Hunt 0 siblings, 1 reply; 10+ messages in thread From: Richael Zhuang @ 2021-07-23 2:22 UTC (permalink / raw) To: dev; +Cc: richael.zhuang, stable, David Hunt The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the array with num_freqs elements, restrict the total num to RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue like: Overrunning array "pi->freqs" of 256 bytes by passing it to a function which accesses it at byte offset 464. Coverity issue: 371913 Fixes: ef1cc88f1837 ("power: support cppc_cpufreq driver") Cc: richael.zhuang@arm.com Cc: stable@dpdk.org Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> --- lib/power/power_cppc_cpufreq.c | 5 +++++ lib/power/power_pstate_cpufreq.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index e92973ab54..db63c2cc10 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -246,6 +246,11 @@ power_get_available_freqs(struct cppc_power_info *pi) pi->nominal_perf * UNIT_DIFF : pi->nominal_perf; num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. */ for (i = 0, pi->nb_freqs = 0; i < num_freqs; i++) { diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 3b607515fd..619090c8d1 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -419,6 +419,11 @@ power_get_available_freqs(struct pstate_power_info *pi) */ num_freqs = (base_max_freq - sys_min_freq) / BUS_FREQ + 1 + pi->turbo_available; + if (num_freqs >= RTE_MAX_LCORE_FREQS) { + RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + num_freqs); + goto out; + } /* Generate the freq bucket array. * If turbo is available the freq bucket[0] value is base_max +1 -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3 1/1] power: check freq count before filling the freqs array 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 1/1] " Richael Zhuang @ 2021-07-23 8:37 ` David Hunt 2021-07-24 8:11 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon 0 siblings, 1 reply; 10+ messages in thread From: David Hunt @ 2021-07-23 8:37 UTC (permalink / raw) To: Richael Zhuang, dev; +Cc: stable Hi Richael, On 23/7/2021 3:22 AM, Richael Zhuang wrote: > The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the > array with num_freqs elements, restrict the total num to > RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue > like: > Overrunning array "pi->freqs" of 256 bytes by passing it to a > function which accesses it at byte offset 464. > > Coverity issue: 371913 > Fixes: ef1cc88f1837 ("power: support cppc_cpufreq driver") > Cc: richael.zhuang@arm.com > Cc: stable@dpdk.org > > Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> > --- > lib/power/power_cppc_cpufreq.c | 5 +++++ > lib/power/power_pstate_cpufreq.c | 5 +++++ > 2 files changed, 10 insertions(+) > ---snip--- LGTM to fix the coverity issue. Acked-by: David Hunt <david.hunt@intel.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH v3 1/1] power: check freq count before filling the freqs array 2021-07-23 8:37 ` David Hunt @ 2021-07-24 8:11 ` Thomas Monjalon 0 siblings, 0 replies; 10+ messages in thread From: Thomas Monjalon @ 2021-07-24 8:11 UTC (permalink / raw) To: Richael Zhuang; +Cc: dev, stable, David Hunt, david.marchand 23/07/2021 10:37, David Hunt: > Hi Richael, > > On 23/7/2021 3:22 AM, Richael Zhuang wrote: > > The freqs array size is RTE_MAX_LCORE_FREQS. Before filling the > > array with num_freqs elements, restrict the total num to > > RTE_MAX_LCORE_FREQS. This fix aims to fix the coverity scan issue > > like: > > Overrunning array "pi->freqs" of 256 bytes by passing it to a > > function which accesses it at byte offset 464. > > > > Coverity issue: 371913 > > Fixes: ef1cc88f1837 ("power: support cppc_cpufreq driver") > > Cc: richael.zhuang@arm.com > > Cc: stable@dpdk.org > > > > Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> > > LGTM to fix the coverity issue. > > Acked-by: David Hunt <david.hunt@intel.com> Removed the space before ":" and applied, thanks. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-07-24 8:10 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-07-21 9:27 [dpdk-dev] [PATCH v1 0/1] power: check freq count before filling the freqs array Richael Zhuang 2021-07-21 9:27 ` [dpdk-dev] [PATCH v1 1/1] " Richael Zhuang 2021-07-22 19:43 ` Thomas Monjalon 2021-07-23 2:07 ` Richael Zhuang 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 0/1] power: check freq count before filling the freqs Richael Zhuang 2021-07-23 2:13 ` [dpdk-dev] [PATCH v2 1/1] power: check freq count before filling the freqs array Richael Zhuang 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 0/1] " Richael Zhuang 2021-07-23 2:22 ` [dpdk-dev] [PATCH v3 1/1] " Richael Zhuang 2021-07-23 8:37 ` David Hunt 2021-07-24 8:11 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).