Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: fix unlikely NULL deref in mach_creds_match

We really shouldn't allow a client to be created with cl_mach_cred set
unless it also has a principal name.

This also allows us to fail such cases immediately on EXCHANGE_ID as
opposed to waiting and incorrectly returning WRONG_CRED on the following
CREATE_SESSION.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>

+9
+9
fs/nfsd/nfs4state.c
··· 2385 2385 status = nfserr_inval; 2386 2386 goto out_nolock; 2387 2387 } 2388 + /* 2389 + * Sometimes userspace doesn't give us a principal. 2390 + * Which is a bug, really. Anyway, we can't enforce 2391 + * MACH_CRED in that case, better to give up now: 2392 + */ 2393 + if (!new->cl_cred.cr_principal) { 2394 + status = nfserr_serverfault; 2395 + goto out_nolock; 2396 + } 2388 2397 new->cl_mach_cred = true; 2389 2398 case SP4_NONE: 2390 2399 break;