mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* How can OOM killer detect process consuming much kernel memory?
       [not found]   ` <201008302227.DJH30258.OQFMFtFJOOVSHL@I-love.SAKURA.ne.jp>
@ 2010-09-01 21:33     ` Tetsuo Handa
  2010-09-01 22:25       ` David Rientjes
  2010-09-03  6:32       ` KOSAKI Motohiro
  0 siblings, 2 replies; 3+ messages in thread
From: Tetsuo Handa @ 2010-09-01 21:33 UTC (permalink / raw)
  To: linux-kernel, netdev, kosaki.motohiro, spender, eric.dumazet

I contacted Brad Spengler regarding below topic

  http://kerneltrap.org/mailarchive/linux-netdev/2010/8/21/6283491

and received some comments.

Brad Spengler wrote:
> Tetsuo Handa wrote:
> > Brad Spengler wrote:
> > > Nice find, seems like the problem isn't just the exhaustion of the space 
> > > itself, but that a single non-root user can completely exhaust it with 
> > > no limitation (given enough RAM).  There should be some per-user 
> > > resource limit for this (similar to RLIMIT_NPROC) or the space should be 
> > > made less rigid.
> > > 
> > I posted a patch in the third message of that thread, but no response so far.
> > I don't know whether we should allow 4294967296 names or not
> > because more RAM will be consumed by attacker if more names are allowed.
> 
> The max size for sun_path is considerably large; why couldn't we encode 
> the uid/namespace into it somehow and reduce the amount each user can 
> allocate?  (conceptually it'd be something like, <namespace 
> uuid><uid><hex to operate on as previously>)  The OOM killer needs to 
> make sure creators of large numbers of these get killed, but 
> implementing a per-user limit on this keeps it from turning into a DoS.

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

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

* Re: How can OOM killer detect process consuming much kernel memory?
  2010-09-01 21:33     ` How can OOM killer detect process consuming much kernel memory? Tetsuo Handa
@ 2010-09-01 22:25       ` David Rientjes
  2010-09-03  6:32       ` KOSAKI Motohiro
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2010-09-01 22:25 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-kernel, netdev, kosaki.motohiro, spender, eric.dumazet

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?

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

* Re: How can OOM killer detect process consuming much kernel memory?
  2010-09-01 21:33     ` How can OOM killer detect process consuming much kernel memory? Tetsuo Handa
  2010-09-01 22:25       ` David Rientjes
@ 2010-09-03  6:32       ` KOSAKI Motohiro
  1 sibling, 0 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2010-09-03  6:32 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: kosaki.motohiro, linux-kernel, netdev, spender, eric.dumazet

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

Unfortunatelly, It's impossible. We have zero information which kernel
memory should be bound caller task. Almost all kernel memory are task
unrelated, so we can't bind them with caller task blindly.

Thanks.





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

end of thread, other threads:[~2010-09-03  6:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201008212101.IJG87048.QMOHFtSOVOLFFJ@I-love.SAKURA.ne.jp>
     [not found] ` <AANLkTi=oWoHUmm_3xkRY7UzoXTuptKvUHzn0gK2WDiSa@mail.gmail.com>
     [not found]   ` <201008302227.DJH30258.OQFMFtFJOOVSHL@I-love.SAKURA.ne.jp>
2010-09-01 21:33     ` How can OOM killer detect process consuming much kernel memory? Tetsuo Handa
2010-09-01 22:25       ` David Rientjes
2010-09-03  6:32       ` KOSAKI Motohiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®