Project

General

Profile

Bug #5842

bind() on AF_UNIX socket may sporadically fail with EADDRINUSE

Added by Ken Harris about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
2015-04-15
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

If a process calls unlink() on the path of a bound socket before calling close() on it's file descriptor, it seems that a vnode pointer may be re-used such that a another process calling into bind() on an AF_UNIX socket, will encounter EADDRINUSE even though no file actually exists.

The attached test program usually demonstrates this when run on a 48-core machine with the following command line:

./eaddrinuse -f /var/tmp -c 256 -p 64

This issue seems to play out in the following files:
uts/common/fs/sockfs/socktpi.c (where the vnode is created)
uts/common/io/tl.c (where mod_hash_insert_reserve() fails when it encounters a previously used vnode pointer)

While it's pretty easy to work around this (call close() before unlink()), this still seems wrong.


Files

eaddrinuse.c (3.64 KB) eaddrinuse.c Ken Harris, 2015-04-15 03:33 PM

Also available in: Atom PDF