Miklos Szeredi cbcf01128d af_unix: fix garbage collect vs MSG_PEEK
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-07-28 10:18:00 -07:00
..
2021-06-02 14:01:55 -07:00
2021-03-30 16:54:50 -07:00
2021-06-30 15:51:09 -07:00
2021-06-29 11:28:21 -07:00
2021-06-29 11:28:21 -07:00
2021-05-26 07:03:39 +02:00
2021-06-07 14:08:30 -07:00
2021-07-05 14:08:24 -07:00
2021-06-30 15:51:09 -07:00
2021-06-29 11:28:21 -07:00
2021-06-30 15:51:09 -07:00
2021-06-30 15:51:09 -07:00
2021-06-29 11:28:21 -07:00
2021-07-09 09:43:57 -07:00
2021-06-30 15:51:09 -07:00
2021-06-30 15:51:09 -07:00
2021-06-30 15:51:09 -07:00
2021-06-03 15:13:56 -07:00