Patch "net: sched: sch: Bounds check priority" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: sched: sch: Bounds check priority

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-sched-sch-bounds-check-priority.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1b236b34082c3b2d948248e9f9ed0c2999208519
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Fri Jan 27 14:40:37 2023 -0800

    net: sched: sch: Bounds check priority
    
    [ 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@xxxxxxxxxxxx>
    Cc: Cong Wang <xiyou.wangcong@xxxxxxxxx>
    Cc: Jiri Pirko <jiri@xxxxxxxxxxx>
    Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
    Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
    Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
    Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
    Cc: netdev@xxxxxxxxxxxxxxx
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Reviewed-by: Simon Horman <simon.horman@xxxxxxxxxxxx>
    Reviewed-by: Cong Wang <cong.wang@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230127224036.never.561-kees@xxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index c3ba018fd083e..c3e773d2ca419 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)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux