IMA memory hog
A number of questions came after this revelation, including:
- Why is IMA using such an inappropriate data structure?
- Why is it keeping all this information around even though it was disabled on the system in question?
- Why was IMA configured into the kernel in the first place?
The answer to the first question seems to be that the IMA developers, as part of the process of getting the code into the mainline, were not allowed to expand the inode structure at all. So they created a separate tree for per-inode information; it just happens that they chose the wrong type of tree and never noticed how poorly it performed.
Question #2 is answered like this: the IMA code needs to keep track of which files are opened for write access at any time. There is no point in measuring the integrity of files (checksumming them, essentially) when they can be changed at any time. Without tracking the state of all files all the time, IMA can never know which files are opened for write access when it first starts up. The only way to be sure, it seems, is to track all files starting at boot time just in case somebody tries to turn IMA on at some point.
As for #3: kernel.org was running a Fedora kernel, and the Fedora folks turned on the feature because it looked like it might be useful to some people. Nobody expected that it would have such an impact on systems where it was not turned on. Some participants in the discussion have given the Fedora kernel maintainers some grief for not having audited the code before enabling it, but auditing everything in the kernel to that level is a bit larger task than Fedora can really be expected to take on.
Eric Paris has started work on slimming IMA down; his patches work by moving the "open for write"
counts into the inode structure itself, eliminating the need to allocate
the separate IMA structures most of the time. IMA is also shifted over to
a red-black tree when it does need to track those structures. This work
eliminates almost all of the memory waste, but at the cost of growing the
inode structure slightly. That does not sit well with everybody,
especially, it seems, those developers who feel that IMA should not exist
in the first place. But it's a clear step in the right direction, so one
should expect something along these lines to be merged for 2.6.37.
Index entries for this article | |
---|---|
Kernel | Integrity measurement architecture |
Posted Oct 21, 2010 1:56 UTC (Thu)
by lordsutch (guest, #53)
[Link] (1 responses)
Posted Oct 21, 2010 14:35 UTC (Thu)
by jengelh (guest, #33263)
[Link]
Posted Oct 21, 2010 8:10 UTC (Thu)
by MisterIO (guest, #36192)
[Link] (1 responses)
Well, looking at the patches, it should be said that the inode structure growth is dependent on CONFIG_IMA, thus, if IMA is not enabled, the inode structure doesn't grow at all.
Posted Oct 21, 2010 12:53 UTC (Thu)
by corbet (editor, #1)
[Link]
Posted Oct 21, 2010 13:36 UTC (Thu)
by i3839 (guest, #31386)
[Link]
As someone mentioned in the thread, things become simpler when IMA is only
Posted Oct 21, 2010 18:23 UTC (Thu)
by dlang (guest, #313)
[Link]
this frequently comes at a cost in startup time, runtime performance, or memory overhead. It's seldom this blatent an issue, but it's very common.
Posted Oct 21, 2010 21:01 UTC (Thu)
by jzbiciak (guest, #5246)
[Link] (6 responses)
Gee, I wonder what happens when I open a file 4 billion times... will IMA notice it later? (On a 32-bit system, at least.)
Posted Oct 21, 2010 21:03 UTC (Thu)
by corbet (editor, #1)
[Link] (4 responses)
Posted Oct 21, 2010 21:09 UTC (Thu)
by jzbiciak (guest, #5246)
[Link] (3 responses)
Posted Oct 22, 2010 12:38 UTC (Fri)
by mpr22 (subscriber, #60784)
[Link] (2 responses)
Posted Oct 22, 2010 13:57 UTC (Fri)
by jzbiciak (guest, #5246)
[Link] (1 responses)
Hmmm.... wouldn't that be an awful lot of us?
I learned C on an I16 arch (and remember Borland's small, medium, large and huge models, the near/far keywords, and all that fun), and I'm only 35, so not a greybeard just yet.
Posted Oct 22, 2010 16:35 UTC (Fri)
by nix (subscriber, #2304)
[Link]
Posted Oct 21, 2010 21:04 UTC (Thu)
by jzbiciak (guest, #5246)
[Link]
IMA memory hog
"今, memory hog(だ)" also works out.
IMA memory hog
IMA memory hog
Yes but...distributors tend to turn on everything that looks like it might be useful for their users, so the chances of CONFIG_IMA being set are fairly good.
IMA memory hog
IMA memory hog
If that would bloat the inode too much, perhaps give the inode a variable
size (size determined at startup), or add a pointer to the IMA struct. But
both seem too much complexity for no gain, just disable IMA except when
you're actually using it. And then adding the info to the inode saves more
memory because you don't have to keep around a whole extra tree. The IMA
menuconfig text needs updating of course.
enabled or disabled at boot time, so no need to keep track of writers etc.
when IMA is not used.
distro kernels are made to work for everyone, and be efficient for nobody
IMA memory hog
if (mode & FMODE_WRITE)
- iint->writecount++;
+ inode->i_writers++;
If you have a system where you can have 4 billion simultaneously open file descriptors, there might indeed be a problem.
IMA memory hog
Yeah, see my mea culpa followup. I had misinterpreted as "total writers ever" as opposed to "total concurrent writers". I'm curious why they chose "long" for the count though. Seems like even a fairly beefy 64-bit box might find (231-1) active file descriptors a bit challenging, let alone (263-1) on machines where sizeof(long)==8. :-)
IMA memory hog
"Learned C on an I16 arch" and "were taught C by someone who learned it on an I16 arch" are the obvious possibilities.
IMA memory hog
IMA memory hog
IMA memory hog
IMA memory hog