[Bug 235582] rpc_svc_gss / nfsd kernel panic

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Feb 9 23:28:28 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235582

--- Comment #10 from Rick Macklem <rmacklem at FreeBSD.org> ---
Created attachment 201876
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=201876&action=edit
fix race in ref counting of svc_rpc_gss_client struct

Upon inspection I found two related races when the svc_rpc_gss_client
structure in created/initialized.
1 - The cl_expiration field is set after the structure is linked into a
    list, making it visible to other threads when it is still 0.
    This could result in svc_rpc_gss_timeout_client() freeing it just after
    being linked into the list.
2 - Related to #1, cl_refs is initialized to 1 and then incremented by
    refcount_acquire() after svc_rpc_gss_create_client() returns it,
    leaving a window where cl_refs could be decremented to 0 and free'd.

This patch makes two changes to svc_rpc_gss_create_client():
- Move the code that initializes cl_expiration to before where it is linked
  into the list, so that it is set before it is visible to other threads.
- Initialize cl_refs to 2, so a refcount_acquire() is not needed after
  the svc_rpc_gss_create_client() call.

These races could allow the structure to be free'd when it is still being
used in svc_rpc_gss().

This patch can be applied separately from #201862.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-fs mailing list