• Pedro Tammela's avatar
    net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve · a13b67c9
    Pedro Tammela authored
    Christian Theune says:
       I upgraded from 6.1.38 to 6.1.55 this morning and it broke my traffic shaping script,
       leaving me with a non-functional uplink on a remote router.
    
    A 'rt' curve cannot be used as a inner curve (parent class), but we were
    allowing such configurations since the qdisc was introduced. Such
    configurations would trigger a UAF as Budimir explains:
       The parent will have vttree_insert() called on it in init_vf(),
       but will not have vttree_remove() called on it in update_vf()
       because it does not have the HFSC_FSC flag set.
    
    The qdisc always assumes that inner classes have the HFSC_FSC flag set.
    This is by design as it doesn't make sense 'qdisc wise' for an 'rt'
    curve to be an inner curve.
    
    Budimir's original patch disallows users to add classes with a 'rt'
    parent, but this is too strict as it breaks users that have been using
    'rt' as a inner class. Another approach, taken by this patch, is to
    upgrade the inner 'rt' into a 'sc', warning the user in the process.
    It avoids the UAF reported by Budimir while also being more permissive
    to bad scripts/users/code using 'rt' as a inner class.
    
    Users checking the `tc class ls [...]` or `tc class get [...]` dumps would
    observe the curve change and are potentially breaking with this change.
    
    v1->v2: https://lore.kernel.org/all/20231013151057.2611860-1-pctammela@mojatatu.com/
    - Correct 'Fixes' tag and merge with revert (Jakub)
    
    Cc: Christian Theune <ct@flyingcircus.io>
    Cc: Budimir Markovic <markovicbudimir@gmail.com>
    Fixes: b3d26c57 ("net/sched: sch_hfsc: Ensure inner classes have fsc curve")
    Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
    Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
    Link: https://lore.kernel.org/r/20231017143602.3191556-1-pctammela@mojatatu.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    a13b67c9
sch_hfsc.c 39.8 KB