Bug 15841 - Wide link issue in samba 4.22
Summary: Wide link issue in samba 4.22
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.22.0
Hardware: All All
: P5 regression (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-29 19:06 UTC by timo
Modified: 2025-06-03 06:50 UTC (History)
3 users (show)

See Also:


Attachments
preliminary patch (940 bytes, text/plain)
2025-04-01 16:24 UTC, Volker Lendecke
no flags Details
Patch from master (1.77 KB, patch)
2025-04-17 09:23 UTC, Volker Lendecke
vl: review? (jra)
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description timo 2025-03-29 19:06:05 UTC
I'm trying to move a file (using Windows Explorer or via the command prompt):

Photos\Untitled.png -> Photos\Work\Untitled.png

This works when using samba 4.21, but fails with samba 4.22. Hence, this seems to be a regression in 4.22.

The reason seems to be that folder "Photos" is a symlink (wide link). Moving files within that folder doesn't work anymore. Interestingly, reading and copying files within that folder works without any issue. Also, moving files in other locations (folder) where no symlinks (wide links) are used works fine.

I've created a client specific level 10 log file using this guide:
https://wiki.samba.org/index.php/Client_specific_logging

The log files and my samba configuration can be downloaded here:
https://www.van-roermund.nl/temp/samba-link-issue.zip
Comment 1 timo 2025-03-30 11:49:16 UTC
Going through the other bugs once again, I *think* this may actually be a duplicate of #15828:

https://bugzilla.samba.org/show_bug.cgi?id=15828
Comment 2 Jeremy Allison 2025-03-31 05:30:09 UTC
I think vfs_widelinks needs to have an implementation of fstatat() added that removes the AT_SYMLINK_NOFOLLOW flag.

That's the same approach it uses to turn lstat() into stat() to avoid symlinks being seen.

My guess is that will fix this.
Comment 3 timo 2025-03-31 19:18:09 UTC
(In reply to Jeremy Allison from comment #2)

I think that that is what you proposed here?

https://bugzilla.samba.org/show_bug.cgi?id=15828#c2

If so: I've tested this patch, but it is not fixing the issue I have.

In fact, the log shows the exact same behavior as before.
Comment 4 Jeremy Allison 2025-03-31 20:16:51 UTC
Ah well. So goes my quick fix idea :-). I'll need to try and reproduce first then to track down the exact regression.
Comment 5 Volker Lendecke 2025-04-01 16:24:24 UTC
Created attachment 18624 [details]
preliminary patch

Thanks to an idea by Ralph this fixes my reproducer
Comment 6 Jeremy Allison 2025-04-01 17:16:04 UTC
Do we also need the fstatat fix ?
Comment 7 timo 2025-04-01 19:09:22 UTC
(In reply to Volker Lendecke from comment #5)

Thanks!

I've just tried it and it seems to resolve the issue for me. I can now again move and delete files in a "wide link" location.

I will keep using this patched version for a bit to see if everything works as expected.
Comment 8 timo 2025-04-01 19:10:54 UTC
(In reply to Jeremy Allison from comment #6)

In the version I'm using now, I only applied the patch provided by Volker above. I did not apply the patch you provided yesterday (https://bugzilla.samba.org/show_bug.cgi?id=15828#c2).
Comment 9 timo 2025-04-02 19:18:06 UTC
FYI -- it seems that O_PATH may not always be available (defined).

The maintainer for the samba package in Debian has uploaded a new version including this patch; and I just noticed that the build fails on some platforms:

https://buildd.debian.org/status/package.php?p=samba&suite=sid

The raw build log for the hurd-amd64 architecture:

https://buildd.debian.org/status/fetch.php?pkg=samba&arch=hurd-amd64&ver=2%3A4.22.0%2Bdfsg-3&stamp=1743600500&raw=0

Relevant lines from this log:

../../source3/modules/vfs_widelinks.c: In function ‘widelinks_openat’:
../../source3/modules/vfs_widelinks.c:362:57: error: ‘O_PATH’ undeclared (first use in this function)
  362 |                 how.flags = (how.flags & ~(O_NOFOLLOW | O_PATH));
      |                                                         ^~~~~~

Cheers,

Timo
Comment 11 Samba QA Contact 2025-04-16 20:57:14 UTC
This bug was referenced in samba master:

9e637a28bd0b5adc2d90df9ca4a1c864a648b0f4
Comment 12 Volker Lendecke 2025-04-17 09:23:46 UTC
Created attachment 18633 [details]
Patch from master
Comment 13 Jule Anger 2025-04-17 13:20:53 UTC
Pushed to autobuild-v4-{22,21}-test.
Comment 14 Samba QA Contact 2025-04-17 15:01:13 UTC
This bug was referenced in samba v4-21-test:

1da707f1093abdcd0ee63c976a03fa4fff1f6423
Comment 15 Samba QA Contact 2025-04-17 17:04:14 UTC
This bug was referenced in samba v4-22-test:

dadfa06573f3958f88b235c4d2e5ecedab78f6c5
Comment 16 Samba QA Contact 2025-04-17 17:16:39 UTC
This bug was referenced in samba v4-22-stable (Release samba-4.22.1):

dadfa06573f3958f88b235c4d2e5ecedab78f6c5
Comment 17 Jule Anger 2025-04-17 17:22:51 UTC
Closing out bug report.

Thanks!
Comment 18 Samba QA Contact 2025-06-03 06:50:43 UTC
This bug was referenced in samba v4-21-stable (Release samba-4.21.6):

1da707f1093abdcd0ee63c976a03fa4fff1f6423