From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: stable@vger•kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
patches@lists•linux.dev, Jamal Hadi Salim <jhs@mojatatu•com>,
Cong Wang <xiyou.wangcong@gmail•com>,
Jiri Pirko <jiri@resnulli•us>,
"David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
netdev@vger•kernel.org, Kees Cook <keescook@chromium•org>,
Simon Horman <simon.horman@corigine•com>,
Cong Wang <cong.wang@bytedance•com>,
Sasha Levin <sashal@kernel•org>
Subject: [PATCH 5.15 15/83] net: sched: sch: Bounds check priority
Date: Mon, 20 Feb 2023 14:35:48 +0100 [thread overview]
Message-ID: <20230220133554.234461370@linuxfoundation.org> (raw)
In-Reply-To: <20230220133553.669025851@linuxfoundation.org>
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 45b92e40082ef..7ea8c73ddeff0 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -427,7 +427,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
parent reply other threads:[~2023-02-20 13:51 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20230220133553.669025851@linuxfoundation.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230220133554.234461370@linuxfoundation.org \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=cong.wang@bytedance$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=jhs@mojatatu$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=keescook@chromium$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=patches@lists$(echo .)linux.dev \
--cc=sashal@kernel$(echo .)org \
--cc=simon.horman@corigine$(echo .)com \
--cc=stable@vger$(echo .)kernel.org \
--cc=xiyou.wangcong@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox