• Miklos Szeredi's avatar
    [AF_UNIX]: Rewrite garbage collector, fixes race. · 1fd05ba5
    Miklos Szeredi authored
    Throw out the old mark & sweep garbage collector and put in a
    refcounting cycle detecting one.
    
    The old one had a race with recvmsg, that resulted in false positives
    and hence data loss.  The old algorithm operated on all unix sockets
    in the system, so any additional locking would have meant performance
    problems for all users of these.
    
    The new algorithm instead only operates on "in flight" sockets, which
    are very rare, and the additional locking for these doesn't negatively
    impact the vast majority of users.
    
    In fact it's probable, that there weren't *any* heavy senders of
    sockets over sockets, otherwise the above race would have been
    discovered long ago.
    
    The patch works OK with the app that exposed the race with the old
    code.  The garbage collection has also been verified to work in a few
    simple cases.
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    1fd05ba5
af_unix.c 48.1 KB