• M
    af_unix: fix garbage collect vs MSG_PEEK · 5fe0058b
    Miklos Szeredi 提交于
    stable inclusion
    from linux-4.19.200
    commit 1dabafa9f61118b1377fde424d9a94bf8dbf2813
    
    --------------------------------
    
    commit cbcf0112 upstream.
    
    unix_gc() assumes that candidate sockets can never gain an external
    reference (i.e.  be installed into an fd) while the unix_gc_lock is
    held.  Except for MSG_PEEK this is guaranteed by modifying inflight
    count under the unix_gc_lock.
    
    MSG_PEEK does not touch any variable protected by unix_gc_lock (file
    count is not), yet it needs to be serialized with garbage collection.
    Do this by locking/unlocking unix_gc_lock:
    
     1) increment file count
    
     2) lock/unlock barrier to make sure incremented file count is visible
        to garbage collection
    
     3) install file into fd
    
    This is a lock barrier (unlike smp_mb()) that ensures that garbage
    collection is run completely before or completely after the barrier.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    5fe0058b
af_unix.c 69.3 KB