[v1] lib/metrics: add check for invalid metric keys
Checks
Commit Message
This patchset adds a check to rte_metrics_update_values()
that prevents the updating of metrics when presented with
an invalid metric key. Previously, doing the latter could
result in a crash.
Fixes: 349950ddb9c5 ("metrics: add information metrics library")
Signed-off-by: Remy Horton <remy.horton@intel.com>
---
lib/librte_metrics/rte_metrics.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On 7/6/2018 2:21 PM, Remy Horton wrote:
> This patchset adds a check to rte_metrics_update_values()
> that prevents the updating of metrics when presented with
> an invalid metric key. Previously, doing the latter could
> result in a crash.
>
> Fixes: 349950ddb9c5 ("metrics: add information metrics library")
>
> Signed-off-by: Remy Horton <remy.horton@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Remy,
You are not new to DPDK. Please pay attention to details:
- subject does not start with lib/
- fixes of old commits must have Cc: stable@dpdk.org
20/07/2018 17:31, Ferruh Yigit:
> On 7/6/2018 2:21 PM, Remy Horton wrote:
> > This patchset adds a check to rte_metrics_update_values()
> > that prevents the updating of metrics when presented with
> > an invalid metric key. Previously, doing the latter could
> > result in a crash.
> >
> > Fixes: 349950ddb9c5 ("metrics: add information metrics library")
> >
> > Signed-off-by: Remy Horton <remy.horton@intel.com>
>
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied, thanks
Harry,
Can you add the following to the cheat-sheet? Don't do many patches
these days, and I'm not the only one to miss these recently..
..Remy
On 26/07/2018 19:11, Thomas Monjalon wrote:
> Remy,
> You are not new to DPDK. Please pay attention to details:
> - subject does not start with lib/
> - fixes of old commits must have Cc: stable@dpdk.org
>
> 20/07/2018 17:31, Ferruh Yigit:
>> On 7/6/2018 2:21 PM, Remy Horton wrote:
>>> This patchset adds a check to rte_metrics_update_values()
>>> that prevents the updating of metrics when presented with
>>> an invalid metric key. Previously, doing the latter could
>>> result in a crash.
>>>
>>> Fixes: 349950ddb9c5 ("metrics: add information metrics library")
>>>
>>> Signed-off-by: Remy Horton <remy.horton@intel.com>
>>
>> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> Applied, thanks
>
>
@@ -159,6 +159,11 @@ rte_metrics_update_values(int port_id,
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
+
+ if (key >= stats->cnt_stats) {
+ rte_spinlock_unlock(&stats->lock);
+ return -EINVAL;
+ }
idx_metric = key;
cnt_setsize = 1;
while (idx_metric < stats->cnt_stats) {