nfs: fix possible null-ptr-deref when parsing param
authorHawkins Jiawei <yin31149@gmail.com>
Sun, 23 Oct 2022 16:39:45 +0000 (00:39 +0800)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 6 Dec 2022 15:43:24 +0000 (10:43 -0500)
commit5559405df652008e56eee88872126fe4c451da67
tree06482691076b88a6726698c286192d218351d307
parentd564d2c4c2445cb0972453933dc87c2dcaac8597
nfs: fix possible null-ptr-deref when parsing param

According to commit "vfs: parse: deal with zero length string value",
kernel will set the param->string to null pointer in vfs_parse_fs_string()
if fs string has zero length.

Yet the problem is that, nfs_fs_context_parse_param() will dereferences the
param->string, without checking whether it is a null pointer, which may
trigger a null-ptr-deref bug.

This patch solves it by adding sanity check on param->string
in nfs_fs_context_parse_param().

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/fs_context.c