NFS4: Only set creation opendata if O_CREAT
authorBenjamin Coddington <bcodding@redhat.com>
Fri, 7 Jun 2019 10:37:30 +0000 (06:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 Jul 2019 06:11:15 +0000 (08:11 +0200)
commit810cfc3d9d2e4b345ba7e5d6290b00562e9e0d27
treed2d7cb0181b71e569692c8b4240a01bb709767f6
parent7075654ce7d0db9aaf5326dea586c35a041f3428
NFS4: Only set creation opendata if O_CREAT

[ Upstream commit 909105199a682cb09c500acd443d34b182846c9c ]

We can end up in nfs4_opendata_alloc during task exit, in which case
current->fs has already been cleaned up.  This leads to a crash in
current_umask().

Fix this by only setting creation opendata if we are actually doing an open
with O_CREAT.  We can drop the check for NULL nfs4_open_createattrs, since
O_CREAT will never be set for the recovery path.

Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4proc.c