From: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: RFC: chasing all idr_remove() misses
Date: Sat, 16 Nov 2024 18:45:37 +0100 [thread overview]
Message-ID: <97f3b17f-2e92-4cb7-8ee5-3a76969fb2cf@orange.com> (raw)
Hi,
In the recent fix of u32's IDR leaks:
73af53d82076 net: sched: cls_u32: Fix u32's systematic failure to free IDR
entries for hnodes.
... one side remark is that the problem went unnoticed for 7 years due to the
NULL result from idr_remove() being ignored at this call site.
Now, a cursory grep over the whole Linux tree shows 306 out of 386 call sites
(excluding those hidden in macros, if any) don't bother to extract the value
returned by idr_remove().
Indeed, a failed IDR removal is "mostly harmless" since IDs are not pointers so
the mismatch is detectable (and is detected, returning NULL). However, in racy
situations you may end up killing an innocent fresh entry, which may really
break things a bit later. And in all cases, a true bug is the root cause.
So, unless we have reasons to think cls_u32 was the only place where two ID
encodings might lend themselves to confusion, I'm wondering if it wouldn't make
sense to chase the issue more systematically:
- either with WARN_ON[_ONCE](idr_remove()==NULL) on each call site individually
(a year-long endeavor implying tens of maintainers)
- or with WARN_ON[_ONCE] just before returning NULL within idr_remove() itself,
or even radix_tree_delete_item() (quicker but possibly disruptive)
- a variant of the latter being to do it only for harsh bug-hunting builds (the
ones typically used by patrolling bots)
Opinions ?
next reply other threads:[~2024-11-16 17:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 17:45 Alexandre Ferrieux [this message]
2024-11-16 19:43 ` RFC: chasing all idr_remove() misses Dan Carpenter
2024-11-17 15:07 ` Alexandre Ferrieux
2024-11-18 2:47 ` Matthew Wilcox
2024-11-18 11:33 ` Alexandre Ferrieux
2024-11-20 14:43 ` Alexandre Ferrieux
-- strict thread matches above, loose matches on Subject: below --
2024-11-10 17:28 [PATCH net v7] net: sched: cls_u32: Fix u32's systematic failure to free IDR entries for hnodes Alexandre Ferrieux
2024-11-13 5:00 ` patchwork-bot+netdevbpf
2024-11-14 18:24 ` RFC: chasing all idr_remove() misses Alexandre Ferrieux
2024-11-19 3:51 ` Cong Wang
2024-11-19 3:57 ` Cong Wang
2024-11-19 6:46 ` Alexandre Ferrieux
2024-11-22 21:32 ` Cong Wang
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=97f3b17f-2e92-4cb7-8ee5-3a76969fb2cf@orange.com \
--to=alexandre.ferrieux@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.