af_unix: limit recursion level
authorEric Dumazet <eric.dumazet@gmail.com>
Thu, 25 Nov 2010 04:11:39 +0000 (04:11 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 7 Jan 2011 21:58:26 +0000 (13:58 -0800)
commit12987cd3a4e09156453804cf90bb7cdb5a29e15c
tree28d05c70cad329d6b0c6f2e11c839f91a12e2874
parentf7e86272f0b8fcc627c3d4a42db21419f1995b9a
af_unix: limit recursion level

[ Upstream commit 25888e30319f8896fc656fc68643e6a078263060 ]

Its easy to eat all kernel memory and trigger NMI watchdog, using an
exploit program that queues unix sockets on top of others.

lkml ref : http://lkml.org/lkml/2010/11/25/8

This mechanism is used in applications, one choice we have is to have a
recursion limit.

Other limits might be needed as well (if we queue other types of files),
since the passfd mechanism is currently limited by socket receive queue
sizes only.

Add a recursion_level to unix socket, allowing up to 4 levels.

Each time we send an unix socket through sendfd mechanism, we copy its
recursion level (plus one) to receiver. This recursion level is cleared
when socket receive queue is emptied.

Reported-by: Марк Коренберг <socketpair@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/net/af_unix.h
net/unix/af_unix.c
net/unix/garbage.c