* [PATCH 5.4 096/156] net: sched: sch: Bounds check priority
[not found] <20230220133602.515342638@linuxfoundation.org>
@ 2023-02-20 13:35 ` Greg Kroah-Hartman
2023-02-21 7:45 ` Paolo Abeni
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-20 13:35 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, Kees Cook, Simon Horman, Cong Wang,
Sasha Levin
From: Kees Cook <keescook@chromium.org>
[ Upstream commit de5ca4c3852f896cacac2bf259597aab5e17d9e3 ]
Nothing was explicitly bounds checking the priority index used to access
clpriop[]. WARN and bail out early if it's pathological. Seen with GCC 13:
../net/sched/sch_htb.c: In function 'htb_activate_prios':
../net/sched/sch_htb.c:437:44: warning: array subscript [0, 31] is outside array bounds of 'struct htb_prio[8]' [-Warray-bounds=]
437 | if (p->inner.clprio[prio].feed.rb_node)
| ~~~~~~~~~~~~~~~^~~~~~
../net/sched/sch_htb.c:131:41: note: while referencing 'clprio'
131 | struct htb_prio clprio[TC_HTB_NUMPRIO];
| ^~~~~~
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Link: https://lore.kernel.org/r/20230127224036.never.561-kees@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/sched/sch_htb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 8184c87da8bec..e635713cb41dd 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -405,7 +405,10 @@ static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)
while (cl->cmode == HTB_MAY_BORROW && p && mask) {
m = mask;
while (m) {
- int prio = ffz(~m);
+ unsigned int prio = ffz(~m);
+
+ if (WARN_ON_ONCE(prio > ARRAY_SIZE(p->inner.clprio)))
+ break;
m &= ~(1 << prio);
if (p->inner.clprio[prio].feed.rb_node)
--
2.39.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5.4 096/156] net: sched: sch: Bounds check priority
2023-02-20 13:35 ` [PATCH 5.4 096/156] net: sched: sch: Bounds check priority Greg Kroah-Hartman
@ 2023-02-21 7:45 ` Paolo Abeni
2023-02-21 8:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2023-02-21 7:45 UTC (permalink / raw)
To: Greg Kroah-Hartman, stable
Cc: patches, Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
Eric Dumazet, Jakub Kicinski, netdev, Kees Cook, Simon Horman,
Cong Wang, Sasha Levin
Hello,
On Mon, 2023-02-20 at 14:35 +0100, Greg Kroah-Hartman wrote:
> From: Kees Cook <keescook@chromium.org>
>
> [ Upstream commit de5ca4c3852f896cacac2bf259597aab5e17d9e3 ]
>
> Nothing was explicitly bounds checking the priority index used to access
> clpriop[]. WARN and bail out early if it's pathological. Seen with GCC 13:
>
> ../net/sched/sch_htb.c: In function 'htb_activate_prios':
> ../net/sched/sch_htb.c:437:44: warning: array subscript [0, 31] is outside array bounds of 'struct htb_prio[8]' [-Warray-bounds=]
> 437 | if (p->inner.clprio[prio].feed.rb_node)
> | ~~~~~~~~~~~~~~~^~~~~~
> ../net/sched/sch_htb.c:131:41: note: while referencing 'clprio'
> 131 | struct htb_prio clprio[TC_HTB_NUMPRIO];
> | ^~~~~~
>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> Link: https://lore.kernel.org/r/20230127224036.never.561-kees@kernel.org
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
This one has a follow-up which I don't see among the patches reaching
the netdev ML:
commit 9cec2aaffe969f2a3e18b5ec105fc20bb908e475
Author: Dan Carpenter <error27@gmail.com>
Date: Mon Feb 6 16:18:32 2023 +0300
net: sched: sch: Fix off by one in htb_activate_prios()
Cheers,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.4 096/156] net: sched: sch: Bounds check priority
2023-02-21 7:45 ` Paolo Abeni
@ 2023-02-21 8:41 ` Greg Kroah-Hartman
2023-02-21 9:12 ` Paolo Abeni
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-21 8:41 UTC (permalink / raw)
To: Paolo Abeni
Cc: stable, patches, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S. Miller, Eric Dumazet, Jakub Kicinski, netdev, Kees Cook,
Simon Horman, Cong Wang, Sasha Levin
On Tue, Feb 21, 2023 at 08:45:18AM +0100, Paolo Abeni wrote:
> Hello,
>
> On Mon, 2023-02-20 at 14:35 +0100, Greg Kroah-Hartman wrote:
> > From: Kees Cook <keescook@chromium.org>
> >
> > [ Upstream commit de5ca4c3852f896cacac2bf259597aab5e17d9e3 ]
> >
> > Nothing was explicitly bounds checking the priority index used to access
> > clpriop[]. WARN and bail out early if it's pathological. Seen with GCC 13:
> >
> > ../net/sched/sch_htb.c: In function 'htb_activate_prios':
> > ../net/sched/sch_htb.c:437:44: warning: array subscript [0, 31] is outside array bounds of 'struct htb_prio[8]' [-Warray-bounds=]
> > 437 | if (p->inner.clprio[prio].feed.rb_node)
> > | ~~~~~~~~~~~~~~~^~~~~~
> > ../net/sched/sch_htb.c:131:41: note: while referencing 'clprio'
> > 131 | struct htb_prio clprio[TC_HTB_NUMPRIO];
> > | ^~~~~~
> >
> > Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > Cc: Jiri Pirko <jiri@resnulli.us>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Eric Dumazet <edumazet@google.com>
> > Cc: Jakub Kicinski <kuba@kernel.org>
> > Cc: Paolo Abeni <pabeni@redhat.com>
> > Cc: netdev@vger.kernel.org
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > Reviewed-by: Simon Horman <simon.horman@corigine.com>
> > Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> > Link: https://lore.kernel.org/r/20230127224036.never.561-kees@kernel.org
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
>
> This one has a follow-up which I don't see among the patches reaching
> the netdev ML:
>
> commit 9cec2aaffe969f2a3e18b5ec105fc20bb908e475
> Author: Dan Carpenter <error27@gmail.com>
> Date: Mon Feb 6 16:18:32 2023 +0300
>
> net: sched: sch: Fix off by one in htb_activate_prios()
This too is in the queue for 5.4 and newer kernels, are you sure you
didn't miss that in this series?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.4 096/156] net: sched: sch: Bounds check priority
2023-02-21 8:41 ` Greg Kroah-Hartman
@ 2023-02-21 9:12 ` Paolo Abeni
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2023-02-21 9:12 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, patches, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S. Miller, Eric Dumazet, Jakub Kicinski, netdev, Kees Cook,
Simon Horman, Cong Wang, Sasha Levin
On Tue, 2023-02-21 at 09:41 +0100, Greg Kroah-Hartman wrote:
> On Tue, Feb 21, 2023 at 08:45:18AM +0100, Paolo Abeni wrote:
> > Hello,
> >
> > On Mon, 2023-02-20 at 14:35 +0100, Greg Kroah-Hartman wrote:
> > > From: Kees Cook <keescook@chromium.org>
> > >
> > > [ Upstream commit de5ca4c3852f896cacac2bf259597aab5e17d9e3 ]
> > >
> > > Nothing was explicitly bounds checking the priority index used to access
> > > clpriop[]. WARN and bail out early if it's pathological. Seen with GCC 13:
> > >
> > > ../net/sched/sch_htb.c: In function 'htb_activate_prios':
> > > ../net/sched/sch_htb.c:437:44: warning: array subscript [0, 31] is outside array bounds of 'struct htb_prio[8]' [-Warray-bounds=]
> > > 437 | if (p->inner.clprio[prio].feed.rb_node)
> > > | ~~~~~~~~~~~~~~~^~~~~~
> > > ../net/sched/sch_htb.c:131:41: note: while referencing 'clprio'
> > > 131 | struct htb_prio clprio[TC_HTB_NUMPRIO];
> > > | ^~~~~~
> > >
> > > Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> > > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > > Cc: Jiri Pirko <jiri@resnulli.us>
> > > Cc: "David S. Miller" <davem@davemloft.net>
> > > Cc: Eric Dumazet <edumazet@google.com>
> > > Cc: Jakub Kicinski <kuba@kernel.org>
> > > Cc: Paolo Abeni <pabeni@redhat.com>
> > > Cc: netdev@vger.kernel.org
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > Reviewed-by: Simon Horman <simon.horman@corigine.com>
> > > Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> > > Link: https://lore.kernel.org/r/20230127224036.never.561-kees@kernel.org
> > > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> > > Signed-off-by: Sasha Levin <sashal@kernel.org>
> >
> > This one has a follow-up which I don't see among the patches reaching
> > the netdev ML:
> >
> > commit 9cec2aaffe969f2a3e18b5ec105fc20bb908e475
> > Author: Dan Carpenter <error27@gmail.com>
> > Date: Mon Feb 6 16:18:32 2023 +0300
> >
> > net: sched: sch: Fix off by one in htb_activate_prios()
>
> This too is in the queue for 5.4 and newer kernels, are you sure you
> didn't miss that in this series?
I missed it, sorry. I checked only my inbox and netdev, and it was not
there, but I see it in the stable queue.
Sorry for the noise,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-21 9:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230220133602.515342638@linuxfoundation.org>
2023-02-20 13:35 ` [PATCH 5.4 096/156] net: sched: sch: Bounds check priority Greg Kroah-Hartman
2023-02-21 7:45 ` Paolo Abeni
2023-02-21 8:41 ` Greg Kroah-Hartman
2023-02-21 9:12 ` Paolo Abeni
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).