Bug 16289 - SMB copy fails with ACCESS_DENIED for NTFS files carrying EA DOSATTRIB="0x0"
Summary: SMB copy fails with ACCESS_DENIED for NTFS files carrying EA DOSATTRIB="0x0"
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.22.11
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-27 08:20 UTC by markus.schmal@gmail.com
Modified: 2026-10-27 08:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description markus.schmal@gmail.com 2026-10-27 08:20:07 UTC
Samba SMB copy fails with ACCESS_DENIED for NTFS files carrying EA DOSATTRIB="0x0"

Summary
=======

I found a reproducible interoperability issue when copying certain files from a Windows 7 SMB server to a modern Samba server via a Windows 11 client.

The affected source files are ordinary NTFS files which carry an NTFS Extended Attribute named:

    DOSATTRIB

with the 3-byte ASCII value:

    0x0

When such a file is copied directly from the Windows 7 SMB share to the Samba share, Windows reports "Access denied".

The destination file is created successfully on Samba, but remains zero bytes. Samba repeatedly truncates the file and updates its user.DOSATTRIB xattr, while the actual file data is never written.

The important finding is that removing only the NTFS EA DOSATTRIB from the source file fixes the problem immediately. No file data, filename, ACL, DOS attribute, or timestamps need to be changed.

This appears to be a conflict between an incoming SMB/NTFS EA named DOSATTRIB and Samba's own special handling of user.DOSATTRIB.


Environment
===========

Samba destination server
------------------------

    OS: Debian 13.7 "trixie"
    Samba: 4.22.11-Debian
    Kernel: 6.12.107+deb13-amd64
    Filesystem: ext4
    Architecture: x86_64

Samba is running as a standalone server.

Relevant share:

    [benutzer]
        path = /srv/data/shares/benutzer
        read only = no
        valid users = @sambausers
        force group = sambausers
        create mask = 0660
        directory mask = 2770

No acl_xattr VFS module is used.

store dos attributes is active/default.

The issue occurs both with the default:

    hide dot files = yes

and with:

    hide dot files = no

so hide dot files is not the cause.


Source server
-------------

    Windows 7
    NTFS
    Windows SMB server

Example source path:

    D:\shares\benutzer\markus\EigeneDateien\.windows-serial

exported as:

    \\SONNE\benutzer\markus\EigeneDateien\.windows-serial


Client performing the copy
--------------------------

    Windows 11

The copy is performed directly between the two UNC paths:

    \\SONNE\...
        ->
    \\192.168.200.200\...

The problem occurs with Windows Explorer, PowerShell Copy-Item, and cmd.exe copy.


Original symptom
================

A large Windows Explorer copy from the Windows 7 server to Samba reached 99% and appeared to hang indefinitely.

The last file shown was:

    .windows-serial

Source file:

    Length:          9 bytes
    Attributes:      Normal
    Contents:        55000000

The destination file on Samba existed, but was:

    Length:          0 bytes

Explorer eventually displayed:

    Destination Folder Access Denied
    You need permission to perform this action.

Linux permissions on the destination were correct.

The same Windows user could create, modify, and delete normal files in the same Samba directory.


Important control tests
=======================

1. Normal writes to Samba work
------------------------------

This succeeds:

    "test" | Set-Content "\\192.168.200.200\benutzer\markus\Kopiertest2\schreibtest.txt"


2. Local Windows file -> Samba works
------------------------------------

This succeeds:

    Copy-Item "$env:TEMP\copyitem-test.txt" `
              "\\192.168.200.200\benutzer\markus\Kopiertest2\copyitem-local.txt"


3. Windows 7 SMB -> local Windows works
---------------------------------------

This succeeds:

    Copy-Item "\\SONNE\benutzer\markus\EigeneDateien\windows-serial-test.txt" `
              "$env:TEMP\serial-von-sonne.txt"


4. Reading source data and explicitly writing destination data works
--------------------------------------------------------------------

This succeeds:

    $src="\\SONNE\benutzer\markus\EigeneDateien\.windows-serial"
    $dst="\\192.168.200.200\benutzer\markus\Kopiertest2\serial-bytes.txt"

    [System.IO.File]::WriteAllBytes(
        $dst,
        [System.IO.File]::ReadAllBytes($src)
    )

So the 9 bytes themselves are readable and writable.


5. Direct SMB -> SMB copy fails
-------------------------------

This fails:

    Copy-Item "\\SONNE\benutzer\markus\EigeneDateien\.windows-serial" `
              "\\192.168.200.200\benutzer\markus\Kopiertest2\serial-test.txt"

with:

    UnauthorizedAccessException
    Access to the path ... was denied.

cmd.exe copy /b fails in the same way:

    Access denied
    0 file(s) copied.

The Samba destination file is nevertheless created as a zero-byte file.


It is not related to filename or content
========================================

A newly created file on the Windows 7 SMB server containing the exact same bytes:

    55000000

copies successfully.

A new file named .windows-serial also copies successfully.

Changing the Archive attribute does not fix the failing file.

Matching the old timestamps on a newly created file does not reproduce the problem.

Deleting the problematic file and recreating it from its 9 data bytes fixes it.

Therefore the following were excluded as the cause:

    filename
    leading dot
    file contents
    file size
    Archive attribute
    Hidden attribute
    CreationTime
    LastWriteTime
    LastAccessTime
    NTFS ACL
    reparse point
    NTFS object ID
    sparse/allocation state


strace observation on Samba
===========================

During the failing copy, the Samba client process loops on the destination file.

Typical sequence:

    openat(... ".windows-serial" ...) = ...
    openat(... O_RDWR|O_CREAT|O_NONBLOCK ...) = ...
    ftruncate(..., 0) = 0
    fsetxattr(..., "user.DOSATTRIB", ..., 24, 0) = 0

This sequence repeats extremely rapidly.

A focused trace showed repeated:

    ftruncate(destination, 0) = 0
    fsetxattr(destination, "user.DOSATTRIB", ..., 24, 0) = 0

but no write() or pwrite() carrying the 9 bytes of file data.

Thus Samba successfully creates and manipulates the destination inode, but the copy never progresses to writing the actual file data.

There is no underlying ext4 EACCES or other failed Linux filesystem syscall corresponding to the Windows "Access denied" error.


Discovery of the source NTFS Extended Attribute
===============================================

Using NtQueryEaFile() on the problematic Windows 7 NTFS file revealed:

    DOSATTRIB
    Flags=0x00
    Length=3
    Value=30-78-30

Hex:

    30 78 30

ASCII:

    0x0

For example:

    === D:\shares\benutzer\markus\EigeneDateien\.windows-serial.bak ===
    NtQueryEaFile: 0x00000000
    DOSATTRIB  Flags=0x00  Length=3  Value=30-78-30

A newly recreated, working version of the same file reports:

    NtQueryEaFile: 0xC0000052

i.e. no EAs on the file.


Causal test
===========

This is the strongest evidence.

A source file that reproducibly failed to copy was left completely unchanged except for removing the EA named:

    DOSATTRIB

using NtSetEaFile() with zero EA value length.

Before removing the EA:

    Windows 7 SMB -> Samba
    Access denied

After removing only DOSATTRIB:

    Windows 7 SMB -> Samba
    success

No other property of the source file was changed.

The test was repeated with another genuine source file:

    D:\shares\.windows-serial

Before:

    DOSATTRIB = "0x0"
    direct SMB copy -> Access denied

After deleting only that EA:

    direct SMB copy -> success

This makes the DOSATTRIB EA the direct trigger with very high confidence.


Additional population scan
==========================

I scanned:

    D:\shares

on the Windows 7 server for NTFS files containing an EA named DOSATTRIB.

Files scanned:

    495,341

Files containing DOSATTRIB:

    3

They were:

    D:\shares\.windows-serial
    D:\shares\benutzer\markus\EigeneDateien\.windows-serial-test
    D:\shares\benutzer\markus\EigeneDateien\WS-Test\.windows-serial

All carried:

    DOSATTRIB = "0x0"

The latter two were test copies derived from the original problematic file.

The genuine file:

    D:\shares\.windows-serial

also reproduced the Samba copy failure and became immediately copyable after deleting only its DOSATTRIB EA.

This therefore does not appear to be random filesystem corruption.


Possible Wine origin
====================

The .windows-serial files appear to originate from Wine. Wine uses .windows-serial to represent a virtual drive serial number.

The value:

    55000000

is consistent with such a drive serial value.

Wine has also historically used Samba-compatible DOS attribute metadata.

It therefore seems plausible that these files were created or modified by Wine and that the NTFS EA:

    DOSATTRIB = "0x0"

is historical Wine-generated metadata.

However, the exact software/version which originally created the EA has not been established and is not required to reproduce the Samba failure.


Expected behaviour
==================

Samba should accept the incoming file and its data.

If the incoming EA named DOSATTRIB is unsupported, malformed, reserved, or conflicts with Samba's internal user.DOSATTRIB, Samba should preferably:

1. ignore the incoming EA, or
2. reject/skip that EA only,

rather than causing the whole file copy to fail with:

    ACCESS_DENIED

after creating a zero-byte destination file.


Actual behaviour
================

Direct copy from Windows SMB source to Samba:

    source NTFS file contains EA DOSATTRIB="0x0"
            |
            v
    Windows creates destination on Samba
            |
            v
    destination remains 0 bytes
            |
            v
    Samba repeatedly truncates file and sets user.DOSATTRIB
            |
            v
    actual file data is never written
            |
            v
    Windows reports ACCESS_DENIED

Removing only the source EA:

    DOSATTRIB

makes the exact same copy succeed.


Why I suspect Samba's DOS attribute handling
============================================

Samba stores DOS metadata in:

    user.DOSATTRIB

on the Unix filesystem.

The incoming Windows/NTFS source file itself contains an EA whose name is:

    DOSATTRIB

The failure occurs precisely when this EA exists.

The Samba trace simultaneously shows intensive handling of:

    user.DOSATTRIB

on the destination.

This suggests an interoperability problem between an incoming SMB EA named DOSATTRIB and Samba's reserved/internal DOS-attribute xattr handling.


Reproduction requirements
=========================

A minimal reproduction appears to require:

1. An NTFS file on a Windows SMB server.
2. Add an NTFS EA:
       Name:  DOSATTRIB
       Value: ASCII "0x0"
3. Access the file from a Windows client.
4. Copy it directly from the Windows SMB share to a Samba share.
5. Observe:
       ACCESS_DENIED
   and a zero-byte destination file.
6. Remove only the DOSATTRIB EA from the source.
7. Repeat the copy.
8. Observe successful copy.

I can provide the small PowerShell/C# NtQueryEaFile / NtSetEaFile helper used to inspect and remove the EA if useful.


Workaround
==========

Removing the source NTFS EA:

    DOSATTRIB

fixes the affected files.

Recreating the source file from its data also fixes it because the problematic EA is not recreated.

Neither changing Samba's:

    hide dot files

setting nor modifying the ordinary DOS attributes is required.


Questions for Samba developers
==============================

1. Is an incoming SMB EA named DOSATTRIB intentionally treated specially by Samba?
2. Could Samba be interpreting the incoming NTFS EA DOSATTRIB="0x0" as its own DOS attribute metadata?
3. Should malformed/legacy DOSATTRIB metadata be ignored rather than returning ACCESS_DENIED for the whole file operation?
4. Is there an existing test in the Samba torture suite covering a Windows SMB source file containing a DOSATTRIB EA copied to a Samba destination?
5. Would a packet capture and/or Samba debug log at a specific debug level help identify which SMB request returns ACCESS_DENIED?


Severity
========

The issue appears rare, but its failure mode is problematic for migrations:

- bulk copy reaches approximately 99%
- destination file already exists as zero bytes
- Explorer may repeatedly retry the same file
- error is reported as a misleading permissions problem
- ordinary Linux permissions are correct
- the actual trigger is hidden NTFS metadata

For migration or backup scenarios involving old Wine-generated files, this can therefore be difficult to diagnose.