Bug 16288 - mkdir fails with NT_STATUS_INSUFFICIENT_RESOURCES on a FUSE (ntfs-3g) share: directory lease + "vfs mkdir use tmp name" fallback, "Character Conversion Error" storing the share mode / lease record
Summary: mkdir fails with NT_STATUS_INSUFFICIENT_RESOURCES on a FUSE (ntfs-3g) share: ...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.25.0
Hardware: x64 Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-10-22 07:12 UTC by smellybelly
Modified: 2026-10-22 07:13 UTC (History)
0 users

See Also:


Attachments
log of a failing run (24.53 KB, text/plain)
2026-10-22 07:12 UTC, smellybelly
no flags Details
test setup with a generic share (data), user (smbtest) and a README (2.15 KB, application/x-gzip)
2026-10-22 07:13 UTC, smellybelly
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description smellybelly 2026-10-22 07:12:46 UTC
Created attachment 19302 [details]
log of a failing run

Samba versions: 4.24.7 (Debian trixie-backports, 4.24.7+dfsg-1~bpo13+1) and 4.25.0 (Debian testing, 4.25.0+dfsg-1); also seen on 4.22.11 (Debian 13).

Setup: a share with a directory on an ntfs-3g (FUSE) mount, e.g. path = /srv/data with
  ntfs-3g -o rw,windows_names,uid=1000,gid=1000 /dev/sdX1 /srv/data/ntfs
Nothing special in smb.conf: "smb3 directory leases" and "vfs mkdir use tmp name" are at their defaults (auto, which resolves to yes). Client: Windows 11, SMB 3.1.1. The attached rig reproduces it in a Debian container with ntfs-3g mounted from an image file.

Steps: from Windows, copy a small tree of new folders onto the ntfs-3g part of the share:
  C:\src\test\readme.txt
  C:\src\test\dir1\dir2\dir3\dir4\test.txt
  robocopy C:\src \\server\data\ntfs /E

Result: creating the new folders fails with NT_STATUS_INSUFFICIENT_RESOURCES; robocopy reports ERROR 1450 (ERROR_NO_SYSTEM_RESOURCES) for "test", "dir1" and "dir2". The folder exists afterwards; robocopy's retry gets NT_STATUS_OBJECT_NAME_COLLISION and carries on. At the default log level smbd logs, once per failure:
  source3/locking/leases_db.c:150(leases_db_do_locked_fn)
  leases_db_do_locked_fn: ndr_push_struct_blob_failed: Character Conversion Error
At log level 3 (attached) the lines before it are:
  convert_string_handle: Conversion error: Incomplete multibyte sequence
    (on other folders: convert_string_internal: Conversion error: Illegal multibyte sequence)
  ndr_push_charset: ndr_push_error(Character Conversion Error): Bad character conversion at librpc/ndr/ndr_string.c:1065
  leases_db_do_locked_fn: ndr_push_struct_blob_failed: Character Conversion Error
  smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_INSUFFICIENT_RESOURCES] || at source3/smbd/smb2_create.c:393
Every folder name is plain ASCII, so the string being pushed is not the folder's name. In one run at log level 5 the share mode record failed the same way instead (share_mode_data_ltdb_store: ndr_push_share_mode_data failed: Character Conversion Error).

Expected: the folders are created without an error, as on a non-FUSE filesystem.

It is timing-dependent: at the default log level it failed in every run (17 of 17), at log level 3 in 3 of 7, at log level 5 in 2 of 8, at log level 10 in none of 4.

What isolates it (4.24.7, same container, client and tree):
- share on ntfs-3g, defaults: fails
- share on ext4, defaults: works
- ntfs-3g with "vfs mkdir use tmp name = no": works
- ntfs-3g with "smb3 directory leases = no": works
Copying files into folders that already exist always works; only creating a folder fails.

Analysis (from reading source3/smbd/open.c, not from a debugger): mkdir_internal() creates the directory under a temporary name and renames it into place with VFS_RENAME_HOW_NO_REPLACE. FUSE filesystems such as ntfs-3g do not support RENAME_NOREPLACE, so renameat2() returns EINVAL and the fallback runs: mkdirat() the real name, then rename the temporary directory over it. After that path the lease (and share mode) record of the new directory holds a string that is not valid in the unix charset although every name is ASCII, which suggests a pointer to freed or reused memory; that would also explain why more logging makes it rarer. Not confirmed with valgrind or ASan.

Related: bug 15801 (same tmp-name mkdir code on OpenBSD, fixed by mapping "auto" to "no" on that platform only). Linux with a filesystem that lacks RENAME_NOREPLACE still takes the fallback.

Workarounds: "vfs mkdir use tmp name = no" on the affected share, or "smb3 directory leases = no".
Comment 1 smellybelly 2026-10-22 07:13:55 UTC
Created attachment 19303 [details]
test setup with a generic share (data), user (smbtest) and a README