From 3a37e4155c3cd82388652f89b611f2c46fee8525 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 2 Sep 2022 11:46:53 +0200 Subject: [PATCH] smbd: Catch streams on non-stream shares MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15161 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Fri Sep 2 15:56:56 UTC 2022 on sn-devel-184 --- selftest/knownfail.d/samba3.smb2.create_no_streams | 1 - source3/smbd/filename.c | 6 ++++++ source3/smbd/files.c | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) delete mode 100644 selftest/knownfail.d/samba3.smb2.create_no_streams diff --git a/selftest/knownfail.d/samba3.smb2.create_no_streams b/selftest/knownfail.d/samba3.smb2.create_no_streams deleted file mode 100644 index c8476081f2d..00000000000 --- a/selftest/knownfail.d/samba3.smb2.create_no_streams +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.create_no_streams.no_stream\(fileserver\) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index ca94b7ec7f9..0be8e320ffa 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1120,6 +1120,12 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( goto fail; } + if ((streamname != NULL) && + ((conn->fs_capabilities & FILE_NAMED_STREAMS) == 0)) { + status = NT_STATUS_OBJECT_NAME_INVALID; + goto fail; + } + if (!posix) { bool name_has_wild = ms_has_wild(dirname); name_has_wild |= ms_has_wild(fname_rel); diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 095a01723b1..e7c83505328 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -565,8 +565,14 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, return NT_STATUS_OK; } - if (!(conn->fs_capabilities & FILE_NAMED_STREAMS) || - !is_named_stream(smb_fname)) { + if (is_named_stream(smb_fname) && + ((conn->fs_capabilities & FILE_NAMED_STREAMS) == 0)) { + DBG_DEBUG("stream open [%s] on non-stream share\n", + smb_fname_str_dbg(smb_fname)); + return NT_STATUS_OBJECT_NAME_INVALID; + } + + if (!is_named_stream(smb_fname)) { /* * openat_pathref_fullname() will make "full_fname" a * talloc child of the smb_fname->fsp. Don't use -- 2.47.3