Project

General

Profile

Actions

Bug #2113

closed

Race condition starting Unix Server

Added by Ryan R about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

These lines (here: https://github.com/inliniac/suricata/blob/master/src/runmode-unix-socket.c#L1026):

```
UnixManagerThreadSpawn(1);

unix_socket_mode_is_running = 1;
UnixManagerRegisterCommand("pcap-file", UnixSocketAddPcapFile, pcapcmd, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("pcap-file-number", UnixSocketPcapFilesNumber, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-file-list", UnixSocketPcapFilesList, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-current", UnixSocketPcapCurrent, pcapcmd, 0);
```

Cause a race if the server starts accepting/dealing with connections before all commands have been registered. A simple fix I have tested is to move the first two lines after the block, like so:

```
UnixManagerRegisterCommand("pcap-file", UnixSocketAddPcapFile, pcapcmd, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("pcap-file-number", UnixSocketPcapFilesNumber, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-file-list", UnixSocketPcapFilesList, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-current", UnixSocketPcapCurrent, pcapcmd, 0);

UnixManagerThreadSpawn(1);
unix_socket_mode_is_running = 1;

```

Actions

Also available in: Atom PDF