From: Jamal Hadi Salim <jhs@mojatatu.com> Date: 2023-12-13 16:57:58
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Eric Dumazet <edumazet@google.com> Date: 2023-12-13 17:30:12
On Wed, Dec 13, 2023 at 5:57 PM Jamal Hadi Salim [off-list ref] wrote:
quoted hunk
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jamal Hadi Salim <jhs@mojatatu.com> Date: 2023-12-13 17:42:48
On Wed, Dec 13, 2023 at 12:30 PM Eric Dumazet [off-list ref] wrote:
On Wed, Dec 13, 2023 at 5:57 PM Jamal Hadi Salim [off-list ref] wrote:
quoted
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Eric Dumazet <edumazet@google.com> Date: 2023-12-13 17:42:50
On Wed, Dec 13, 2023 at 6:29 PM Eric Dumazet [off-list ref] wrote:
On Wed, Dec 13, 2023 at 5:57 PM Jamal Hadi Salim [off-list ref] wrote:
quoted
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jamal Hadi Salim <jhs@mojatatu.com> Date: 2023-12-13 17:53:20
On Wed, Dec 13, 2023 at 12:42 PM Eric Dumazet [off-list ref] wrote:
On Wed, Dec 13, 2023 at 6:29 PM Eric Dumazet [off-list ref] wrote:
quoted
On Wed, Dec 13, 2023 at 5:57 PM Jamal Hadi Salim [off-list ref] wrote:
quoted
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -159,7 +159,7 @@ struct fq_sched_data {/* return the i-th 2-bit value ("crumb") */staticu8fq_prio2band(constu8*prio2band,unsignedintprio){-return(prio2band[prio/4]>>(2*(prio&0x3)))&0x3;+return(prio2band[prio/4]>>(2*(prio&0x3)))%0x3;}
Are you sure this is needed ?
fq_load_priomap() makes sure this can not happen...
Yeah, I am pretty sure this patch is incorrect, we need to mask to get
only two bits.
The check in fq_load_priomap() is what makes it moot. Masking with
b'11 could result in b'11. Definitely the modulo will guarantee
whatever results can only be in the range 0..2. But it is not needed.
cheers,
jamal
From: Eric Dumazet <edumazet@google.com> Date: 2023-12-13 18:04:56
On Wed, Dec 13, 2023 at 6:53 PM Jamal Hadi Salim [off-list ref] wrote:
On Wed, Dec 13, 2023 at 12:42 PM Eric Dumazet [off-list ref] wrote:
quoted
On Wed, Dec 13, 2023 at 6:29 PM Eric Dumazet [off-list ref] wrote:
quoted
On Wed, Dec 13, 2023 at 5:57 PM Jamal Hadi Salim [off-list ref] wrote:
quoted
It is possible to compute a band of 3. Doing so will overrun array
q->band_pkt_count[0-2] boundaries.
Fixes: 29f834aa326e ("net_sched: sch_fq: add 3 bands and WRR scheduling")
Reported-by: Coverity Scan <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_fq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -159,7 +159,7 @@ struct fq_sched_data {/* return the i-th 2-bit value ("crumb") */staticu8fq_prio2band(constu8*prio2band,unsignedintprio){-return(prio2band[prio/4]>>(2*(prio&0x3)))&0x3;+return(prio2band[prio/4]>>(2*(prio&0x3)))%0x3;}
Are you sure this is needed ?
fq_load_priomap() makes sure this can not happen...
Yeah, I am pretty sure this patch is incorrect, we need to mask to get
only two bits.
The check in fq_load_priomap() is what makes it moot. Masking with
b'11 could result in b'11. Definitely the modulo will guarantee
whatever results can only be in the range 0..2. But it is not needed.
Modulo would be incorrect, since it would use high order bits.
(0x22 % 3) is different than (0x22 & 3)
Had you written:
return ((prio2band[prio / 4] >> (2 * (prio & 0x3))) & 0x3) % 3)
Then yes, the last % 3 would be "not needed"