HomeFreeBSD

Fix a race in the RPCSEC_GSS server code that caused crashes.

Description

Fix a race in the RPCSEC_GSS server code that caused crashes.

When a new client structure was allocated, it was added to the list
so that it was visible to other threads before the expiry time was
initialized, with only a single reference count.
The caller would increment the reference count, but it was possible
for another thread to decrement the reference count to zero and free
the structure before the caller incremented the reference count.
This could occur because the expiry time was still set to zero when
the new client structure was inserted in the list and the list was
unlocked.

This patch fixes the race by initializing the reference count to two
and initializing all fields, including the expiry time, before inserting
it in the list.

Tested by: peter@ifm.liu.se
PR: 235582
MFC after: 2 weeks

Details

Provenance
rmacklemAuthored on
Parents
rS345817: Build NVMe CAM transport unrelated to NVMe SIM.
Branches
Unknown
Tags
Unknown