Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/5]  net/sched: improve class lifetime handling
@ 2023-07-21 19:13 Pedro Tammela
  2023-07-21 19:13 ` [PATCH net-next 1/5] net/sched: wrap open coded Qdics class filter counter Pedro Tammela
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Pedro Tammela @ 2023-07-21 19:13 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, jhs, xiyou.wangcong, jiri,
	Pedro Tammela

Valis says[0]:
============
Three classifiers (cls_fw, cls_u32 and cls_route) always copy
tcf_result struct into the new instance of the filter on update.

This causes a problem when updating a filter bound to a class,
as tcf_unbind_filter() is always called on the old instance in the
success path, decreasing filter_cnt of the still referenced class
and allowing it to be deleted, leading to a use-after-free.
============

Turns out these could have been spotted easily with proper warnings.
Improve the current class lifetime with wrappers that check for
overflow/underflow.

While at it add an extack for when a class in use is deleted.

[0] https://lore.kernel.org/all/20230721174856.3045-1-sec@valis.email/


Pedro Tammela (5):
  net/sched: wrap open coded Qdics class filter counter
  net/sched: sch_drr: warn about class in use while deleting
  net/sched: sch_hfsc: warn about class in use while deleting
  net/sched: sch_htb: warn about class in use while deleting
  net/sched: sch_qfq: warn about class in use while deleting

 include/net/sch_generic.h |  1 +
 include/net/tc_class.h    | 33 +++++++++++++++++++++++++++++++++
 net/sched/sch_drr.c       | 12 +++++++-----
 net/sched/sch_hfsc.c      | 11 +++++++----
 net/sched/sch_htb.c       | 11 ++++++-----
 net/sched/sch_qfq.c       | 11 ++++++-----
 6 files changed, 60 insertions(+), 19 deletions(-)
 create mode 100644 include/net/tc_class.h

-- 
2.39.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-24 17:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 19:13 [PATCH net-next 0/5] net/sched: improve class lifetime handling Pedro Tammela
2023-07-21 19:13 ` [PATCH net-next 1/5] net/sched: wrap open coded Qdics class filter counter Pedro Tammela
2023-07-23 18:10   ` Cong Wang
2023-07-24 17:05     ` Pedro Tammela
2023-07-21 19:13 ` [PATCH net-next 2/5] net/sched: sch_drr: warn about class in use while deleting Pedro Tammela
2023-07-21 19:13 ` [PATCH net-next 3/5] net/sched: sch_hfsc: " Pedro Tammela
2023-07-21 19:13 ` [PATCH net-next 4/5] net/sched: sch_htb: " Pedro Tammela
2023-07-21 19:13 ` [PATCH net-next 5/5] net/sched: sch_qfq: " Pedro Tammela
2023-07-22 12:41 ` [PATCH net-next 0/5] net/sched: improve class lifetime handling Jamal Hadi Salim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox