Ensure that the credentials field of the NFSv4 client open structure is
authorrmacklem <rmacklem@FreeBSD.org>
Thu, 22 Jun 2017 00:17:15 +0000 (00:17 +0000)
committerrmacklem <rmacklem@FreeBSD.org>
Thu, 22 Jun 2017 00:17:15 +0000 (00:17 +0000)
commit73a70b4bbb9b2978f0ea5495d782a01758a2cf5b
treedde0012ceda01ae09d67995110eb1178f4eefce7
parenta4cc310916995d3ce93eee1101a1f4e0a7f3520d
Ensure that the credentials field of the NFSv4 client open structure is
initialized.

bdrewery@ has reported panics "newnfs_copycred: negative nfsc_ngroups".
The only way I can see that this occurs is that the credentials field of
the open structure gets used before being filled in.
I am not sure quite how this happens, but for the file create case, the
code is serialized via the vnode lock on the directory. If, somehow, a
link to the same file gets created just after file creation, this might
occur.

This patch ensures that the credentials field is initialized to a reasonable
set of credentials before the structure is linked into any list, so I
this should ensure it is initialized before use.
I am committing the patch now, since bdrewery@ notes that the panics
are intermittent and it may be months before he knows if the patch fixes
his problem.

Reported by: bdrewery
MFC after: 2 weeks
sys/fs/nfsclient/nfs_clstate.c