1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

54986 Commits

Author SHA1 Message Date
Ralph Boehme
54883d4b3a 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>
2020-05-14 18:07:39 +00:00
Ralph Boehme
f0df11ce9d 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>
2020-05-14 18:07:39 +00:00
Jeremy Allison
393da520e4 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
2020-05-12 21:32:44 +00:00
Jeremy Allison
753115a8d1 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>
2020-05-12 19:53:46 +00:00
Jeremy Allison
b10de0bb64 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>
2020-05-12 19:53:46 +00:00
Jeremy Allison
e016671d34 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>
2020-05-12 19:53:46 +00:00
Stefan Metzmacher
0f01b10679 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>
2020-05-12 19:53:46 +00:00
Stefan Metzmacher
42e77c4cf2 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
c57a731c4c 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
283f968722 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
f085dbf8b2 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
2f6abb00b0 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
9de4f8be1d 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
ab89b8e753 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
f96f45c9ba 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
388bc2e6e4 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
5005ae3fb2 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
40be2232a4 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
a51969b8c7 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>
2020-05-12 19:53:45 +00:00
Stefan Metzmacher
a1487067a6 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
456533c9cf 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
f78e98e022 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
fadc7043a7 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
801c06f4c9 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
bf2e546be3 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
ca8c3619f6 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
7daa79908b 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
20ee8b03bb 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>
2020-05-12 19:53:44 +00:00
Jeremy Allison
60f590000d 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
6fa753a1a6 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
70fa4b884d 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
ba68f21286 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>
2020-05-12 19:53:44 +00:00
Stefan Metzmacher
a6eee38ba2 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>
2020-05-12 19:53:43 +00:00
Ralph Boehme
bf04ca5658 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
2020-05-12 19:52:48 +00:00
Ralph Boehme
59f55aa083 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>
2020-05-12 18:15:31 +00:00
Ralph Boehme
3f37008eda 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>
2020-05-12 18:15:31 +00:00
Gary Lockyer
8c17b6f82f Fix clang 9 format-nonliteral warnings
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-08 09:31:31 +00:00
Gary Lockyer
13a2f70a4d Fix clang 9 missing-field-initializer warnings
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-08 09:31:31 +00:00
Jeremy Allison
c6e71fbd68 s3: VFS: Complete the replacement of SMB_VFS_GET_NT_ACL() -> SMB_VFS_GET_NT_ACL_AT().
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): Thu May  7 21:04:59 UTC 2020 on sn-devel-184
2020-05-07 21:04:59 +00:00
Jeremy Allison
7acbef462b s3: VFS: full_audit. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:38 +00:00
Jeremy Allison
8c6628f953 s3: VFS: time_audit. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:38 +00:00
Jeremy Allison
67b778ccfc s3: VFS: unityed_media. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
b744ebbc43 s3: VFS: zfsacl. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
cb7c617dd6 s3: VFS: snapper. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
04805929ef s3: VFS: shadow_copy2. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
e158d42c2c s3: VFS: nfs4acl_xattr. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
9507c623f9 s3: VFS: media_harmony. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
4f44294c04 s3: VFS: gpfs. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
f2f6846951 s3: VFS: glusterfs. Remove NULL definition of get_nt_acl_fn().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
5e361140c3 s3: VFS: ceph_snapshots. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00