metze/samba/wip.git
20 months agos3:smbd: only clear share_mode lease state... contend_level2_oplocks_begin_default...
Stefan Metzmacher [Mon, 15 Aug 2022 20:45:17 +0000 (22:45 +0200)]
s3:smbd: only clear share_mode lease state... contend_level2_oplocks_begin_default clear all expect own TODO remember
current state...

20 months agosq selftest/knownfail.d/lease_bug_15148
Stefan Metzmacher [Wed, 17 Aug 2022 15:17:37 +0000 (17:17 +0200)]
sq selftest/knownfail.d/lease_bug_15148

20 months agoonly test_lease_v[1,2]_bug_15148
Stefan Metzmacher [Wed, 17 Aug 2022 14:34:19 +0000 (16:34 +0200)]
only test_lease_v[1,2]_bug_15148

20 months agotest_lease_v[1,2]_bug_15148
Stefan Metzmacher [Wed, 17 Aug 2022 15:07:08 +0000 (17:07 +0200)]
test_lease_v[1,2]_bug_15148

20 months agos3:smbd: share_mode_flags_set() takes SMB2_LEASE_* values
Stefan Metzmacher [Mon, 15 Aug 2022 08:49:13 +0000 (10:49 +0200)]
s3:smbd: share_mode_flags_set() takes SMB2_LEASE_* values

We currently only ever pass SMB2_LEASE_READ and both
have the same value of 0x1, so for now it's only cosmetic,
but that will change soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agoRevert "HACK g_lock fetch_locked"
Stefan Metzmacher [Wed, 10 Aug 2022 00:29:56 +0000 (00:29 +0000)]
Revert "HACK g_lock fetch_locked"

This reverts commit 53431af27241ac327dbbb322f15e82cb8c6897a3.

20 months agoHACK g_lock fetch_locked
Stefan Metzmacher [Wed, 10 Aug 2022 00:29:34 +0000 (00:29 +0000)]
HACK g_lock fetch_locked

20 months agoTODO source3/selftest/tests.py have_linux_openat2
Stefan Metzmacher [Mon, 15 Aug 2022 00:27:20 +0000 (02:27 +0200)]
TODO source3/selftest/tests.py have_linux_openat2

20 months agoRevert "tevent: remove tevent_wrapper related tests"
Stefan Metzmacher [Mon, 25 Jul 2022 13:41:35 +0000 (15:41 +0200)]
Revert "tevent: remove tevent_wrapper related tests"

This reverts commit 11394bcb2e81cda6893f1512dbc31a32cb3acee7.

20 months agoRevert "tevent: remove deprecated tevent_wrapper_ops infrastructure"
Stefan Metzmacher [Mon, 25 Jul 2022 13:41:35 +0000 (15:41 +0200)]
Revert "tevent: remove deprecated tevent_wrapper_ops infrastructure"

This reverts commit 1cd768d10412015380f8d4aeca908750434c78cf.

20 months agotevent: remove deprecated tevent_wrapper_ops infrastructure
Stefan Metzmacher [Mon, 25 Jul 2022 10:59:47 +0000 (12:59 +0200)]
tevent: remove deprecated tevent_wrapper_ops infrastructure

This was only ever used by samba master for some time,
but reverted before 4.10.0rc1 again.

Note the change to ABI/tevent-0.12.1.sigs will be reverted
with the bump to 0.13.0.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agotevent: remove tevent_wrapper related tests
Stefan Metzmacher [Mon, 25 Jul 2022 10:57:40 +0000 (12:57 +0200)]
tevent: remove tevent_wrapper related tests

The tevent_wrapper will be removed soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agosource3/smbd/smbXsrv TDB_VOLATILE
Stefan Metzmacher [Thu, 30 Jun 2022 10:25:47 +0000 (10:25 +0000)]
source3/smbd/smbXsrv TDB_VOLATILE

20 months agoRevert "num/s=12031 !!! no serverid_exists???"
Stefan Metzmacher [Mon, 25 Jul 2022 20:45:50 +0000 (22:45 +0200)]
Revert "num/s=12031 !!! no serverid_exists???"

This reverts commit 0172d3772ae9ada6b5b37c416650aa0e29d1093c.

20 months agonum/s=12031 !!! no serverid_exists???
Stefan Metzmacher [Mon, 4 Jul 2022 12:21:46 +0000 (12:21 +0000)]
num/s=12031 !!! no serverid_exists???

The following test with 256 commections all looping with open/close
on the same inode (share root) is improved drastically:

  smbtorture //127.0.0.1/m -Uroot%test smb2.create.bench-path-contention-shared \
     --option='torture:bench_path=' \
     --option="torture:timelimit=60" \
     --option="torture:nprocs=256"

From some like this:

   open[num/s=10223,avslat=0.017922,minlat=0.000083,maxlat=0.106759]
   close[num/s=10223,avslat=0.017694,minlat=0.000040,maxlat=0.107345]

to:

   open[num/s=12033,avslat=0.010883,minlat=0.000070,maxlat=0.065944]
   close[num/s=12031,avslat=0.010573,minlat=0.000029,maxlat=0.065834]

20 months agoTODO source3/lib/dbwrap/dbwrap_watch.h documentation...
Stefan Metzmacher [Mon, 25 Jul 2022 09:27:30 +0000 (11:27 +0200)]
TODO source3/lib/dbwrap/dbwrap_watch.h documentation...

20 months agobootstrap/ci: add ubuntu2204
Stefan Metzmacher [Wed, 10 Aug 2022 22:12:15 +0000 (00:12 +0200)]
bootstrap/ci: add ubuntu2204

We'll hopefully remove ubuntu1804 soon, but first I need
to upgrade the autobuild infrastructure first.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agoRevert "TODO: map ELOOP to NT_STATUS_SYMLINK_CLASS_DISABLED??? NT_STATUS_STOPPED_ON_...
Stefan Metzmacher [Fri, 12 Aug 2022 17:17:41 +0000 (19:17 +0200)]
Revert "TODO: map ELOOP to NT_STATUS_SYMLINK_CLASS_DISABLED???  NT_STATUS_STOPPED_ON_SYMLINK would be correct, but for that we need to return additional information about the symlink..."

This reverts commit 5307e5fb1a12794f7efd5dc5ed77bba603626847.

20 months agoTODO: map ELOOP to NT_STATUS_SYMLINK_CLASS_DISABLED??? NT_STATUS_STOPPED_ON_SYMLINK...
Stefan Metzmacher [Fri, 12 Aug 2022 17:16:16 +0000 (19:16 +0200)]
TODO: map ELOOP to NT_STATUS_SYMLINK_CLASS_DISABLED???  NT_STATUS_STOPPED_ON_SYMLINK would be correct, but for that we need to return additional information about the symlink...

20 months agoRevert "check"
Stefan Metzmacher [Tue, 9 Aug 2022 23:17:40 +0000 (23:17 +0000)]
Revert "check"

This reverts commit 2a77f9c8d1a5b5fe4703a5c32528b62485a1f8a0.

20 months agocheck
Stefan Metzmacher [Tue, 9 Aug 2022 15:37:11 +0000 (15:37 +0000)]
check

20 months agoRevert "TODO source3/smbd/filename.c"
Stefan Metzmacher [Tue, 9 Aug 2022 09:50:01 +0000 (09:50 +0000)]
Revert "TODO source3/smbd/filename.c"

This reverts commit 2ae827a8f12ffcf7560c3e410e7702df40903da4.

20 months agoTODO source3/smbd/filename.c
Stefan Metzmacher [Tue, 9 Aug 2022 09:49:29 +0000 (09:49 +0000)]
TODO source3/smbd/filename.c

20 months agoRevert "TODO NEEDED???: smbd: Avoid non_widelink_open() for VFS_OPEN_HOW_RESOLVE_NO_S...
Stefan Metzmacher [Mon, 8 Aug 2022 19:12:23 +0000 (21:12 +0200)]
Revert "TODO NEEDED???: smbd: Avoid non_widelink_open() for VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS"

This reverts commit 008d815dbb95124569ed8a0d0f1efc78bf89f227.

20 months agoTODO NEEDED???: smbd: Avoid non_widelink_open() for VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS
Volker Lendecke [Fri, 17 Jun 2022 09:14:51 +0000 (11:14 +0200)]
TODO NEEDED???: smbd: Avoid non_widelink_open() for VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS

The caller will have to deal with NT_STATUS_NOT_SUPPORTED if the VFS
can't deal with this flag

TODO(metze): check fallback_to_widelinks (added by metze)

20 months agoRevert "HACK rep_openat2 resolve == 0 => openat()"
Stefan Metzmacher [Wed, 10 Aug 2022 00:14:03 +0000 (00:14 +0000)]
Revert "HACK rep_openat2 resolve == 0 => openat()"

This reverts commit 1c5379f3c86967d6b6771c5de4869845be97c459.

20 months agoRevert "HACK vfswrap_openat always openat2"
Stefan Metzmacher [Wed, 10 Aug 2022 00:14:03 +0000 (00:14 +0000)]
Revert "HACK vfswrap_openat always openat2"

This reverts commit 0d60a34b1fad080a6061921eebbbe8de614af395.

20 months agoHACK vfswrap_openat always openat2
Stefan Metzmacher [Wed, 10 Aug 2022 00:13:21 +0000 (00:13 +0000)]
HACK vfswrap_openat always openat2

20 months agoHACK rep_openat2 resolve == 0 => openat()
Stefan Metzmacher [Wed, 10 Aug 2022 00:12:50 +0000 (00:12 +0000)]
HACK rep_openat2 resolve == 0 => openat()

20 months agoselftest/knownfail.opath-required
Stefan Metzmacher [Mon, 15 Aug 2022 20:31:12 +0000 (22:31 +0200)]
selftest/knownfail.opath-required

20 months agoHACK no O_PATH
Stefan Metzmacher [Sun, 14 Aug 2022 09:17:51 +0000 (11:17 +0200)]
HACK no O_PATH

20 months agos3:tests: make sure smbclient_expect_error() handles NT_STATUS_OK as no NT_STATUS_...
Stefan Metzmacher [Fri, 12 Aug 2022 17:03:39 +0000 (19:03 +0200)]
s3:tests: make sure smbclient_expect_error() handles NT_STATUS_OK as no NT_STATUS_ in the output

testing 'grep -v NT_STATUS_' only means we check that we have at least
one line of output without NT_STATUS_.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agorelease-script: Fix shellcheck errors
Andreas Schneider [Wed, 23 Feb 2022 11:19:19 +0000 (12:19 +0100)]
release-script: Fix shellcheck errors

./release-scripts/build-docs:4:7: error: Double quote array expansions
to avoid re-splitting elements. [SC2068]

Same error for the other scripts.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Wed Aug 17 11:03:54 UTC 2022 on sn-devel-184

20 months agolib:fuzzing: Fix shellcheck errors in build_samba.sh
Andreas Schneider [Tue, 22 Feb 2022 17:01:31 +0000 (18:01 +0100)]
lib:fuzzing: Fix shellcheck errors in build_samba.sh

lib/fuzzing/oss-fuzz/build_samba.sh:24:27: error: Double quote array
expansions to avoid re-splitting elements. [SC2068]

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agonsswitch: Fix shellcheck errors in test_rfc2307_mapping.sh
Andreas Schneider [Tue, 22 Feb 2022 16:58:47 +0000 (17:58 +0100)]
nsswitch: Fix shellcheck errors in test_rfc2307_mapping.sh

nsswitch/tests/test_rfc2307_mapping.sh:65:139: error: Double quote array
expansions to avoid re-splitting elements. [SC2068]

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agoexamples: Fix shellcheck error in VampireDriversFunctions
Andreas Schneider [Tue, 22 Feb 2022 16:50:34 +0000 (17:50 +0100)]
examples: Fix shellcheck error in VampireDriversFunctions

examples/printing/VampireDriversFunctions:183:24: error: Double quote
array expansions to avoid re-splitting elements. [SC2068]

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agoexamples: Remove trailing spaces in VampireDriversFunctions
Andreas Schneider [Tue, 22 Feb 2022 16:51:16 +0000 (17:51 +0100)]
examples: Remove trailing spaces in VampireDriversFunctions

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agoexamples: Fix shellcheck error in get_next_oid
Andreas Schneider [Tue, 22 Feb 2022 16:42:55 +0000 (17:42 +0100)]
examples: Fix shellcheck error in get_next_oid

examples/LDAP/get_next_oid:6:4: error: Remove spaces around += to assign
(or quote '+=' if literal). [SC2285]

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agotestprogs: Fix variable asignment in test_wintest.sh
Andreas Schneider [Mon, 21 Feb 2022 10:24:07 +0000 (11:24 +0100)]
testprogs: Fix variable asignment in test_wintest.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agos3:script: Fix variable asignment in test_dfree_command.sh
Andreas Schneider [Mon, 21 Feb 2022 10:23:27 +0000 (11:23 +0100)]
s3:script: Fix variable asignment in test_dfree_command.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agoscript: Add script to run shellcheck on shell scripts
Andreas Schneider [Mon, 21 Feb 2022 10:25:37 +0000 (11:25 +0100)]
script: Add script to run shellcheck on shell scripts

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agobootstrap: Install ShellCheck and shfmt
Andreas Schneider [Mon, 21 Feb 2022 10:29:29 +0000 (11:29 +0100)]
bootstrap: Install ShellCheck and shfmt

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
20 months agos3/smbd: Use after free when iterating smbd_server_connection->connections
Jeremy Allison [Fri, 22 Jul 2022 15:28:03 +0000 (16:28 +0100)]
s3/smbd: Use after free when iterating smbd_server_connection->connections

Change conn_free() to just use a destructor. We now
catch any other places where we may have forgetten to
call conn_free() - it's implicit on talloc_free(conn).

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

Based on code from Noel Power <noel.power@suse.com>.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Aug 17 09:54:06 UTC 2022 on sn-devel-184

20 months agos3/smbd: Use after free when iterating smbd_server_connection->connections
Jeremy Allison [Tue, 16 Aug 2022 20:51:27 +0000 (13:51 -0700)]
s3/smbd: Use after free when iterating smbd_server_connection->connections

In SMB2 smbd_smb2_tree_connect() we create a new conn struct
inside make_connection_smb2() then move the ownership to tcon using:

        tcon->compat = talloc_move(tcon, &compat_conn);

so the lifetime of tcon->compat is tied directly to tcon.

Inside smbXsrv_tcon_disconnect() we have:

 908                 ok = chdir_current_service(tcon->compat);
 909                 if (!ok) {
 910                         status = NT_STATUS_INTERNAL_ERROR;
 911                         DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): "
 912                                   "chdir_current_service() failed: %s\n",
 913                                   tcon->global->tcon_global_id,
 914                                   tcon->global->share_name,
 915                                   nt_errstr(status)));
 916                         tcon->compat = NULL;
 917                         return status;
 918                 }
 919
 920                 close_cnum(tcon->compat, vuid);
 921                 tcon->compat = NULL;

If chdir_current_service(tcon->compat) fails, we return status without ever having
called close_cnum(tcon->compat, vuid), leaving the conn pointer left in the linked
list sconn->connections.

The caller frees tcon and (by ownership) tcon->compat, still leaving the
freed tcon->compat pointer on the sconn->connections linked list.

When deadtime_fn() fires and walks the sconn->connections list it
indirects this freed pointer. We must call close_cnum() on error also.

Valgrind trace from Noel Power <noel.power@suse.com> is:

==6432== Invalid read of size 8
==6432==    at 0x52CED3A: conn_lastused_update (conn_idle.c:38)
==6432==    by 0x52CEDB1: conn_idle_all (conn_idle.c:54)
==6432==    by 0x5329971: deadtime_fn (smb2_process.c:1566)
==6432==    by 0x5DA2339: smbd_idle_event_handler (util_event.c:45)
==6432==    by 0x685F2F8: tevent_common_invoke_timer_handler (tevent_timed.c:376)

==6432==  Address 0x19074b88 is 232 bytes inside a block of size 328 free'd
==6432==    at 0x4C3451B: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6432==    by 0x5B38521: _tc_free_internal (talloc.c:1222)
==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
==6432==    by 0x5B385C5: _talloc_free_internal (talloc.c:1248)
==6432==    by 0x5B3988D: _talloc_free (talloc.c:1792)
==6432==    by 0x5349B22: smbd_smb2_flush_send_queue (smb2_server.c:4828)

==6432==  Block was alloc'd at
==6432==    at 0x4C332EF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6432==    by 0x5B378D9: __talloc_with_prefix (talloc.c:783)
==6432==    by 0x5B37A73: __talloc (talloc.c:825)
==6432==    by 0x5B37E0C: _talloc_named_const (talloc.c:982)
==6432==    by 0x5B3A8ED: _talloc_zero (talloc.c:2421)
==6432==    by 0x539873A: conn_new (conn.c:70)
==6432==    by 0x532D692: make_connection_smb2 (smb2_service.c:909)
==6432==    by 0x5352B5E: smbd_smb2_tree_connect (smb2_tcon.c:344)

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
20 months agos3:utils remove documentation of -l as alias for --long
Christian Ambach [Mon, 15 Aug 2022 21:30:23 +0000 (23:30 +0200)]
s3:utils remove documentation of -l as alias for --long

This was removed in 94fc9ca4c506468ab1907d501c0964d67b9d963c, so remove it from
the usage output and manpage.

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Aug 17 07:14:21 UTC 2022 on sn-devel-184

20 months agowaf: Fix SO version number of libsamba-errors
Andreas Schneider [Wed, 10 Aug 2022 11:55:48 +0000 (13:55 +0200)]
waf: Fix SO version number of libsamba-errors

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
20 months agomanpages: add smbstatus option --json with sample output
Jule Anger [Mon, 15 Aug 2022 13:27:55 +0000 (15:27 +0200)]
manpages: add smbstatus option --json with sample output

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

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jule Anger <janger@samba.org>
Autobuild-Date(master): Tue Aug 16 15:04:54 UTC 2022 on sn-devel-184

20 months agos3:tests: let smbstatus json tests fail if jq is not installed
Jule Anger [Tue, 16 Aug 2022 10:25:13 +0000 (12:25 +0200)]
s3:tests: let smbstatus json tests fail if jq is not installed

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
20 months agos3:vfs.h: change SMB_VFS_INTERFACE_VERSION to 48 for 4.18
Stefan Metzmacher [Tue, 16 Aug 2022 07:36:09 +0000 (09:36 +0200)]
s3:vfs.h: change SMB_VFS_INTERFACE_VERSION to 48 for 4.18

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug 16 11:51:36 UTC 2022 on sn-devel-184

20 months agos3:vfs.h: add comment about VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS
Stefan Metzmacher [Tue, 16 Aug 2022 07:35:16 +0000 (09:35 +0200)]
s3:vfs.h: add comment about VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
20 months agos3: smbd: Add IS_VETO_PATH checks to openat_pathref_fsp_case_insensitive().
Jeremy Allison [Thu, 11 Aug 2022 17:03:58 +0000 (10:03 -0700)]
s3: smbd: Add IS_VETO_PATH checks to openat_pathref_fsp_case_insensitive().

Returns NT_STATUS_OBJECT_NAME_NOT_FOUND for final component.

Note we have to call the check before each call to
openat_pathref_fsp(), as each call may be using a
different filesystem name. The first name is the
one passed into openat_pathref_fsp_case_insensitive()
by the caller, the second one is a name retrieved from
get_real_filename_cache_key(), and the third one is the name
retrieved from get_real_filename_at(). The last two
calls may have demangled the client given name into
a veto'ed path on the filesystem.

Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug 16 08:26:54 UTC 2022 on sn-devel-184

20 months agos3: smbd: Add IS_VETO_PATH check to openat_pathref_dirfsp_nosymlink().
Jeremy Allison [Thu, 11 Aug 2022 16:55:56 +0000 (09:55 -0700)]
s3: smbd: Add IS_VETO_PATH check to openat_pathref_dirfsp_nosymlink().

Returns NT_STATUS_OBJECT_PATH_NOT_FOUND for directory component.
Note IS_VETO_PATH only looks at the last component, so we must
do it during the directory walk on each component.

Note, we also have to check after a call to get_real_filename_at()
as it may have demangled the client sent name into a filesystem
name that matches the "veto files" parameter.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
20 months agos3: tests: Add samba3.blackbox.test_veto_files.
Jeremy Allison [Thu, 11 Aug 2022 16:51:11 +0000 (09:51 -0700)]
s3: tests: Add samba3.blackbox.test_veto_files.

Shows we currently don't look at smb.conf veto files parameter
when opening a file or directory. Checks multi-component paths.
Also checks veto files that might be hidden behind a mangled
name.

Add knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
20 months agoselftest/Samba3: let nt4_dc* use vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS=no
Stefan Metzmacher [Fri, 12 Aug 2022 08:55:42 +0000 (10:55 +0200)]
selftest/Samba3: let nt4_dc* use vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS=no

We should always test the code path without openat2 being available,
even if the kernel supports it.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Aug 15 16:00:26 UTC 2022 on sn-devel-184

20 months agovfs_default: Use openat2(RESOLVE_NO_SYMLINKS) if available
Volker Lendecke [Fri, 17 Jun 2022 15:41:52 +0000 (17:41 +0200)]
vfs_default: Use openat2(RESOLVE_NO_SYMLINKS) if available

This improves the following test:

 time smbtorture //127.0.0.1/m -Uroot%test \
        smb2.create.bench-path-contention-shared \
        --option='torture:bench_path=Apps\1\2\3\4\5\6\7\8\9\10' \
        --option="torture:timelimit=600" \
        --option="torture:nprocs=1"

From:

   open[num/s=14186,avslat=0.000044,minlat=0.000042,maxlat=0.000079]
   close[num/s=14185,avslat=0.000027,minlat=0.000025,maxlat=0.000057]

to:

   open[num/s=16917,avslat=0.000038,minlat=0.000035,maxlat=0.000340]
   close[num/s=16916,avslat=0.000020,minlat=0.000019,maxlat=0.000104]

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agovfs_default: prepare O_PATH usage with openat2()
Stefan Metzmacher [Wed, 27 Jul 2022 18:43:14 +0000 (18:43 +0000)]
vfs_default: prepare O_PATH usage with openat2()

When O_PATH is specified in flags, flag bits other than O_CLOEXEC,
O_DIRECTORY, and O_NOFOLLOW are ignored.

In preparation to use openat2(), which gives an error instead of
ignoring flags, we better remove unexpected flags, callers typically
pass O_RDONLY and O_NONBLOCK.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agos3:smbd: let openat_pathref_dirfsp_nosymlink() try VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS...
Volker Lendecke [Thu, 14 Jul 2022 17:44:04 +0000 (19:44 +0200)]
s3:smbd: let openat_pathref_dirfsp_nosymlink() try VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS first

This will reduce the amount of syscalls and the related cost drastically
for long path names.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agos3:smbd: let openat_pathref_dirfsp_nosymlink() handle ELOOP similar to ENOTDIR
Stefan Metzmacher [Fri, 12 Aug 2022 17:12:44 +0000 (19:12 +0200)]
s3:smbd: let openat_pathref_dirfsp_nosymlink() handle ELOOP similar to ENOTDIR

This is no likely to happen as we use O_NOFOLLOW with O_DIRECTORY,
but it's better to be prepared...

This will be more important in the upcoming openat2(RESOLVE_NO_SYMLINK)
case, but we should be consitent...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agos3:smbd: let openat_pathref_dirfsp_nosymlink() do a verification loop against . and...
Stefan Metzmacher [Wed, 10 Aug 2022 20:01:10 +0000 (22:01 +0200)]
s3:smbd: let openat_pathref_dirfsp_nosymlink() do a verification loop against . and .. first

I guess we should catch NT_STATUS_OBJECT_NAME_INVALID first,
currently the check is already done in check_path_syntax*,
but we may remove it in future.

But the most important reason for this is the
openat2(RESOLVE_NO_SYMLINK) optimization, which will
be introduced in the following commits.

Review with: git show -w

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agovfs: define VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS
Volker Lendecke [Fri, 3 Jun 2022 14:45:41 +0000 (16:45 +0200)]
vfs: define VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS

This will allow us to make use of openat2(RESOLVE_NO_SYMLINKS) soon.

The caller should check if connection_struct.open_how_resolve contains
VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS before using it, this avoids waisting
cpu time. But even then the caller must be prepared to handle -1/ENOSYS.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
20 months agolib/replace: let DISABLE_OPATH also undef __NR_openat2
Stefan Metzmacher [Fri, 12 Aug 2022 08:53:06 +0000 (10:53 +0200)]
lib/replace: let DISABLE_OPATH also undef __NR_openat2

The reason for DISABLE_OPATH is to simulate a non-linux
system, so we should not use openat2() either.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agolib/replace: add fallback defines for __NR_openat2
Stefan Metzmacher [Mon, 8 Aug 2022 13:33:24 +0000 (15:33 +0200)]
lib/replace: add fallback defines for __NR_openat2

sys/syscall.h might be older than the runtime kernel.

If the kernel has support for openat2() we should
try to use if anyway.

The callers have to deal with ENOSYS anyway,
so there's no difference if we get that from syscall(__NR_openat2)
or directly from rep_openat2().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agolib/replace: use syscall(__NR_openat2) if available
Stefan Metzmacher [Mon, 8 Aug 2022 13:25:39 +0000 (15:25 +0200)]
lib/replace: use syscall(__NR_openat2) if available

There's no glibc wrapper for openat2() yet, so we need
to use syscall(__NR_openat2) ourself.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agolib/replace: always include <sys/syscall.h> in replace.c if available
Stefan Metzmacher [Mon, 8 Aug 2022 13:24:28 +0000 (15:24 +0200)]
lib/replace: always include <sys/syscall.h> in replace.c if available

It will be used for openat2() soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agolib/replace: add a replacement for openat2() that returns ENOSYS
Stefan Metzmacher [Mon, 8 Aug 2022 13:23:29 +0000 (15:23 +0200)]
lib/replace: add a replacement for openat2() that returns ENOSYS

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agovfs_btrfs: fix include order, includes.h or replace.h should be first
Stefan Metzmacher [Mon, 8 Aug 2022 13:29:28 +0000 (15:29 +0200)]
vfs_btrfs: fix include order, includes.h or replace.h should be first

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agovfs_io_uring: hide a possible definition of struct open_how in liburing/compat.h
Stefan Metzmacher [Tue, 9 Aug 2022 10:29:24 +0000 (10:29 +0000)]
vfs_io_uring: hide a possible definition of struct open_how in liburing/compat.h

liburing.h will include liburing/compat.h, which either includes
linux/openat2.h or defines struct open_how itself.

This will help with the following changes, which will provide
openat2() via libreplace's system/filesys.h, either including
linux/openat2.h or defining open_how ourself.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agowafsamba: allow cflags for CHECK_TYPE[_IN]()
Stefan Metzmacher [Wed, 10 Aug 2022 22:41:28 +0000 (00:41 +0200)]
wafsamba: allow cflags for CHECK_TYPE[_IN]()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
20 months agos3:tests: add a lot more tests to test_symlink_traversal_smb2.sh
Stefan Metzmacher [Fri, 12 Aug 2022 17:07:39 +0000 (19:07 +0200)]
s3:tests: add a lot more tests to test_symlink_traversal_smb2.sh

We now also test more path components checking the difference between
OBJECT_NAME_NOT_FOUND and OBJECT_PATH_NOT_FOUND.

We also test with symlinks within the path instead of only checking
symlinks as final path components (at least for the dirfsp part).

This ensures the following commits won't introduce regressions
when adding the openat2(RESOLVE_NO_SYMLINK) optimization.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
21 months agos3:utils: Fix NULL check
Andreas Schneider [Wed, 10 Aug 2022 06:51:06 +0000 (08:51 +0200)]
s3:utils: Fix NULL check

CID 1507864

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Aug 12 21:50:23 UTC 2022 on sn-devel-184

21 months agos3:util: Initialize json_object structures so we can call json_free()
Andreas Schneider [Wed, 10 Aug 2022 06:41:24 +0000 (08:41 +0200)]
s3:util: Initialize json_object structures so we can call json_free()

CID 1507863
CID 1507865
CID 1507866
CID 1507867
CID 1507868
CID 1507869
CID 1507870

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
21 months agos3: smbd: Remove unix_convert() and associated functions.
Jeremy Allison [Tue, 9 Aug 2022 04:59:14 +0000 (21:59 -0700)]
s3: smbd: Remove unix_convert() and associated functions.

All code now uses filename_convert_dirfsp() for race-free
filename conversion.

Best viewed with:
$ git show --patience

               ----------------
              /                \
             /       REST       \
            /         IN         \
           /         PEACE        \
          /                        \
          |                        |
          |      unix_convert      |
          |                        |
          |                        |
          |       9th August       |
          |          2022          |
          |                        |
          |                        |
         *|     *  *  *            | *
_________)/\\_//(\/(/\)/\//\/\///\/|_)_______

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Aug 12 19:18:25 UTC 2022 on sn-devel-184

21 months agos3: smbd: Remove the old dfs_path_lookup() code.
Jeremy Allison [Tue, 9 Aug 2022 19:13:10 +0000 (12:13 -0700)]
s3: smbd: Remove the old dfs_path_lookup() code.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Switch get_referred_path() over to use the new dfs_path_lookup().
Jeremy Allison [Tue, 9 Aug 2022 19:11:07 +0000 (12:11 -0700)]
s3: smbd: Switch get_referred_path() over to use the new dfs_path_lookup().

New function doesn't need a TWRP argument and returns NT_STATUS_OK
on successful redirect, not NT_STATUS_PATH_NOT_COVERED.

Comment out the old dfs_path_lookup().

There are now no more users of unix_convert().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add new version of dfs_path_lookup() that uses filename_convert_dirfsp().
Jeremy Allison [Tue, 9 Aug 2022 19:07:30 +0000 (12:07 -0700)]
s3: smbd: Add new version of dfs_path_lookup() that uses filename_convert_dirfsp().

Commented out as not yet used but it's easier to see the
new logic this way.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Remove dfs_redirect().
Jeremy Allison [Wed, 10 Aug 2022 18:34:24 +0000 (11:34 -0700)]
s3: smbd: Remove dfs_redirect().

A moment of silence please.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Remove call to dfs_redirect() from filename_convert_dirfsp_nosymlink().
Jeremy Allison [Wed, 10 Aug 2022 18:32:30 +0000 (11:32 -0700)]
s3: smbd: Remove call to dfs_redirect() from filename_convert_dirfsp_nosymlink().

Use dfs_filename_convert() instead. There are now no more callers of dfs_redirect().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Remove call to dfs_redirect() from filename_convert_smb1_search_path().
Jeremy Allison [Wed, 10 Aug 2022 18:29:33 +0000 (11:29 -0700)]
s3: smbd: Remove call to dfs_redirect() from filename_convert_smb1_search_path().

Use dfs_filename_convert() instead. Code is now much simpler.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: In filename_convert_dirfsp_nosymlink(), cope with an MS-DFS link as the...
Jeremy Allison [Mon, 8 Aug 2022 20:18:56 +0000 (13:18 -0700)]
s3: smbd: In filename_convert_dirfsp_nosymlink(), cope with an MS-DFS link as the terminal component.

If the terminal component was an MSDFS link, openat_pathref_fsp_case_insensitive() will
return NT_STATUS_OBJECT_NAME_NOT_FOUND with a VALID_STAT of a symlink.

If this is the case, check if we actually found a terminal MS-DFS link
at the end of the pathname and return NT_STATUS_PATH_NOT_COVERED.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: In filename_convert_dirfsp_nosymlink(), allow a NT_STATUS_PATH_NOT_COVERED...
Jeremy Allison [Mon, 8 Aug 2022 20:15:17 +0000 (13:15 -0700)]
s3: smbd: In filename_convert_dirfsp_nosymlink(), allow a NT_STATUS_PATH_NOT_COVERED error to be returned.

openat_pathref_dirfsp_nosymlink() can now return NT_STATUS_PATH_NOT_COVERED.
Don't convert this automatically into NT_STATUS_OBJECT_PATH_NOT_FOUND.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Allow openat_pathref_dirfsp_nosymlink() to return NT_STATUS_PATH_NOT_COVERE...
Jeremy Allison [Mon, 8 Aug 2022 18:31:39 +0000 (11:31 -0700)]
s3: smbd: Allow openat_pathref_dirfsp_nosymlink() to return NT_STATUS_PATH_NOT_COVERED for a DFS link on a DFS share.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: In get create_junction(), make sure check_path_syntax() is called on return...
Jeremy Allison [Fri, 12 Aug 2022 06:57:51 +0000 (23:57 -0700)]
s3: smbd: In get create_junction(), make sure check_path_syntax() is called on returned reqpath.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: In get referred_path(), make sure check_path_syntax() is called on returned...
Jeremy Allison [Fri, 12 Aug 2022 06:55:58 +0000 (23:55 -0700)]
s3: smbd: In get referred_path(), make sure check_path_syntax() is called on returned reqpath.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add dfs_filename_convert(). Simple wrapper around parse_dfs_path().
Jeremy Allison [Mon, 8 Aug 2022 18:16:17 +0000 (11:16 -0700)]
s3: smbd: Add dfs_filename_convert(). Simple wrapper around parse_dfs_path().

Not yet used.

This is what we will use to replace dfs_redirect() in the filename
conversion code. Keep as a wrapper for now as we might want to
add some error checking around the 'hostname' and 'service'
returns.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Use helper function msdfs_servicename_matches_connection() in dfs_redirect().
Jeremy Allison [Tue, 9 Aug 2022 17:58:24 +0000 (10:58 -0700)]
s3: smbd: Use helper function msdfs_servicename_matches_connection() in dfs_redirect().

Replaces ugly complex logic.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Use helper function msdfs_servicename_matches_connection() in parse_dfs_path().
Jeremy Allison [Tue, 9 Aug 2022 17:53:18 +0000 (10:53 -0700)]
s3: smbd: Use helper function msdfs_servicename_matches_connection() in parse_dfs_path().

Replaces ugly complex logic.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add helper function msdfs_servicename_matches_connection().
Jeremy Allison [Tue, 9 Aug 2022 17:49:46 +0000 (10:49 -0700)]
s3: smbd: Add helper function msdfs_servicename_matches_connection().

Not yet used so commented out.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Remove definition of struct dfs_path.
Jeremy Allison [Mon, 8 Aug 2022 17:27:16 +0000 (10:27 -0700)]
s3: smbd: Remove definition of struct dfs_path.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Remove use of 'struct dfs_path'. Not needed for a (hostname, servicename...
Jeremy Allison [Wed, 10 Aug 2022 18:17:49 +0000 (11:17 -0700)]
s3: smbd: Remove use of 'struct dfs_path'. Not needed for a (hostname, servicename, path) tuple.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add TALLOC_CTX * parameter to parse_dfs_path().
Jeremy Allison [Wed, 10 Aug 2022 18:06:47 +0000 (11:06 -0700)]
s3: smbd: Add TALLOC_CTX * parameter to parse_dfs_path().

Not yet used. Preparing to remove 'struct dfs_path'.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Ensure smb2_file_rename_information() uses the SMB2 pathname parsers, not...
Jeremy Allison [Tue, 9 Aug 2022 17:43:45 +0000 (10:43 -0700)]
s3: smbd: Ensure smb2_file_rename_information() uses the SMB2 pathname parsers, not the SMB1 parsers.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Make sure we have identical check_path_syntax logic in smbd_smb2_create_dur...
Jeremy Allison [Tue, 9 Aug 2022 17:41:39 +0000 (10:41 -0700)]
s3: smbd: Make sure we have identical check_path_syntax logic in smbd_smb2_create_durable_lease_check(), as for smb2_create.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: In smbd_smb2_create_send() call the helper function check_path_syntax_smb2().
Jeremy Allison [Tue, 9 Aug 2022 17:39:41 +0000 (10:39 -0700)]
s3: smbd: In smbd_smb2_create_send() call the helper function check_path_syntax_smb2().

Previously for DFS names we were skipping this.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add helper function check_path_syntax_smb2().
Jeremy Allison [Tue, 9 Aug 2022 17:36:00 +0000 (10:36 -0700)]
s3: smbd: Add helper function check_path_syntax_smb2().

Not yet used, but uses check_path_syntax_smb2_msdfs()
so remove the #ifdef's around that.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Add new function check_path_syntax_smb2_msdfs() for SMB2 MSDFS paths.
Jeremy Allison [Fri, 5 Aug 2022 19:16:44 +0000 (12:16 -0700)]
s3: smbd: Add new function check_path_syntax_smb2_msdfs() for SMB2 MSDFS paths.

 #ifdef'ed out as static and not yet used.

We can't just call check_path_syntax() on these as
they are of the form hostname\share[\extrapath]
(where [\extrapath] is optional).

hostname here can be an IPv6 ':' separated address,
which check_path_syntax() fails on due to the streamname
processing.

NB. This also has to cope with out existing (broken)
libsmbclient libraries that sometimes set the DFS
flag and then send a local pathname. Cope by just
calling the normal check_path_syntax() on the
whole pathname in that case.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos3: smbd: Fix cosmetic bug logging pathnames from Linux kernel clients using SMB1...
Jeremy Allison [Sat, 6 Aug 2022 02:27:33 +0000 (19:27 -0700)]
s3: smbd: Fix cosmetic bug logging pathnames from Linux kernel clients using SMB1 DFS calls.

The Linux kernel SMB1 client has a bug - it sends
DFS pathnames as:

\\server\share\path

instead of:

\server\share\path

Causing us to mis-parse server,share,remaining_path here
and jump into 'goto local_path' at 'share\path' instead
of 'path'.

This doesn't cause an error as the limits on share names
are similar to those on pathnames.

parse_dfs_path() which we call before filename parsing
copes with this by calling trim_char on the leading '\'
characters before processing.

Do the same here so logging of pathnames looks better.

How did I find this ? Lots and lots of manual
testing with the Linux kernel client to make
sure all the recent changes haven't broken Linux
SMB1/2/3 DFS :-).

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 months agos4:torture/smb2: add smb2.bench.echo
Stefan Metzmacher [Wed, 10 Aug 2022 13:14:52 +0000 (13:14 +0000)]
s4:torture/smb2: add smb2.bench.echo

This test calls SMB2_Echo in a loop per connection.

For 4 connections with 2 parallel loops use this:

time smbtorture //127.0.0.1/m -Uroot%test smb2.bench.echo \
--option="torture:timelimit=600" \
--option="torture:nprocs=1" \
--option="torture:qdepth=2"

Sometimes the bottleneck is the smbtorture process.
In order to bring the smbd process to 100% cpu, you can use
'--option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4"'
and run multiple instances of the test at the same time,
which both talk to the same smbd process.

This is a very useful test to show how many requests are possible
at the raw SMB2 layer.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Aug 11 19:23:37 UTC 2022 on sn-devel-184

21 months agos4:torture/smb2: teach smb2.bench.path-contention-shared about --option="torture...
Stefan Metzmacher [Wed, 10 Aug 2022 11:43:20 +0000 (11:43 +0000)]
s4:torture/smb2: teach smb2.bench.path-contention-shared about --option="torture:qdepth=4"

This can now test more than one open/close loop per connection.

time smbtorture //127.0.0.1/m -Uroot%test \
smb2.create.bench-path-contention-shared \
--option='torture:bench_path=' \
--option="torture:timelimit=60" \
--option="torture:nprocs=1" \
--option="torture:qdepth=4"

The default is still 1, but it's very useful for tests.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
21 months agos4:param: add --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4"...
Stefan Metzmacher [Wed, 10 Aug 2022 13:15:45 +0000 (13:15 +0000)]
s4:param: add --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4" support...

We already handle this in the source3/libsmb code, but it's good to
have this also for torture tests.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
21 months agos3:g_lock: use TDB_VOLATILE to avoid fcntl locks
Stefan Metzmacher [Wed, 10 Aug 2022 13:16:14 +0000 (13:16 +0000)]
s3:g_lock: use TDB_VOLATILE to avoid fcntl locks

This improves 'time smbtorture3 //foo/bar -U% local-g-lock-ping-pong -o 50000000'
from ~1.400.000 to ~3.400.000 operations per second any a testsystem.

As we also use TDB_VOLATILE for locking.tdb, this is a much more
realistic test now.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>