Re: How can OOM killer detect process consuming much kernelmemory?

From: David Rientjes
Date: Wed Sep 01 2010 - 18:25:42 EST


On Thu, 2 Sep 2010, Tetsuo Handa wrote:

> Is it possible to make OOM killer to kill processes consuming kernel memory
> rather than userspace memory?
>
> I'm happy if OOM killer can select victim process based on both kernel memory
> usage and userspace memory usage. For example, opening a file requires kernel
> memory allocation (e.g. /sys/kernel/security/tomoyo/self_domain allocates 8KB
> of kernel memory). Therefore, I refuse allowing everybody to open that file
> even if the content is public (because an attacker would open
> /sys/kernel/security/tomoyo/self_domain as many as possible using
> fork() and open() in order to exhaust kernel memory).

The oom killer has been rewritten for 2.6.36, so it'd probably help to
frame it in the context of its new behavior, which you can try out in
2.6.36-rc3.

The case you're describing would be difficult to kill with the oom killer
because each fork() and exec() would be considered as seperate users of
memory, so an aggregate of kernel memory amongst these threads wouldn't be
considered.

The oom killer isn't really concerned whether the memory was allocated in
userspace or kernelspace, the only thing that matters is that it's used
and is unreclaimable (and non-migratable).

The memory controller accounts for user memory, so it's probably not a
sufficient alternative either in this case. Is it not possible for the
kernel to intelligently limit the amount of memory that it can allocate
through an interface at any given time?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/