NFSv4: Fix a NULL pointer dereference in pnfs_mark_matching_lsegs_return()
authorAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 19 May 2021 16:54:51 +0000 (12:54 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 20 May 2021 16:17:08 +0000 (12:17 -0400)
commita421d218603ffa822a0b8045055c03eae394a7eb
treed28e45b50533395e3872e99c6d88387da2972ee5
parente877a88d1f069edced4160792f42c2a8e2dba942
NFSv4: Fix a NULL pointer dereference in pnfs_mark_matching_lsegs_return()

Commit de144ff4234f changes _pnfs_return_layout() to call
pnfs_mark_matching_lsegs_return() passing NULL as the struct
pnfs_layout_range argument. Unfortunately,
pnfs_mark_matching_lsegs_return() doesn't check if we have a value here
before dereferencing it, causing an oops.

I'm able to hit this crash consistently when running connectathon basic
tests on NFS v4.1/v4.2 against Ontap.

Fixes: de144ff4234f ("NFSv4: Don't discard segments marked for return in _pnfs_return_layout()")
Cc: stable@vger.kernel.org
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/pnfs.c