]> git.baikalelectronics.ru Git - kernel.git/commit
net/unix: drop obsolete fd-recursion limits
authorDavid Herrmann <dh.herrmann@gmail.com>
Mon, 17 Jul 2017 09:35:54 +0000 (11:35 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jul 2017 15:57:59 +0000 (08:57 -0700)
commit103c096ff0c15e5f0e96401da2a3adfad0b73ae9
tree8346a2f39052b1b3d3d06179dfe091555ddffe61
parent709ff95399553766e914937ed75aadfd2734bdcb
net/unix: drop obsolete fd-recursion limits

All unix sockets now account inflight FDs to the respective sender.
This was introduced in:

    commit f625c8daa0d6e4e2220a9795d4adb5c7e2fccc2a
    Author: willy tarreau <w@1wt.eu>
    Date:   Sun Jan 10 07:54:56 2016 +0100

        unix: properly account for FDs passed over unix sockets

and further refined in:

    commit 34d03873beef6d97d3f91723e9e1d95867749d7d
    Author: Hannes Frederic Sowa <hannes@stressinduktion.org>
    Date:   Wed Feb 3 02:11:03 2016 +0100

        unix: correctly track in-flight fds in sending process user_struct

Hence, regardless of the stacking depth of FDs, the total number of
inflight FDs is limited, and accounted. There is no known way for a
local user to exceed those limits or exploit the accounting.

Furthermore, the GC logic is independent of the recursion/stacking depth
as well. It solely depends on the total number of inflight FDs,
regardless of their layout.

Lastly, the current `recursion_level' suffers a TOCTOU race, since it
checks and inherits depths only at queue time. If we consider `A<-B' to
mean `queue-B-on-A', the following sequence circumvents the recursion
level easily:

    A<-B
       B<-C
          C<-D
             ...
               Y<-Z

resulting in:

    A<-B<-C<-...<-Z

With all of this in mind, lets drop the recursion limit. It has no
additional security value, anymore. On the contrary, it randomly
confuses message brokers that try to forward file-descriptors, since
any sendmsg(2) call can fail spuriously with ETOOMANYREFS if a client
maliciously modifies the FD while inflight.

Cc: Alban Crequy <alban.crequy@collabora.co.uk>
Cc: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/af_unix.h
net/unix/af_unix.c