Skip to contentSkip to conversation

SMB3 POSIX and deleting files with FILE_ATTRIBUTE_READONLY

DISCUSSION Ralph Boehme 4 participants 12 messages Apr 9, 2025 – Apr 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi folks,

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

Checking WRITE_ATTRIBUTES first means we would correctly honor permissions and the client could have removed FILE_ATTRIBUTE_READONLY anyway to then remove the file.

Windows has some new bits FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE to handle this locally (!) and it seems to be doing it without checking WRITE_ATTRIBUTES on the server.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/2e860264-018a-47b3-8555-565a13b35a45>

Thoughts?

Thanks!
-slow

#1 lore raw
Quoted 10 lines · Ralph Boehme

Hi folks,

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

I agree that to delete a file with READ_ONLY set should by default require WRITE_ATTRIBUTES (and delete) permission (better to be safe
in restricting a potential dangerous operation).

But this is a good question ...

Quoted 11 lines

Checking WRITE_ATTRIBUTES first means we would correctly honor permissions and the client could have removed FILE_ATTRIBUTE_READONLY anyway to then remove the file.

Windows has some new bits FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE to handle this locally (!) and it seems to be doing it without checking WRITE_ATTRIBUTES on the server.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/2e860264-018a-47b3-8555-565a13b35a45>

Thoughts?

Signature · 3 lines
Thanks,

Steve
#2 lore raw
Quoted 11 lines · Steve French
Quoted 7 lines · Ralph Boehme

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

I agree that to delete a file with READ_ONLY set should by default require WRITE_ATTRIBUTES (and delete)

delete will be checked the usual way, so nothing special there.

Quoted 2 lines

permission (better to be safe
in restricting a potential dangerous operation).

yes, that was my thought as well.

Quoted 2 lines

But this is a good question ...

That's why I brought it up :)))

Thanks!
-slow

reviewer
#3 lore raw
Quoted 5 lines · Ralph Boehme
Quoted 4 lines · Steve French
Quoted 3 lines · Ralph Boehme

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

I agree that to delete a file with READ_ONLY set should by default require WRITE_ATTRIBUTES (and delete)

Since when does Posix require this?? All that's required is that the /directory/ is writable. The rm command will prompt if the /file/ is not writable, but the unlink(2) itself is not denied.

https://pubs.opengroup.org/onlinepubs/9799919799/

Tom.

Quoted 17 lines

delete will be checked the usual way, so nothing special there.

Quoted 2 lines

permission (better to be safe
in restricting a potential dangerous operation).

yes, that was my thought as well.

Quoted 2 lines

But this is a good question ...

That's why I brought it up :)))

Thanks!
-slow

#4 lore raw
Quoted 11 lines · Tom Talpey
Quoted 10 lines · Ralph Boehme
Quoted 9 lines · Steve French
Quoted 7 lines · Ralph Boehme

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

I agree that to delete a file with READ_ONLY set should by default require WRITE_ATTRIBUTES (and delete)

Since when does Posix require this??

Obviously it doesn't.

Let me try to ask it differently: do we want to relax Windows security model on a POSIX handle for this operation, even if we can build sane semantics into the protocol that doesn't require this?

#5 lore raw
Quoted 18 lines · Ralph Boehme
Quoted 16 lines · Tom Talpey
Quoted 14 lines · Ralph Boehme
Quoted 13 lines · Steve French
Quoted 8 lines · Ralph Boehme

what should be the behavior with SMB3 POSIX when a POSIX client tries to
delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

I agree that to delete a file with READ_ONLY set should by default require
WRITE_ATTRIBUTES (and delete)

Quoted 7 lines
Quoted 1 line

Since when does Posix require this??

Obviously it doesn't.

Let me try to ask it differently: do we want to relax Windows security model on a POSIX handle for this operation, even if we can build sane semantics into the protocol that doesn't require this?

If in doubt, better to be "more secure" unless case is very strong to relax this check.

Signature · 3 lines
Thanks,

Steve
#6 lore raw
In reply to Ralph Boehme
Quoted 6 lines · Ralph Boehme

Hi folks,

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

Quoted 7 lines

Checking WRITE_ATTRIBUTES first means we would correctly honor permissions and the client could have removed FILE_ATTRIBUTE_READONLY anyway to then remove the file.

Windows has some new bits FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE to handle this locally (!) and it seems to be doing it without checking WRITE_ATTRIBUTES on the server.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/2e860264-018a-47b3-8555-565a13b35a45>

Thoughts?

Does Windows ever send FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE over the wire ? What happens if smbclient does ?

#8 lore raw
Quoted 7 lines · Ralph Boehme
Quoted 2 lines · Jeremy Allison

Does Windows ever send FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE over the wire ?

No, it's local only, cf MS-FSCC and the thread "SMB2 DELETE vs UNLINK" on the Linux cifs mailing list.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/4718fc40-e539-4014-8e33-b675af74e3e1>

OK, but does the Windows SMB3 server filter it out ?

Can a Linux client send it over the wire and does
it have the desired effect ?

#9 lore raw
Quoted 10 lines · Jeremy Allison
Quoted 7 lines · Ralph Boehme
Quoted 2 lines · Jeremy Allison

Does Windows ever send FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE over the wire ?

No, it's local only, cf MS-FSCC and the thread "SMB2 DELETE vs UNLINK" on the Linux cifs mailing list.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms- fscc/4718fc40-e539-4014-8e33-b675af74e3e1>

OK, but does the Windows SMB3 server filter it out ?

yes.

Quoted 2 lines

Can a Linux client send it over the wire and does
it have the desired effect ?

no. Cf the thread I mentioned.

Thanks!
-slow

#10 lore raw
In reply to Ralph Boehme

As discussed at SambaXP, what about this?

https://gitlab.com/samba-team/smb3-posix-spec/-/merge_requests/6/diffs

Quoted 16 lines · Ralph Boehme via samba-technical

Hi folks,

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

Checking WRITE_ATTRIBUTES first means we would correctly honor permissions and the client could have removed FILE_ATTRIBUTE_READONLY anyway to then remove the file.

Windows has some new bits FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE to handle this locally (!) and it seems to be doing it without checking WRITE_ATTRIBUTES on the server.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms- fscc/2e860264-018a-47b3-8555-565a13b35a45>

Thoughts?

Thanks!
-slow

#11 lore raw

Looks fine to me

Quoted 32 lines · Ralph Boehme

As discussed at SambaXP, what about this?

https://gitlab.com/samba-team/smb3-posix-spec/-/merge_requests/6/diffs

Quoted 25 lines · Ralph Boehme via samba-technical

Hi folks,

what should be the behavior with SMB3 POSIX when a POSIX client tries to delete a file that has FILE_ATTRIBUTE_READONLY set?

The major question that we must answer is, if this we would want to allow for POSIX clients to ignore this in some way: either completely ignore it on POSIX handles or first check if the handle has requested and been granted WRITE_ATTRIBUTES access.

Checking WRITE_ATTRIBUTES first means we would correctly honor permissions and the client could have removed FILE_ATTRIBUTE_READONLY anyway to then remove the file.

Windows has some new bits FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE to handle this locally (!) and it seems to be doing it without checking WRITE_ATTRIBUTES on the server.

<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-
fscc/2e860264-018a-47b3-8555-565a13b35a45>

Thoughts?

Thanks!
-slow

Signature · 3 lines
Thanks,

Steve