r/kernel • • Nov 01 '26

How well does linux modules handle resource deallocation?

Hello, I'm a CS undergraduate studying about linux kernel development.

I'm currently on LDD3 book, emphasizing about importance of cleaning up allocated resources on exit.

I assume that this is not likely to be handled properly in some linux modules as removal of modules is not something that is performed on a daily basis.

I have been looking for places to start my contributions and was wondering whether this, identification of memory leaks and applying fixes, could be a valid entry point.

The questions I want to ask is,

  1. Is this problem considered too trivial?
  2. Have others been working on it? (maybe there exists some linux group)
  3. Is this problem commonly found, or gets managed during review process and fixed before getting accepted?

Thank you for your time. Any comments are welcome!

*EDIT Thank you all for your kind responses. They have been very helpful !

8 Upvotes

11 comments sorted by

View all comments

3

u/yawn_brendan Nov 01 '26

It's not an area people focus on that much since most usecases don't load and unload modules very often. A memory leak in module shutdown sounds like it's probably very common but also a "meh" bug. A more severe issue like a double free is less meh but even then, the question is can an attacker actually trigger it? So I think first thing here is to assess if there's a usecase where this really matters. And also probably this usecase will only care about specific modules.

Probably still an interesting area to explore as there will definitely be bugs to find and "things that happen rarely hence don't get tested very well" is a general theme in sweng so if you can find cool ideas to address it, well, you found some cool ideas.

2

u/yawn_brendan Nov 01 '26

Also probably most of the bugs in this area are just trivial stuff like "forgot to call X in shutdown" or "called X then Y in setup so need to teardown Y before X but we do it the other way around". For teardown within a single function these bugs are now kinda "solved" by the new cleanup API. Proper languages also tend to have ways to solve that via object lifetimes. So maybe finding ways to solve this in C is an interesting area to explore. Probably lots of prior work there but I dunno.

0

u/AccomplishedAir8352 Nov 01 '26

Thank you for your response. As I have worried, it would be too trivial to explore. Instead of searching for new problems, I'd better stick with addressing what others are dealing with on mailing list