Skip to contentSkip to conversation

examples/vm_power_manager: fix buffer overrun

PATCH Superseded David Hunt 4 participants 12 messages Apr 10, 2019 – May 2, 2019

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 examples/vm_power_manager: fix buffer overrun

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
     Coverity issue: 337660
---
 examples/vm_power_manager/power_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vm_power_manager/power_manager.c +1 -1
index aef832644..35be30d2e 100644
@@ -143,7 +143,7 @@ power_manager_get_current_frequency(unsigned core_num)
 	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
 	index = rte_power_get_freq(core_num);
 	rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl);
-	if (index >= POWER_MGR_MAX_CPUS)
+	if (index >= RTE_MAX_LCORE_FREQS)
 		freq = 0;
 	else
 		freq = global_core_freq_info[core_num].freqs[index];
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Hunt
Sent: Wednesday, April 10, 2019 1:49 PM
To: [email protected]
Cc: Hunt, David <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix buffer overrun

Quoted 2 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS,

Couple of nit-picks,

:%s/ attempt/ attempt

Quoted 5 lines

which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
     Coverity issue: 337660

Candidate for [email protected]?

Thanks,
Reshma

#2 lore raw
Quoted 3 lines · Reshma
Quoted 2 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
     Coverity issue: 337660

Candidate for [email protected]?

There is no reply to this comment - re-asking as I will probably have the same question in a few weeks :-)

#3 lore raw

Hi Kevin,

Quoted 6 lines · Kevin Traynor
Quoted 3 lines · Reshma
Quoted 2 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
      Coverity issue: 337660

Candidate for [email protected]?

There is no reply to this comment - re-asking as I will probably have the same question in a few weeks :-)

There was a v2 this morning and it had a --cc stable on it. :)

Rgds,
Dave.

#4 lore raw
Quoted 4 lines · David

Hi Kevin,

Quoted 1 line · Kevin Traynor

On 18/04/2019 16:14, Pattan, Reshma wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
      Coverity issue: 337660

Candidate for [email protected]?

There is no reply to this comment - re-asking as I will probably have the same question in a few weeks :-)

There was a v2 this morning and it had a --cc stable on it. :)

Yes, you're right, but that just puts it in the email and it gets lost from the commit message. The 'Cc: [email protected]' tag is needed in the commit message so it can be picked up by scripts later when finding which patches should be backported.

https://doc.dpdk.org/guides/contributing/stable.html#what-changes-should-be-backported

As it's discussed, maybe Thomas can add it for this patch when applying.

thanks,
Kevin.

Quoted 3 lines

Rgds,
Dave.

#5 lore raw
In reply to David Hunt

10/04/2019 14:49, David Hunt:

Quoted 9 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
     Coverity issue: 337660

It seems to have been fixed in another patch, isn't it?

#6 lore raw

Hi Thomas,

Quoted 6 lines · Thomas Monjalon

10/04/2019 14:49, David Hunt:

Quoted 5 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Quoted 6 lines
Quoted 4 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
      Coverity issue: 337660

It seems to have been fixed in another patch, isn't it?

It was not fixed in another patch, although I can see the confusion.

A previous patch made the #defines more consistent, and POWER_MGR_MAX_CPUS was changed to RTE_MAX_LCORE on the affected line. However, this was later revealed as a coverity issue, and was fixed in this patch to be RTE_LCORE_MAX_FREQS, which is the size of the array it's trying to index into.

So looking at RC2, this patch is still needed.

Rgds,
Dave.

#7 lore raw

23/04/2019 10:21, Hunt, David:

Quoted 18 lines

Hi Thomas,

Quoted 6 lines · Thomas Monjalon

10/04/2019 14:49, David Hunt:

Quoted 5 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Quoted 6 lines
Quoted 4 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
      Coverity issue: 337660

It seems to have been fixed in another patch, isn't it?

It was not fixed in another patch, although I can see the confusion.

Quoted 7 lines

A previous patch made the #defines more consistent, and POWER_MGR_MAX_CPUS was changed to RTE_MAX_LCORE on the affected line. However, this was later revealed as a coverity issue, and was fixed in this patch to be RTE_LCORE_MAX_FREQS, which is the size of the array it's trying to index into.

So looking at RC2, this patch is still needed.

I think it needs to be rebased in a v2 then.

#8 lore raw
Quoted 18 lines · Thomas Monjalon

23/04/2019 10:21, Hunt, David:

Quoted 17 lines

Hi Thomas,

Quoted 6 lines · Thomas Monjalon

10/04/2019 14:49, David Hunt:

Quoted 5 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attemtp to look at the index at POWER_MANAGER_MAX_CPUS, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Quoted 6 lines
Quoted 4 lines
Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
       Coverity issue: 337660

It seems to have been fixed in another patch, isn't it?

It was not fixed in another patch, although I can see the confusion.

Quoted 9 lines
Quoted 7 lines

A previous patch made the #defines more consistent, and POWER_MGR_MAX_CPUS was changed to RTE_MAX_LCORE on the affected line. However, this was later revealed as a coverity issue, and was fixed in this patch to be RTE_LCORE_MAX_FREQS, which is the size of the array it's trying to index into.

So looking at RC2, this patch is still needed.

I think it needs to be rebased in a v2 then.

Sure, will do.

author
#9 lore raw

PATCH v2 1/1 examples/vm_power_manager: fix buffer overrun

In reply to David Hunt

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attempt to look at the index at RTE_MAX_LCORE, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")
     Coverity issue: 337660

---
v2 - Rebase to 19.05 RC2.

---
 examples/vm_power_manager/power_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vm_power_manager/power_manager.c +1 -1
index 9553455be..9d4e587b0 100644
@@ -143,7 +143,7 @@ power_manager_get_current_frequency(unsigned core_num)
 	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
 	index = rte_power_get_freq(core_num);
 	rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl);
-	if (index >= RTE_MAX_LCORE)
+	if (index >= RTE_MAX_LCORE_FREQS)
 		freq = 0;
 	else
 		freq = global_core_freq_info[core_num].freqs[index];
Signature · 1 line
2.17.1
author
#10 lore raw

PATCH v3 1/1 examples/vm_power_manager: fix buffer overrun

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attempt to look at the index at RTE_MAX_LCORE, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")

Coverity issue: 337660

---
v2 - Rebase to 19.05 RC2.
v3 - add CC stable

---
 examples/vm_power_manager/power_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vm_power_manager/power_manager.c +1 -1
index 9553455be..9d4e587b0 100644
@@ -143,7 +143,7 @@ power_manager_get_current_frequency(unsigned core_num)
 	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
 	index = rte_power_get_freq(core_num);
 	rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl);
-	if (index >= RTE_MAX_LCORE)
+	if (index >= RTE_MAX_LCORE_FREQS)
 		freq = 0;
 	else
 		freq = global_core_freq_info[core_num].freqs[index];
Signature · 1 line
2.17.1
#11 lore raw

26/04/2019 10:42, David Hunt:

Quoted 10 lines

The freqs array in freq_info struct has RTE_MAX_LCORE_FREQS elements, yet the code can attempt to look at the index at RTE_MAX_LCORE, which may be greater than RTE_MAX_LCORE_FREQS. Fix to limit index to RTE_MAX_LCORE_FREQS.

Fixes d26c18c93260 ("examples/vm_power: cpu frequency in host")

Coverity issue: 337660

Applied, thanks