smbd: fix pathref unlinking in create_file_unixpath()
authorJeremy Allison <jra@samba.org>
Tue, 8 Jun 2021 16:53:18 +0000 (18:53 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 10 Jun 2021 10:31:11 +0000 (10:31 +0000)
commit42fa9f800fd008881c70cf37e63954f5987d0c78
tree0887c355b8f6dca9123335a4660fd341282a08a1
parent1c8ba016208458d97a78bc3a1d954c2df915cafd
smbd: fix pathref unlinking in create_file_unixpath()

This is really subtle. If someone passes in an smb_fname where smb_fname
actually is taken from fsp->fsp_name, then the lifetime of these objects is
meant to be the same.

This is commonly the case from an SMB1 path-based call
(eg call_trans2qfilepathinfo()) where we use the pathref fsp
(smb_fname->fsp) as the handle. In this case we must not unlink smb_fname->fsp
from it's owner.

The asserts below:

  SMB_ASSERT(fsp->fsp_name->fsp != NULL);
  SMB_ASSERT(fsp->fsp_name->fsp == fsp);

ensure the required invarients are met.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14732

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jun  8 20:44:41 UTC 2021 on sn-devel-184

(cherry picked from commit 8a427783e5e780d3ffbe4f9710ac4a17c483ca33)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Thu Jun 10 10:31:11 UTC 2021 on sn-devel-184
source3/smbd/open.c