In order to move a file across two file systems like: ext4 and tmpfs, the 'vfs objects = crossrename' is added into smb.conf [global] section. Client is windows server 2022. Server is Ubuntu 22.04.4 + samba-4.20.5, my smb.conf: ``` [global] workgroup = U2204 [samba] path = /home/jones/samba browsable = yes guest ok = yes read only = no create mask = 0755 vfs objects = crossrename ``` windows server 2022 connected to samba server, through windows file explorer drag-n-drop operation, to move the 'file.txt' from source folder (resident in ext4) to destination folder (resident in tmpfs). This is what it looks like from server's terminal: ``` $ df -PTh /home/jones/samba/file.txt /home/jones/samba/dst_tmpfs/ Filesystem Type Size Used Avail Use% Mounted on /dev/vda3 ext4 49G 25G 21G 55% / tmpfs tmpfs 2.0G 0 2.0G 0% /home/jones/samba/dst_tmpfs ``` 1st issue comes, windows server 2022 got an error prompted said: ``` Item Not Found Could not find this item This is no longer located in \\192.168.252.181\samba. Verify the item's location and try again. ``` strace gives a clue: samba try to remove 'file.txt' in the dst folder but actually it is not existed yet, and got an errno = ENOENT, ``` renameat(32, "file.txt", 31, "file.txt") = -1 EXDEV (Invalid cross-device link) unlinkat(31, "file.txt", 0) = -1 ENOENT (No such file or directory) ``` Commit 5c18f074be92 ("s3: VFS: crossrename. Use real dirfsp for SMB_VFS_RENAMEAT()") seems unintentionally removed errno ENOENT checking, so add it back could address 1st issue. Then 2nd issue comes, windows server 2022 got an error prompted said: ``` An unexpected error is keeping you from moving the file... Error 0x8007003B: An unexpected network error occured. ``` log.smbd said it is segfault: ``` BACKTRACE: 43 stack frames: #0 /usr/local/samba/lib/private/libgenrand-private-samba.so(log_stack_trace+0x32) [0x7edbd7fbdd9d] #1 /usr/local/samba/lib/private/libgenrand-private-samba.so(smb_panic_log+0x213) [0x7edbd7fbdd1a] #2 /usr/local/samba/lib/private/libgenrand-private-samba.so(smb_panic+0x1c) [0x7edbd7fbdd39] #3 /usr/local/samba/lib/private/libgenrand-private-samba.so(+0x27bd) [0x7edbd7fbd7bd] #4 /usr/local/samba/lib/private/libgenrand-private-samba.so(+0x27d6) [0x7edbd7fbd7d6] #5 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7edbd7c42520] #6 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(fdos_mode+0xb8) [0x7edbd829c077] #7 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(copy_internals+0xa4) [0x7edbd827c380] #8 /usr/local/samba/lib/vfs/crossrename.so(+0x15a8) [0x7edbd34be5a8] #9 /usr/local/samba/lib/vfs/crossrename.so(+0x16f6) [0x7edbd34be6f6] #10 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smb_vfs_call_renameat+0x117) [0x7edbd82bedf3] #11 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(rename_internals_fsp+0x1072) [0x7edbd82829ad] #12 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0x96b23) [0x7edbd8296b23] #13 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_do_setfilepathinfo+0x34f) [0x7edbd8298728] #14 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0x11f413) [0x7edbd831f413] #15 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_smb2_request_process_setinfo+0x511) [0x7edbd831e1f7] #16 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_smb2_request_dispatch+0x18dc) [0x7edbd82f37b9] #17 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf87b6) [0x7edbd82f87b6] #18 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf8bc3) [0x7edbd82f8bc3] #19 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf8c93) [0x7edbd82f8c93] #20 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_invoke_fd_handler+0x125) [0x7edbd81dd3df] #21 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x162f5) [0x7edbd81ea2f5] #22 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x16a92) [0x7edbd81eaa92] #23 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11dfa) [0x7edbd81e5dfa] #24 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_once+0x126) [0x7edbd81dbbd8] #25 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_loop_wait+0x29) [0x7edbd81dbf60] #26 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11ea3) [0x7edbd81e5ea3] #27 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_wait+0x2f) [0x7edbd81dc007] #28 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_process+0xd9e) [0x7edbd82d8e66] #29 smbd: client [192.168.7.67](+0xa2bc) [0x5b32f4f2a2bc] #30 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_invoke_fd_handler+0x125) [0x7edbd81dd3df] #31 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x162f5) [0x7edbd81ea2f5] #32 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x16a92) [0x7edbd81eaa92] #33 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11dfa) [0x7edbd81e5dfa] #34 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_once+0x126) [0x7edbd81dbbd8] #35 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_loop_wait+0x29) [0x7edbd81dbf60] #36 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11ea3) [0x7edbd81e5ea3] #37 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_wait+0x2f) [0x7edbd81dc007] #38 smbd: client [192.168.7.67](+0xb06c) [0x5b32f4f2b06c] #39 smbd: client [192.168.7.67](main+0x1986) [0x5b32f4f2d374] #40 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7edbd7c29d90] #41 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7edbd7c29e40] #42 smbd: client [192.168.7.67](_start+0x25) [0x5b32f4f26be5] ``` gdb gives a clue: dereference null pointer, ``` Program received signal SIGSEGV, Segmentation fault. 0x00007edbd829c077 in fdos_mode (fsp=0x0) at ../../source3/smbd/dosmode.c:691 691 if (fsp->fake_file_handle != NULL) { (gdb) bt #0 0x00007edbd829c077 in fdos_mode (fsp=0x0) at ../../source3/smbd/dosmode.c:691 #1 0x00007edbd827c380 in copy_internals (ctx=0x5b32f5e88990, conn=0x5b32f5e3b080, req=0x0, src_dirfsp=0x5b32f5e95be0, smb_fname_src=0x5b32f5e86520, dst_dirfsp=0x5b32f5e77320, smb_fname_dst=0x5b32f5e79640, attrs=6) at ../../source3/smbd/smb2_nttrans.c:298 #2 0x00007edbd34be5a8 in copy_reg (handle=0x5b32f5e60d80, srcfsp=0x5b32f5e95be0, source=0x5b32f5e76e60, dstfsp=0x5b32f5e77320, dest=0x5b32f5e73600) at ../../source3/modules/vfs_crossrename.c:115 #3 0x00007edbd34be6f6 in crossrename_renameat (handle=0x5b32f5e60d80, srcfsp=0x5b32f5e95be0, smb_fname_src=0x5b32f5e76e60, dstfsp=0x5b32f5e77320, smb_fname_dst=0x5b32f5e73600) at ../../source3/modules/vfs_crossrename.c:166 #4 0x00007edbd82bedf3 in smb_vfs_call_renameat (handle=0x5b32f5e60d80, srcfsp=0x5b32f5e95be0, smb_fname_src=0x5b32f5e76e60, dstfsp=0x5b32f5e77320, smb_fname_dst=0x5b32f5e73600) at ../../source3/smbd/vfs.c:1725 #5 0x00007edbd82829ad in rename_internals_fsp (conn=0x5b32f5e3b080, fsp=0x5b32f5e5c580, smb_fname_dst_in=0x5b32f5e89490, dst_original_lcomp=0x5b32f5e89640 "file.txt", attrs=6, replace_if_exists=false) at ../../source3/smbd/smb2_reply.c:1752 #6 0x00007edbd8296b23 in smb2_file_rename_information (conn=0x5b32f5e3b080, req=0x5b32f5e756f0, pdata=0x5b32f5e69cb0 "", total_data=56, fsp=0x5b32f5e5c580, smb_fname_src=0x5b32f5e7a430) at ../../source3/smbd/smb2_trans2.c:4400 #7 0x00007edbd8298728 in smbd_do_setfilepathinfo (conn=0x5b32f5e3b080, req=0x5b32f5e756f0, mem_ctx=0x5b32f5e755a0, info_level=65290, fsp=0x5b32f5e5c580, smb_fname=0x5b32f5e7a430, ppdata=0x7ffe7957c230, total_data=56, ret_data_size=0x7ffe7957c218) at ../../source3/smbd/smb2_trans2.c:5197 #8 0x00007edbd831f413 in smbd_smb2_setinfo_send (mem_ctx=0x5b32f5e74f80, ev=0x5b32f5e4a540, smb2req=0x5b32f5e74f80, fsp=0x5b32f5e5c580, in_info_type=1 '\001', in_file_info_class=10 '\n', in_input_buffer=..., in_additional_information=0) at ../../source3/smbd/smb2_setinfo.c:513 #9 0x00007edbd831e1f7 in smbd_smb2_request_process_setinfo (req=0x5b32f5e74f80) at ../../source3/smbd/smb2_setinfo.c:112 #10 0x00007edbd82f37b9 in smbd_smb2_request_dispatch (req=0x5b32f5e74f80) at ../../source3/smbd/smb2_server.c:3580 #11 0x00007edbd82f87b6 in smbd_smb2_advance_incoming (xconn=0x5b32f5e61440, n=152) at ../../source3/smbd/smb2_server.c:5110 #12 0x00007edbd82f8bc3 in smbd_smb2_io_handler (xconn=0x5b32f5e61440, fde_flags=1) at ../../source3/smbd/smb2_server.c:5225 #13 0x00007edbd82f8c93 in smbd_smb2_connection_handler (ev=0x5b32f5e4a540, fde=0x5b32f5e5fef0, flags=1, private_data=0x5b32f5e61440) at ../../source3/smbd/smb2_server.c:5255 #14 0x00007edbd81dd3df in tevent_common_invoke_fd_handler (fde=0x5b32f5e5fef0, flags=1, removed=0x0) at ../../lib/tevent/tevent_fd.c:174 #15 0x00007edbd81ea2f5 in epoll_event_loop (epoll_ev=0x5b32f5e5e440, tvalp=0x7ffe7957c790) at ../../lib/tevent/tevent_epoll.c:696 #16 0x00007edbd81eaa92 in epoll_event_loop_once (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent_epoll.c:926 #17 0x00007edbd81e5dfa in std_event_loop_once (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent_standard.c:110 #18 0x00007edbd81dbbd8 in _tevent_loop_once (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent.c:820 #19 0x00007edbd81dbf60 in tevent_common_loop_wait (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent.c:949 #20 0x00007edbd81e5ea3 in std_event_loop_wait (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent_standard.c:141 #21 0x00007edbd81dc007 in _tevent_loop_wait (ev=0x5b32f5e4a540, location=0x7edbd83e1dd0 "../../source3/smbd/smb2_process.c:2064") at ../../lib/tevent/tevent.c:968 #22 0x00007edbd82d8e66 in smbd_process (ev_ctx=0x5b32f5e4a540, msg_ctx=0x5b32f5e350a0, sock_fd=34, interactive=false) at ../../source3/smbd/smb2_process.c:2064 #23 0x00005b32f4f2a2bc in smbd_accept_connection (ev=0x5b32f5e4a540, fde=0x5b32f5e5e4d0, flags=1, private_data=0x5b32f5e5e440) at ../../source3/smbd/server.c:1031 #24 0x00007edbd81dd3df in tevent_common_invoke_fd_handler (fde=0x5b32f5e5e4d0, flags=1, removed=0x0) at ../../lib/tevent/tevent_fd.c:174 #25 0x00007edbd81ea2f5 in epoll_event_loop (epoll_ev=0x5b32f5e4a770, tvalp=0x7ffe7957cb80) at ../../lib/tevent/tevent_epoll.c:696 #26 0x00007edbd81eaa92 in epoll_event_loop_once (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_epoll.c:926 #27 0x00007edbd81e5dfa in std_event_loop_once (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_standard.c:110 #28 0x00007edbd81dbbd8 in _tevent_loop_once (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:820 #29 0x00007edbd81dbf60 in tevent_common_loop_wait (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:949 #30 0x00007edbd81e5ea3 in std_event_loop_wait (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_standard.c:141 #31 0x00007edbd81dc007 in _tevent_loop_wait (ev=0x5b32f5e4a540, location=0x5b32f4f2f7d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:968 #32 0x00005b32f4f2b06c in smbd_parent_loop (ev_ctx=0x5b32f5e4a540, parent=0x5b32f5e351f0) at ../../source3/smbd/server.c:1373 #33 0x00005b32f4f2d374 in main (argc=1, argv=0x7ffe7957d158) at ../../source3/smbd/server.c:2131 (gdb) f 1 #1 0x00007edbd827c380 in copy_internals (ctx=0x5b32f5e88990, conn=0x5b32f5e3b080, req=0x0, src_dirfsp=0x5b32f5e95be0, smb_fname_src=0x5b32f5e86520, dst_dirfsp=0x5b32f5e77320, smb_fname_dst=0x5b32f5e79640, attrs=6) at ../../source3/smbd/smb2_nttrans.c:298 298 fattr = fdos_mode(smb_fname_src->fsp); (gdb) l 293 status = NT_STATUS_OBJECT_NAME_NOT_FOUND; 294 goto out; 295 } 296 297 /* Ensure attributes match. */ 298 fattr = fdos_mode(smb_fname_src->fsp); 299 if ((fattr & ~attrs) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { 300 status = NT_STATUS_NO_SUCH_FILE; 301 goto out; 302 } ``` smb_fname_src->fsp is 0x0 so segfault is triggered. Guess we should prepare smb_fname_src->fsp first by synthetic_pathref(), a bit similar behavior as smb_fname_dst->fsp is prepared in copy_internals(). Commit 46372997a09c ("smbd: Remove a NULL check that became obsolete") seems removed fsp checking in fdos_mode(), not sure whether we should add this checking back. Then 3rd issue comes, windows server 2022 got the same error as 2nd issue. log.smbd said it is segfault by assertion failure: ``` PANIC (pid 3254204): assert failed: share_mode_lock_key_refcount == 0 in 4.20.5 BACKTRACE: 45 stack frames: #0 /usr/local/samba/lib/private/libgenrand-private-samba.so(log_stack_trace+0x32) [0x7023ff621d9d] #1 /usr/local/samba/lib/private/libgenrand-private-samba.so(smb_panic_log+0x213) [0x7023ff621d1a] #2 /usr/local/samba/lib/private/libgenrand-private-samba.so(smb_panic+0x1c) [0x7023ff621d39] #3 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(_share_mode_entry_prepare_lock+0x17e) [0x7023ffa54fa4] #4 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xab46c) [0x7023ffaab46c] #5 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xb073d) [0x7023ffab073d] #6 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(create_file_default+0x4fe) [0x7023ffab13d3] #7 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0x61609) [0x7023ffa61609] #8 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smb_vfs_call_create_file+0x14c) [0x7023ffabdf0f] #9 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(copy_internals+0x1c8) [0x7023ffa7c4a4] #10 /usr/local/samba/lib/vfs/crossrename.so(+0x1688) [0x7023fabdf688] #11 /usr/local/samba/lib/vfs/crossrename.so(+0x181b) [0x7023fabdf81b] #12 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smb_vfs_call_renameat+0x117) [0x7023ffabedf3] #13 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(rename_internals_fsp+0x1072) [0x7023ffa829ad] #14 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0x96b23) [0x7023ffa96b23] #15 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_do_setfilepathinfo+0x34f) [0x7023ffa98728] #16 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0x11f413) [0x7023ffb1f413] #17 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_smb2_request_process_setinfo+0x511) [0x7023ffb1e1f7] #18 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_smb2_request_dispatch+0x18dc) [0x7023ffaf37b9] #19 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf87b6) [0x7023ffaf87b6] #20 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf8bc3) [0x7023ffaf8bc3] #21 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(+0xf8c93) [0x7023ffaf8c93] #22 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_invoke_fd_handler+0x125) [0x7023ff8463df] #23 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x162f5) [0x7023ff8532f5] #24 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x16a92) [0x7023ff853a92] #25 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11dfa) [0x7023ff84edfa] #26 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_once+0x126) [0x7023ff844bd8] #27 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_loop_wait+0x29) [0x7023ff844f60] #28 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11ea3) [0x7023ff84eea3] #29 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_wait+0x2f) [0x7023ff845007] #30 /usr/local/samba/lib/private/libsmbd-base-private-samba.so(smbd_process+0xd9e) [0x7023ffad8e66] #31 smbd: client [192.168.7.67](+0xa2bc) [0x59a52f67b2bc] #32 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_invoke_fd_handler+0x125) [0x7023ff8463df] #33 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x162f5) [0x7023ff8532f5] #34 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x16a92) [0x7023ff853a92] #35 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11dfa) [0x7023ff84edfa] #36 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_once+0x126) [0x7023ff844bd8] #37 /usr/local/samba/lib/private/libtevent-private-samba.so(tevent_common_loop_wait+0x29) [0x7023ff844f60] #38 /usr/local/samba/lib/private/libtevent-private-samba.so(+0x11ea3) [0x7023ff84eea3] #39 /usr/local/samba/lib/private/libtevent-private-samba.so(_tevent_loop_wait+0x2f) [0x7023ff845007] #40 smbd: client [192.168.7.67](+0xb06c) [0x59a52f67c06c] #41 smbd: client [192.168.7.67](main+0x1986) [0x59a52f67e374] #42 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7023ff229d90] #43 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7023ff229e40] #44 smbd: client [192.168.7.67](_start+0x25) [0x59a52f677be5] ``` So far this is how far and where i could reach, im not quite sure how to continue 3rd issue with assertion failure, perhaps im doing this in the wrong direction. Any suggestions are appreciated :) patch for 1st issue and 2nd issue will follow.
> patch for 1st issue and 2nd issue will follow. https://gitlab.com/samba-team/devel/samba/-/commits/jones2019_fix_vfs_crossrename
> patch for 1st issue and 2nd issue will follow. mr: https://gitlab.com/samba-team/samba/-/merge_requests/3816 And 3rd issue segfault is not addresses yet, any suggestions in bugzilla here or gitlab mr are appreciated :)
ohh okay found a series of discussion about two years ago: https://lists.samba.org/archive/samba-technical/2022-October/137688.html