netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/5] net/sched: improve class lifetime handling
@ 2023-07-28 15:35 Pedro Tammela
  2023-07-28 15:35 ` [PATCH net-next v2 1/5] net/sched: wrap open coded Qdics class filter counter Pedro Tammela
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Pedro Tammela @ 2023-07-28 15:35 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/

v1 -> v2:
   - Add ack tag from Jamal
   - Move definitions to sch_generic.h as suggested by Cong

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 | 26 ++++++++++++++++++++++++++
 net/sched/sch_drr.c       | 11 ++++++-----
 net/sched/sch_hfsc.c      | 10 ++++++----
 net/sched/sch_htb.c       | 10 +++++-----
 net/sched/sch_qfq.c       | 12 ++++++------
 5 files changed, 49 insertions(+), 20 deletions(-)

-- 
2.39.2


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

end of thread, other threads:[~2023-08-01  9:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 15:35 [PATCH net-next v2 0/5] net/sched: improve class lifetime handling Pedro Tammela
2023-07-28 15:35 ` [PATCH net-next v2 1/5] net/sched: wrap open coded Qdics class filter counter Pedro Tammela
2023-07-28 15:35 ` [PATCH net-next v2 2/5] net/sched: sch_drr: warn about class in use while deleting Pedro Tammela
2023-07-28 15:35 ` [PATCH net-next v2 3/5] net/sched: sch_hfsc: " Pedro Tammela
2023-07-28 15:35 ` [PATCH net-next v2 4/5] net/sched: sch_htb: " Pedro Tammela
2023-07-28 15:35 ` [PATCH net-next v2 5/5] net/sched: sch_qfq: " Pedro Tammela
2023-07-31  7:31 ` [PATCH net-next v2 0/5] net/sched: improve class lifetime handling Simon Horman
2023-08-01  9:10 ` patchwork-bot+netdevbpf

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).