HomeFreeBSD

nfscl: newnfs_copycred() cannot be called when a mutex is held

Description

nfscl: newnfs_copycred() cannot be called when a mutex is held

Since newnfs_copycred() calls crsetgroups() which in turn calls
crextend() which might do a malloc(M_WAITOK), newnfs_copycred()
cannot be called with a mutex held. Fortunately, the malloc()
call is rarely done, since XU_GROUPS is 16 and the NFS client
uses a maximum of 17 (only 17 groups will cause the malloc() to
be called). Further, it is only a problem if the malloc() tries
to sleep(). As such, this bug does not seem to have caused
problems in practice.

This patch fixes the one place in the NFS client where
newnfs_copycred() is called while a mutex is held by moving the
call to after where the mutex is released.

Found by inspection while working on an experimental patch.

(cherry picked from commit 501bdf3001190686bf55d9d333cb533858c2cf2f)

Details

Provenance
rmacklemAuthored on Nov 6 2023, 10:25 PM
Parents
rG3ab7f15d9116: nfscl: Handle a Getattr failure with NFSERR_DELAY following Open
Branches
Unknown
Tags
Unknown