gd/samba-autobuild/.git
6 weeks agos4/torture: Unlink test file at the beginning of smb2.read.position master
Michael Adam [Wed, 13 May 2020 08:15:11 +0000 (13:45 +0530)]
s4/torture: Unlink test file at the beginning of smb2.read.position

Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agoselftest: add python S4U2Self tests including unkeyed checksums
Isaac Boukris [Mon, 4 May 2020 16:09:53 +0000 (18:09 +0200)]
selftest: add python S4U2Self tests including unkeyed checksums

To test the CRC32 I reverted the unkeyed-checksum fix (43958af1)
and the weak-crypto fix (389d1b97). Note that the unkeyed-md5
still worked even with weak-crypto disabled, and that the
unkeyed-sha1 never worked but I left it anyway.

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri May 15 12:25:40 UTC 2020 on sn-devel-184

6 weeks agoRevert "CVE-2018-16860 selftest: Add test for S4U2Self with unkeyed checksum"
Isaac Boukris [Thu, 7 May 2020 15:17:12 +0000 (17:17 +0200)]
Revert "CVE-2018-16860 selftest: Add test for S4U2Self with unkeyed checksum"

This reverts commit 5639e973c1f6f1b28b122741763f1d05b47bc2d8.

This is no longer needed as the next commit includes a Python
test for this, without the complexity of being inside krb5.kdc.canon.

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 weeks agoRevert "selftest: mitm-s4u2self: use zlib for CRC32_checksum calc"
Isaac Boukris [Thu, 7 May 2020 15:17:00 +0000 (17:17 +0200)]
Revert "selftest: mitm-s4u2self: use zlib for CRC32_checksum calc"

This reverts commit 151f8c0f31d3d17b9418db3793ec14ba7dbf2143.

This allows a clean revert (and so removal) of the test.

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 weeks agoRevert "selftest: allow any kdc error in mitm-s4u2self test"
Isaac Boukris [Thu, 7 May 2020 15:16:53 +0000 (17:16 +0200)]
Revert "selftest: allow any kdc error in mitm-s4u2self test"

This reverts commit a53fa8ffe3e36f7921baf5d31a1052747f90aa7d.

This allows a clean revert (and so removal) of the test.

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 weeks agosmb2_server: do async shutdown for pending multi-channel requests
Stefan Metzmacher [Fri, 4 Oct 2019 12:55:52 +0000 (14:55 +0200)]
smb2_server: do async shutdown for pending multi-channel requests

We have wait until all pending requests are done before we can
TALLOC_FREE() the connection structure.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri May 15 10:26:29 UTC 2020 on sn-devel-184

6 weeks agosmbXsrv_session: add a smbXsrv_session_disconnect_xconn() helper
Stefan Metzmacher [Fri, 4 Oct 2019 10:11:00 +0000 (12:11 +0200)]
smbXsrv_session: add a smbXsrv_session_disconnect_xconn() helper

This removes the connection references from the session channel
array for each session that's used on the connection.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmb2_server: call smbXsrv_connection_disconnect_transport() early on network errors
Stefan Metzmacher [Fri, 4 Oct 2019 12:56:40 +0000 (14:56 +0200)]
smb2_server: call smbXsrv_connection_disconnect_transport() early on network errors

It's good to remember the first error we got and makes sure we don't try
any further io on the connection.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmb2_server: add and use a function that calculated the remaining channels
Stefan Metzmacher [Fri, 4 Oct 2019 12:49:59 +0000 (14:49 +0200)]
smb2_server: add and use a function that calculated the remaining channels

This is useful for debugging, but also simplies the following changes,
where client->connections may hold disconnected connections until
all pending requests are finished.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmb2_server: let smbd_server_connection_terminate_ex() call smbXsrv_connection_discon...
Stefan Metzmacher [Fri, 4 Oct 2019 12:30:17 +0000 (14:30 +0200)]
smb2_server: let smbd_server_connection_terminate_ex() call smbXsrv_connection_disconnect_transport()

If the connection is broken mark it as invalid and close
the socket.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agos3:smbd: split out smbXsrv_connection_disconnect_transport()
Stefan Metzmacher [Fri, 4 Oct 2019 12:26:20 +0000 (14:26 +0200)]
s3:smbd: split out smbXsrv_connection_disconnect_transport()

It's good to have an isolated function that just disconnects the
lower layer transport and remembers the first error status.

This will be used in more placed in the following commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmb2_server: make sure we detect stale smbXsrv_connection pointers in smbXsrv_channel...
Stefan Metzmacher [Fri, 4 Oct 2019 08:02:56 +0000 (10:02 +0200)]
smb2_server: make sure we detect stale smbXsrv_connection pointers in smbXsrv_channel_global

Pointer values can be reused (yes, I hit that during my testing!).
Introduce a channel_id to identify connections and also add
some timestamps to make debugging easier.

This makes smbXsrv_session_find_channel() much more robust.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmb2_server: update inline comment for max channels
Günther Deschner [Wed, 24 Jan 2018 16:14:59 +0000 (17:14 +0100)]
smb2_server: update inline comment for max channels

All Windows versions have the limit of 32 channels.

Signed-off-by: Guenther Deschner <gd@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosmbXsrv_client: make sure that we store a valid blob
Stefan Metzmacher [Thu, 7 May 2020 13:49:24 +0000 (06:49 -0700)]
smbXsrv_client: make sure that we store a valid blob

This fixes a regression introduced by
14182350f8397d27d7642dae595dc52691f0acfe
("librpc ndr: ndr_pull_advance check for unsigned overflow.")
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14236

ndr_push_smbXsrv_client_global0() is happy with
pushing NULL pointers for r->{local_address,remote_address,remote_name},
while the IDL doesn't allow it.
In turn ndr_pull_smbXsrv_client_global0() no longer ignores the error.

This means multi-channel connections were broken,
and we paniced on a NULL pointer.
It's really sad that we still don't have automated tests for it.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agosmbXsrv_client: fix debug message in smbXsrv_client_create()
Stefan Metzmacher [Thu, 7 May 2020 13:54:37 +0000 (06:54 -0700)]
smbXsrv_client: fix debug message in smbXsrv_client_create()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
6 weeks agos4/rpc_server/dnsserver: Allow parsing of dnsProperty to fail gracefully
Andrew Bartlett [Wed, 13 May 2020 00:01:05 +0000 (12:01 +1200)]
s4/rpc_server/dnsserver: Allow parsing of dnsProperty to fail gracefully

On (eg) the

DC=_msdcs.X.Y,CN=MicrosoftDNS,DC=ForestDnsZones,DC=X,DC=Y

record, in domains that have had a Microsoft Windows DC an attribute:

dNSProperty:: AAAAAAAAAAAAAAAAAQAAAJIAAAAAAAAA

000000 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00  >................<
000010 92 00 00 00 00 00 00 00                          >........<
000018

We, until samba 4.12, would parse this as:

pull returned Success
    dnsp_DnsProperty: struct dnsp_DnsProperty
        wDataLength              : 0x00000000 (0)
        namelength               : 0x00000000 (0)
        flag                     : 0x00000000 (0)
        version                  : 0x00000001 (1)
        id                       : DSPROPERTY_ZONE_NS_SERVERS_DA (146)
        data                     : union dnsPropertyData(case 0)
        name                     : 0x00000000 (0)
dump OK

However, the wDataLength is 0.  There is not anything in
[MS-DNSP] 2.3.2.1 dnsProperty to describe any special behaviour
for when the id suggests that there is a value, but wDataLength is 0.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/445c7843-e4a1-4222-8c0f-630c230a4c80

We now fail to parse it, because we expect an entry with id DSPROPERTY_ZONE_NS_SERVERS_DA
to therefore have a valid DNS_ADDR_ARRAY (section 2.2.3.2.3).

As context we changed it in our commit fee5c6a4247aeac71318186bbff7708d25de5912
because of bug https://bugzilla.samba.org/show_bug.cgi?id=14206
which was due to the artificial environment of the fuzzer.

Microsoft advises that Windows also fails to parse this, but
instead of failing the operation, the value is ignored.

Reported by Alex MacCuish.  Many thanks for your assistance in
tracking down the issue.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri May 15 07:29:17 UTC 2020 on sn-devel-184

6 weeks agoselftest: Add test for handling of "short" dnsProperty records
Andrew Bartlett [Wed, 13 May 2020 22:19:45 +0000 (10:19 +1200)]
selftest: Add test for handling of "short" dnsProperty records

These have been known to be given by Windows DCs that share the same domain
as while invalid, they are not format-checked inbound when set by the DNS
Manager MMC applet over the dnsserver pipe to Windows.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 weeks agolibrpc/idl: Add dnsp_DnsProperty_short
Andrew Bartlett [Wed, 13 May 2020 22:21:19 +0000 (10:21 +1200)]
librpc/idl: Add dnsp_DnsProperty_short

This will be used by a test and the DNS server code to parse short dnsProperty
records which come from Windows servers.

This example is from the value that caused Samba to fail as it
can not be parsed as a normal dnsp_DnsProperty

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 weeks agoselftest: Avoid running the slowest of the "none" tests in samba-o3
Andrew Bartlett [Fri, 8 May 2020 11:28:52 +0000 (23:28 +1200)]
selftest: Avoid running the slowest of the "none" tests in samba-o3

This job is already quite long and these tests are unlikely
to vary between hosts or under the -O3 compile

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
6 weeks agosmbd: Store share_entries in locking.tdb again
Volker Lendecke [Tue, 14 Apr 2020 14:51:15 +0000 (16:51 +0200)]
smbd: Store share_entries in locking.tdb again

The "base on g_lock" patch is a slowdown because we do more tdb
operations. Getting share_entries.tdb back into locking.tdb tries to
speed things up again.

Now that we're based on g_lock we'll most likely use a different
method in order to spread the entries across multiple records.

It still maintains the sorted array of share modes within locking.tdb,
but not as part of the expensive ndr marshalling of the complete
array.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 15 02:27:49 UTC 2020 on sn-devel-184

6 weeks agosmbd: Move share mode entry parsing up in the file
Volker Lendecke [Thu, 26 Mar 2020 18:45:10 +0000 (19:45 +0100)]
smbd: Move share mode entry parsing up in the file

Will be used by parsing code soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agosmbd: Base locking.tdb on g_lock.c
Volker Lendecke [Tue, 5 Nov 2019 11:01:52 +0000 (12:01 +0100)]
smbd: Base locking.tdb on g_lock.c

This means we don't hold locking.tdb mutexes anymore while we do
filesystem-level operations. This has hurt ctdb quite a bit: A smbd hanging in
an unlink() syscall prevents ctdb from recovering locking.tdb.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_dump_send/recv
Volker Lendecke [Tue, 24 Mar 2020 08:54:26 +0000 (09:54 +0100)]
lib: Add g_lock_dump_send/recv

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_set_lock_order()
Volker Lendecke [Thu, 21 Nov 2019 14:20:07 +0000 (15:20 +0100)]
lib: Add g_lock_set_lock_order()

Optionally allow a database with g_lock format to participate in the dbwarp
lock order check. Will be used once locking.tdb is based upon g_lock.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_writev_data
Volker Lendecke [Wed, 29 Apr 2020 13:35:39 +0000 (15:35 +0200)]
lib: Add g_lock_writev_data

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Allow additional dbufs in g_lock_store()
Volker Lendecke [Wed, 29 Apr 2020 13:28:03 +0000 (15:28 +0200)]
lib: Allow additional dbufs in g_lock_store()

Preparation for g_lock_writev_data()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_seqnum()
Volker Lendecke [Tue, 5 Nov 2019 15:36:59 +0000 (16:36 +0100)]
lib: Add g_lock_seqnum()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_wake_watchers()
Volker Lendecke [Mon, 4 Nov 2019 15:03:52 +0000 (16:03 +0100)]
lib: Add g_lock_wake_watchers()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agotorture: Test g_lock_watch_data_send()/recv()
Volker Lendecke [Thu, 31 Oct 2019 10:45:36 +0000 (11:45 +0100)]
torture: Test g_lock_watch_data_send()/recv()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Add g_lock_watch_data_send/recv()
Volker Lendecke [Wed, 30 Oct 2019 15:12:11 +0000 (16:12 +0100)]
lib: Add g_lock_watch_data_send/recv()

Same concept as dbwrap_watched_watch_send/recv: Get informed if the
underlying data of a record changes. This utilizes the watched
database that g_lock is based upon anyway. To avoid spurious wakeups
by pure g_lock operations this patch adds a sequence number for the
data that is stored in the g_lock data field.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agolib: Allow DBWRAP_LOCK_ORDER_NONE in db_open()
Volker Lendecke [Thu, 21 Nov 2019 14:20:33 +0000 (15:20 +0100)]
lib: Allow DBWRAP_LOCK_ORDER_NONE in db_open()

locking.tdb will not have a LOCK_ORDER anymore, this will be done by
the code in g_lock.c. We need to allow opening a database with dbwrap
without having a lock order.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agodbwrap: Make dbwrap_lock_order_[un]lock() public
Volker Lendecke [Thu, 21 Nov 2019 14:19:16 +0000 (15:19 +0100)]
dbwrap: Make dbwrap_lock_order_[un]lock() public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agodbwrap: Simplify dbwrap_lock_order_[un]lock()
Volker Lendecke [Thu, 21 Nov 2019 12:23:39 +0000 (13:23 +0100)]
dbwrap: Simplify dbwrap_lock_order_[un]lock()

Directly pass the database name and lock order to the core functions,
avoid passing struct db_context.

In the next steps these functions will become public: locking.tdb will
be based on g_lock.c to avoid holding a tdb-level locking.tdb mutex
while doing complex file system operations like unlink() which can
take ages on FAT for example.

This means that g_lock.c will participate in the dbwrap lock order
protection and needs access to dbwrap_lock_order_[un]lock() without
providing a direct db_context.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agosrvsvc: Move brl_get_locks() out of enum_file_fn()
Volker Lendecke [Tue, 21 Apr 2020 12:54:25 +0000 (14:54 +0200)]
srvsvc: Move brl_get_locks() out of enum_file_fn()

With share_infos.tdb this is a locking order violation:
share_infos.tdb is level 4, brlock.tdb is level 2. Avoid this by first
walking the share_infos.tdb and then fetching all the brlock entries.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu May 14 22:06:32 UTC 2020 on sn-devel-184

6 weeks agotest: Show that netfileenum is broken
Volker Lendecke [Mon, 11 May 2020 09:08:54 +0000 (11:08 +0200)]
test: Show that netfileenum is broken

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agorpcclient: Make netfileenum cmd print the path names
Volker Lendecke [Mon, 11 May 2020 09:09:02 +0000 (11:09 +0200)]
rpcclient: Make netfileenum cmd print the path names

Needed for the next commit testing netfileenum

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agorpcclient: Use struct initializers in cmd_srvsvc_net_file_enum()
Volker Lendecke [Wed, 22 Apr 2020 11:21:40 +0000 (13:21 +0200)]
rpcclient: Use struct initializers in cmd_srvsvc_net_file_enum()

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosrvsvc: Collect file ids in enum_file_fn()
Volker Lendecke [Tue, 21 Apr 2020 12:32:16 +0000 (14:32 +0200)]
srvsvc: Collect file ids in enum_file_fn()

Will be used a few patches down

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosrvsvc: Use a struct initializer in net_enum_files()
Volker Lendecke [Tue, 21 Apr 2020 12:42:50 +0000 (14:42 +0200)]
srvsvc: Use a struct initializer in net_enum_files()

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosrvsvc: Directly use "ctr3->count" instead of "i"
Volker Lendecke [Tue, 21 Apr 2020 12:24:48 +0000 (14:24 +0200)]
srvsvc: Directly use "ctr3->count" instead of "i"

To me this was not very transparent, and now that we have "ctr3" a
single indirect looks okay

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosrvsvc: Use a struct assignment in enum_file_fn()
Volker Lendecke [Tue, 21 Apr 2020 12:21:49 +0000 (14:21 +0200)]
srvsvc: Use a struct assignment in enum_file_fn()

Looks nicer than 5 complex array references...

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agosrvsvc: Introduce ctx3 helper var in enum_file_fn()
Volker Lendecke [Tue, 21 Apr 2020 12:16:41 +0000 (14:16 +0200)]
srvsvc: Introduce ctx3 helper var in enum_file_fn()

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 weeks agovfs: remove root_dir_fid arg from SMB_VFS_CREATE_FILE()
Ralph Boehme [Thu, 14 May 2020 13:59:33 +0000 (15:59 +0200)]
vfs: remove root_dir_fid arg from SMB_VFS_CREATE_FILE()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu May 14 19:43:27 UTC 2020 on sn-devel-184

6 weeks agosmbd: move processing of root_dir_fid outside of SMB_VFS_CREATE_FILE()
Ralph Boehme [Thu, 14 May 2020 11:42:05 +0000 (13:42 +0200)]
smbd: move processing of root_dir_fid outside of SMB_VFS_CREATE_FILE()

The only two callers that pass a root_dir_fid != 0 are reply_ntcreate_and_X()
and call_nt_transact_create(). By moving root_dir_fid processing outside of
SMB_VFS_CREATE_FILE() we can avoid rewriting get_relative_fid_filename() to work
with *AT semantics and dirfsps.

Bonus points: the previous code in both functions passed fname to
filename_convert() which can't really have worked as it is relative to
root_dir_fid so filename_convert() will not be able to stat() the relative path
and it's components.

The only test I can find that uses a root dir_fid is raw.samba3rootdirfid and
that uses a handle on the share root which will work.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agos4/torture: add a *real* root_dir_fid test
Ralph Boehme [Thu, 14 May 2020 12:22:16 +0000 (14:22 +0200)]
s4/torture: add a *real* root_dir_fid test

raw.samba3rootdirfid tests with the share root directory as root_dir_fid handle,
that doesn't cover the case where the relative name has more then one path
component. It only works because in unix_convert() we run into the creating file
optimasation.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 weeks agotestprogs: Add 'net ads join' test for fips
Andreas Schneider [Wed, 13 May 2020 14:33:14 +0000 (16:33 +0200)]
testprogs: Add 'net ads join' test for fips

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Thu May 14 14:27:26 UTC 2020 on sn-devel-184

7 weeks agolib:param: Fix memory leak in lpcfg_load_internal()
awalker [Mon, 6 Apr 2020 19:50:41 +0000 (15:50 -0400)]
lib:param: Fix memory leak in lpcfg_load_internal()

Signed-off-by: awalker <awalker@ixsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed May 13 17:34:43 UTC 2020 on sn-devel-184

7 weeks agoctdb: increase TasksMax limit, the systemd default is just 512
Ralph Boehme [Tue, 12 May 2020 13:30:05 +0000 (15:30 +0200)]
ctdb: increase TasksMax limit, the systemd default is just 512

In 2015 systemd introduced a TasksMax which limits the number of processes in a
unit:

https://lists.freedesktop.org/archives/systemd-devel/2015-November/035006.html

The default of 512 may be too low in certain situations leading to vfork()
failing with errno=EAGAIN when trying to spawn lock-helper processes.

With the default for LockProcessesPerDB being 200 the increased TasksMax limit
should cover the problematic scenario.

Additional background: the failing vfork()s have been seen on production
clusters and were tracked down to being logged in the context of ctdb calling
tdb_repack().

Links:

https://github.com/systemd/systemd/commit/9ded9cd14cc03c67291b10a5c42ce5094ba0912f
https://www.suse.com/support/kb/doc/?id=000015901
https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting
https://www.percona.com/blog/2019/01/02/tasksmax-another-setting-that-can-cause-mysql-error-messages/

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed May 13 13:30:12 UTC 2020 on sn-devel-184

7 weeks agos3: libsmbclient: Finish unifing bad iconv behavior across CORE NT1 SMB2 protocols.
Jeremy Allison [Mon, 11 May 2020 22:58:27 +0000 (15:58 -0700)]
s3: libsmbclient: Finish unifing bad iconv behavior across CORE NT1 SMB2 protocols.

On bad name conversion, exit the directory listing with an error, but leave the
connection intact. We were already checking for finfo->name == NULL here,
but were ignoring it and not reporting an error.

Remove the knownfail.d/bad_iconv file as we now
behave the same across CORE/NT1/SMB2.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue May 12 21:32:44 UTC 2020 on sn-devel-184

7 weeks agos3: libsmb: In SMB2 return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion...
Jeremy Allison [Mon, 11 May 2020 19:23:49 +0000 (12:23 -0700)]
s3: libsmb: In SMB2 return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.

Can happen if namelen == 0.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agos3: libsmb: In SMB1 old protocol - return NT_STATUS_INVALID_NETWORK_RESPONSE if name...
Jeremy Allison [Mon, 11 May 2020 19:34:10 +0000 (12:34 -0700)]
s3: libsmb: In SMB1 old protocol - return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.

Can happen if namelen == 0.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agos3: selftest: Add test_smbclient_iconv.sh to check client behavior on bad name conver...
Jeremy Allison [Mon, 11 May 2020 22:37:00 +0000 (15:37 -0700)]
s3: selftest: Add test_smbclient_iconv.sh to check client behavior on bad name conversion.

SMB2 and NT1 fail this, CORE already returns NT_STATUS_INVALID_NETWORK_RESPONSE
on bad conversion.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agos3: selftest: Add share definition [bad_iconv] in fileserver.
Jeremy Allison [Mon, 11 May 2020 21:10:54 +0000 (14:10 -0700)]
s3: selftest: Add share definition [bad_iconv] in fileserver.

Creates a utf8 valid filename within that is invalid in CP850.
Useful to test smbclient list directory character set conversions.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agovfs_io_uring: retry after a short writes in vfs_io_uring_pwrite_completion()
Stefan Metzmacher [Fri, 8 May 2020 11:30:17 +0000 (13:30 +0200)]
vfs_io_uring: retry after a short writes in vfs_io_uring_pwrite_completion()

We need to be prepared for short writes from the kernel depending on
the state of the page cache.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: retry after a short read in vfs_io_uring_pread_completion()
Stefan Metzmacher [Fri, 8 May 2020 11:30:17 +0000 (13:30 +0200)]
vfs_io_uring: retry after a short read in vfs_io_uring_pread_completion()

We need to be prepared for short reads from the kernel depending on
the state of the page cache. Windows and Mac clients don't
expect short reads for files, so we need to retry ourself.

For the future we may be able to play with some io_uring flags
in order to avoid the retries in userspace, but for now we just fix
the data corruption bug...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: protect vfs_io_uring_fsync_completion() against invalid results
Stefan Metzmacher [Fri, 8 May 2020 09:38:56 +0000 (11:38 +0200)]
vfs_io_uring: protect vfs_io_uring_fsync_completion() against invalid results

We should never get back a value > 0.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: protect vfs_io_uring_pwrite_completion() against invalid results
Stefan Metzmacher [Fri, 8 May 2020 09:38:56 +0000 (11:38 +0200)]
vfs_io_uring: protect vfs_io_uring_pwrite_completion() against invalid results

We should never get more acked than we asked for.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: protect vfs_io_uring_pread_completion() against invalid results
Stefan Metzmacher [Fri, 8 May 2020 09:38:56 +0000 (11:38 +0200)]
vfs_io_uring: protect vfs_io_uring_pread_completion() against invalid results

We should never get back more than we asked for.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: split out a vfs_io_uring_pwrite_submit() function
Stefan Metzmacher [Fri, 8 May 2020 09:17:51 +0000 (11:17 +0200)]
vfs_io_uring: split out a vfs_io_uring_pwrite_submit() function

This can be reused when we add handling for short writes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: split out a vfs_io_uring_pread_submit() function
Stefan Metzmacher [Fri, 8 May 2020 09:17:51 +0000 (11:17 +0200)]
vfs_io_uring: split out a vfs_io_uring_pread_submit() function

This can be reused when we add handling for short reads.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: split out a vfs_io_uring_request_submit() function
Stefan Metzmacher [Fri, 8 May 2020 09:17:51 +0000 (11:17 +0200)]
vfs_io_uring: split out a vfs_io_uring_request_submit() function

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: avoid stack recursion of vfs_io_uring_queue_run()
Stefan Metzmacher [Fri, 8 May 2020 19:29:53 +0000 (21:29 +0200)]
vfs_io_uring: avoid stack recursion of vfs_io_uring_queue_run()

Instead we remember if recursion was triggered and jump to
the start of the function again from the end.

This should make it safe to be called from the completion_fn().

This is hideously complex stuff, so document the hell
out of it.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()
Stefan Metzmacher [Fri, 8 May 2020 11:17:05 +0000 (13:17 +0200)]
vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()

This makes the follow up commits easier as we don't have to care
about overflows.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send()
Stefan Metzmacher [Fri, 8 May 2020 11:17:05 +0000 (13:17 +0200)]
vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send()

This makes the follow up commits easier as we don't have to care
about overflows.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()
Stefan Metzmacher [Fri, 8 May 2020 08:52:52 +0000 (10:52 +0200)]
vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()

We should do that as early as possible and that's in
vfs_io_uring_fsync_completion().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: move error handling out of vfs_io_uring_pwrite_recv()
Stefan Metzmacher [Fri, 8 May 2020 08:52:52 +0000 (10:52 +0200)]
vfs_io_uring: move error handling out of vfs_io_uring_pwrite_recv()

We should do that as early as possible and that's in
vfs_io_uring_pwrite_completion().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: move error handling out of vfs_io_uring_pread_recv()
Stefan Metzmacher [Fri, 8 May 2020 08:52:52 +0000 (10:52 +0200)]
vfs_io_uring: move error handling out of vfs_io_uring_pread_recv()

We should do that as early as possible and that's in
vfs_io_uring_pread_completion().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: introduce vfs_io_uring_request->completion_fn()
Stefan Metzmacher [Fri, 8 May 2020 08:42:59 +0000 (10:42 +0200)]
vfs_io_uring: introduce vfs_io_uring_request->completion_fn()

We'll need to add more logic than a simple _tevent_req_done()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: replace vfs_io_uring_request->state with _tevent_req_data()
Stefan Metzmacher [Fri, 8 May 2020 08:39:52 +0000 (10:39 +0200)]
vfs_io_uring: replace vfs_io_uring_request->state with _tevent_req_data()

We don't need a direct pointer to the state...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agovfs_io_uring: fix the prefix for parametric options from 'vfs_io_uring' to 'io_uring'
Stefan Metzmacher [Wed, 6 May 2020 10:05:47 +0000 (03:05 -0700)]
vfs_io_uring: fix the prefix for parametric options from 'vfs_io_uring' to 'io_uring'

This is what the manpage describes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agos3: VFS: default. Change pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE_SEND() to...
Jeremy Allison [Thu, 7 May 2020 19:48:49 +0000 (12:48 -0700)]
s3: VFS: default. Change pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE_SEND() to protect against short writes.

Note that as sys_pwrite_full() deals with the EINTR case
we can remove the do {} while loop here.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agos3: VFS: default. Change pread() -> sys_pread_full() in SMB_VFS_PREAD_SEND() to prote...
Jeremy Allison [Thu, 7 May 2020 19:45:10 +0000 (12:45 -0700)]
s3: VFS: default. Change pread() -> sys_pread_full() in SMB_VFS_PREAD_SEND() to protect against short reads.

Note that as sys_pread_full() deals with the EINTR case
we can remove the do {} while loop here.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agos3: VFS: default. Change sys_pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE() to...
Jeremy Allison [Thu, 7 May 2020 19:44:26 +0000 (12:44 -0700)]
s3: VFS: default. Change sys_pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE() to protect against short writes.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agos3: VFS: default. Change sys_pread() -> sys_pread_full() in SMB_VFS_PREAD() to protec...
Jeremy Allison [Thu, 7 May 2020 19:43:34 +0000 (12:43 -0700)]
s3: VFS: default. Change sys_pread() -> sys_pread_full() in SMB_VFS_PREAD() to protect against short reads.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agos3: VFS: aio_fork: Change sys_pwrite() -> sys_pwrite_full() to protect against short...
Jeremy Allison [Thu, 7 May 2020 19:42:53 +0000 (12:42 -0700)]
s3: VFS: aio_fork: Change sys_pwrite() -> sys_pwrite_full() to protect against short writes.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agos3: VFS: aio_fork: Change sys_pread() -> sys_pread_full() to protect against short...
Jeremy Allison [Thu, 7 May 2020 19:42:10 +0000 (12:42 -0700)]
s3: VFS: aio_fork: Change sys_pread() -> sys_pread_full() to protect against short reads.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
7 weeks agosmbd: add vfs_valid_{pread,pwrite}_range() checks where needed
Stefan Metzmacher [Mon, 11 May 2020 16:18:24 +0000 (18:18 +0200)]
smbd: add vfs_valid_{pread,pwrite}_range() checks where needed

I checked all callers of SMB_VFS_PWRITE[_SEND](),
all callers of SMB_VFS_PREAD[_SEND]() and also
places where we append to the file and allocate
more space.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agos3:smbd: add vfs_valid_{pread,pwrite}_range() helper functions
Stefan Metzmacher [Mon, 11 May 2020 20:00:37 +0000 (22:00 +0200)]
s3:smbd: add vfs_valid_{pread,pwrite}_range() helper functions

These implement the SMB2 visible behavior of the [MS-FSA]
2.1.5.2 Server Requests a Read and 2.1.5.3 Server Requests a Write
constraints. Note that offset < 0 is not allowed over SMB.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agos3:smbd: handle 0 length writes as no-op.
Stefan Metzmacher [Mon, 11 May 2020 16:18:24 +0000 (18:18 +0200)]
s3:smbd: handle 0 length writes as no-op.

They should never touch the SMB_VFS layer
and they never trigger an DISK_FULL error.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agosmb2_server: fix smbd_smb2_request_verify_sizes() for SMB2_OP_WRITE
Stefan Metzmacher [Mon, 11 May 2020 16:18:24 +0000 (18:18 +0200)]
smb2_server: fix smbd_smb2_request_verify_sizes() for SMB2_OP_WRITE

Writes with a length of 0 are allowed.

The readfile related check we had before was not really useful
as min_dyn_len can only every be 0 or 1 (and for SMB2_OP_WRITE it's
always 1). So we checked
  if (unread_bytes > 0) {
     if (unread_bytes < 1) {
       return error;
     }
  }

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agolib: util: Add sys_pwrite_full().
Jeremy Allison [Thu, 7 May 2020 19:34:32 +0000 (12:34 -0700)]
lib: util: Add sys_pwrite_full().

A pwrite wrapper that will deal with EINTR and never return a short
write unless the file system returns an error. Copes with the
unspecified edge condition of pwrite returning zero by changing
the return to -1, errno = ENOSPC.

Thread-safe so may be used as a replacement for pwrite
inside pwrite_do() thread functions.

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

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
7 weeks agolib: util: Add sys_pread_full().
Jeremy Allison [Thu, 7 May 2020 19:32:48 +0000 (12:32 -0700)]
lib: util: Add sys_pread_full().

A pread wrapper that will deal with EINTR and never return a short
read unless pread returns zero meaning EOF.

Thread-safe so may be used as a replacement for pread
inside pread_do() thread functions.

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

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
7 weeks agolib: util: Add sys_valid_io_range()
Stefan Metzmacher [Fri, 8 May 2020 11:06:54 +0000 (13:06 +0200)]
lib: util: Add sys_valid_io_range()

This implements the contraints of
[MS-FSA] 2.1.5.2 Server Requests a Read.

The special handling of [MS-FSA] 2.1.5.3 Server Requests a Write
with offset < 0, should be handled by higher layers!
Which means the check can also be used for writes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agos4:torture: add tests to test the SMB2 read/write offset/length boundaries
Stefan Metzmacher [Mon, 11 May 2020 10:37:41 +0000 (12:37 +0200)]
s4:torture: add tests to test the SMB2 read/write offset/length boundaries

[MS-FSA] 2.1.5.2 Server Requests a Read and
2.1.5.3 Server Requests a Write define some contraints.

These tests demonstrate that ((int64_t)offset) < 0) is
not allowed for both reads and writes for SMB.
Also the special case for writes at offset -2 is not possible
nor the append mode with offset < 0.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 weeks agos3/locking: prime flags in a fresh sharemode data object
Ralph Boehme [Mon, 11 May 2020 09:35:04 +0000 (11:35 +0200)]
s3/locking: prime flags in a fresh sharemode data object

This is needed to prime the logic in share_mode_flags_restrict() for the
following scenario:

* (First) CREATE on a file with FILE_SHARE_NONE and
  access_mask=FILE_READ_ATTRIBUTES (a stat-open).

* share_mode_flags_restrict() gets called with

    share_mode_flags_restrict(flags=0,
                              access_mask=0x80,
                              share_mode=0,
                              lease_type=UINT32_MAX)

  and returns a value where none of the FILE_SHARE_* flags is set.

As a result share_mode_data.flags doesn't reflect the share-modes in effect.

This doesn't change any current visible behaviour outside of open_mode_check(),
but it avoids calling share_mode_forall_entries() in open_mode_check_fn().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue May 12 19:52:48 UTC 2020 on sn-devel-184

7 weeks agosmbd: fix for bug 14375
Ralph Boehme [Sat, 9 May 2020 13:13:54 +0000 (15:13 +0200)]
smbd: fix for bug 14375

... with many thanks to an enthusiastic Samba user from Poland for helping to
track this down.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
7 weeks agosmbd: make conflicting_access available to other functions
Ralph Boehme [Mon, 11 May 2020 11:42:39 +0000 (13:42 +0200)]
smbd: make conflicting_access available to other functions

The next commit adds more users of conflicting_access.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
7 weeks agos4/torture: reproducer for bug 14375
Ralph Boehme [Sat, 9 May 2020 13:29:15 +0000 (15:29 +0200)]
s4/torture: reproducer for bug 14375

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
7 weeks agoselftest: split a knownfail entry
Ralph Boehme [Mon, 11 May 2020 13:56:58 +0000 (15:56 +0200)]
selftest: split a knownfail entry

Lists the two existing subtests indidivually in preparation of adding a third
that is going to pass against ad_dc_ntvfs.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
7 weeks agowinbind.service: drop quotes from $WINBINDOPTIONS variable
Marcos Mello [Fri, 8 May 2020 10:56:32 +0000 (07:56 -0300)]
winbind.service: drop quotes from $WINBINDOPTIONS variable

systemd parser splits arguments at whitespaces respecting quotes
when necessary.

Signed-off-by: Marcos Mello <marcosfrm@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue May 12 12:27:11 UTC 2020 on sn-devel-184

7 weeks agoDrop NotifyAccess=all from systemd units
Marcos Mello [Fri, 8 May 2020 10:44:51 +0000 (07:44 -0300)]
Drop NotifyAccess=all from systemd units

The implicit NotifyAccess=main is enough since Samba daemons do not
fork()/exit() anymore under systemd.

Signed-off-by: Marcos Mello <marcosfrm@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
7 weeks agolib ldb: Limit depth of ldb_parse_tree
Gary Lockyer [Tue, 21 Apr 2020 03:37:40 +0000 (15:37 +1200)]
lib ldb: Limit depth of ldb_parse_tree

Limit the number of nested conditionals allowed by ldb_parse tree to
128, to avoid potential stack overflow issues.

Credit Oss-Fuzz

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19508

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Sun May 10 23:21:08 UTC 2020 on sn-devel-184

7 weeks agolib util ASN.1: Panic on ASN.1 tag mismatch
Gary Lockyer [Tue, 28 Apr 2020 23:09:34 +0000 (11:09 +1200)]
lib util ASN.1: Panic on ASN.1 tag mismatch

If the ASN.1 depth is zero in asn1_end_tag, call smb_panic. Rather than
ignoring the condition.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 weeks agos4 cldap server tests: request size limit tests
Gary Lockyer [Tue, 28 Apr 2020 21:17:52 +0000 (09:17 +1200)]
s4 cldap server tests: request size limit tests

Add tests for packet size limits.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 weeks agos4 ldap server tests: request size limit tests
Gary Lockyer [Tue, 28 Apr 2020 01:55:04 +0000 (13:55 +1200)]
s4 ldap server tests: request size limit tests

Extra tests for ldap maximum request size limits.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 weeks agoFix clang 9 for-loop-analysis warnings
Gary Lockyer [Mon, 4 May 2020 23:42:28 +0000 (11:42 +1200)]
Fix clang 9 for-loop-analysis warnings

Review-note: The for loop increment operation was changed and the
             trailing i++ was removed from the loop body.
             The resulting for statement is equivalent to the original

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri May  8 11:16:18 UTC 2020 on sn-devel-184

7 weeks agoFix clang 9 format-nonliteral warnings
Gary Lockyer [Tue, 5 May 2020 01:48:10 +0000 (13:48 +1200)]
Fix clang 9 format-nonliteral warnings

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agoFix clang 9 missing-field-initializer warnings
Gary Lockyer [Tue, 5 May 2020 01:47:39 +0000 (13:47 +1200)]
Fix clang 9 missing-field-initializer warnings

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agoFix clang 9 unused-function warnings
Gary Lockyer [Fri, 1 May 2020 03:03:10 +0000 (15:03 +1200)]
Fix clang 9 unused-function warnings

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 weeks agoFix clang 9 enum-conversion warnings
Gary Lockyer [Thu, 30 Apr 2020 23:58:52 +0000 (11:58 +1200)]
Fix clang 9 enum-conversion warnings

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>