Bug 273414 - linuxulator regression in symlinks under zfs
Summary: linuxulator regression in symlinks under zfs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Dmitry Chagin
URL:
Keywords: regression
Depends on:
Blocks: 14.0r
  Show dependency treegraph
 
Reported: 2023-08-28 22:23 UTC by Vincent Milum Jr
Modified: 2024-01-24 20:33 UTC (History)
9 users (show)

See Also:
linimon: mfc-stable13?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Milum Jr 2023-08-28 22:23:37 UTC
This commit broke symlinks when using Linuxulator:
https://reviews.freebsd.org/D40090

Further information can be found in:
https://reviews.freebsd.org/D40479

Repro steps, tested with latest 14.0-ALPHA3 ISO fresh install:

sysrc linux_enable="YES"
service linux start
pkg install fontconfig linux-c7-fontconfig font-adobe-75dpi

This command completes correctly:
fc-list

This command errors out:
/compat/linux/usr/bin/fc-list


After further testing, it was found that this issue only happens with ZFS file systems. UFS file systems are unaffected by this issue.

The initial issue was discovered because due to fontconfig no longer being able to see its own config file, Linux apps no longer had font rendering support. The small test above is a smaller test case without requiring a full desktop installation to see the issue.

A full video recording of the repro was also produced:
https://www.youtube.com/watch?v=N46TGrCK4t8
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2023-08-29 03:50:38 UTC
dchagin wrote in D40479:
> We found the cause of the problem, on it


Handing it over to him
Comment 2 Dmitry Chagin freebsd_committer freebsd_triage 2023-08-29 08:54:31 UTC
here it rather makes sense to speak about regression in vfs/namecache/ufs due to the fact that:
1. starting from https://cgit.freebsd.org/src/commit/sys/kern/vfs_cache.c?id=739ecbcf1c4fd22b5f6ee0bb180a67644046a3e0 file systems should cache symbolic link targets on their own. This method is not implemented for UFS, so the described bug does not occur for UFS.

2. UFS currently does not use namecache at all, so this bug does not occur. See here: https://reviews.freebsd.org/D41337, https://reviews.freebsd.org/D41338

I think it would be correct to modify the algorithm of the namei() and cache_fplookup() functions so that file systems are not responsible for caching symlink targets, ie, cache_fplookup() should stop its loop and return PARTIAL in case of a symbolic link, and namei() should resolve the symlink and go to the cache lookup starting from the current directory.

As a temporary fix, try this patch, please: https://people.freebsd.org/~dchagin/vfs.patch
Comment 3 Dmitry Chagin freebsd_committer freebsd_triage 2023-09-10 14:47:31 UTC
https://people.freebsd.org/~dchagin/nc.patch
Comment 4 Dmitry Chagin freebsd_committer freebsd_triage 2023-09-11 10:23:15 UTC
https://reviews.freebsd.org/D41806
Comment 5 Dan Kotowski 2023-09-11 14:41:31 UTC
Dmitri - could you expand on vfs.patch, nc.patch, and D41806? Should we ignore vfs.patch and nc.patch in favor of D41806 when it lands?
Comment 6 Dmitry Chagin freebsd_committer freebsd_triage 2023-09-11 18:22:56 UTC
(In reply to Dan Kotowski from comment #5)
Ah, nc.patch is the same as D41806, vfs.patch is wrong, don't use it
Comment 7 Ed Maste freebsd_committer freebsd_triage 2023-10-16 14:22:16 UTC
Vincent, are you able to build & test the patch in D41806 to confirm it resolves the issue for you?
Comment 8 Dmitry Chagin freebsd_committer freebsd_triage 2023-10-17 09:15:19 UTC
(In reply to Ed Maste from comment #7)
I've asked Gleb to test, no response yet. I plan to commit this temporary solution tomorrow to merge to releng/14.0.
I will write a separate letter with a plan to fix this problem.
Comment 9 Gleb Smirnoff freebsd_committer freebsd_triage 2023-10-17 14:08:26 UTC
The patch works as expected. Just tested it.
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-10-19 10:34:22 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=bb8ecf259f96510b9c2146d846403393543061b7

commit bb8ecf259f96510b9c2146d846403393543061b7
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-10-19 10:33:58 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-10-19 10:33:58 +0000

    vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI

    This is a temporary solution to fix PR before release.
    During 15.0 it's necessary to refactor symlinks handling
    between vfs & namecache.

    PR:                     273414
    Reported by:            Vincent Milum Jr, Dan Kotowski, glebius
    Tested by:              Dan Kotowski, glebius
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D41806
    MFC after:              3 days

 sys/kern/vfs_cache.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 11 Alex S 2023-10-20 20:44:05 UTC
Nitpick: it doesn't matter whether symlinks start with /, only that they reside in compat.linux.emul_path and point outside of it. (Yes, both absolute and relative symlinks work on FreeBSD 13. That doesn't necessarily mean that behavior is worth keeping — I don't have an opinion here.)
Comment 12 commit-hook freebsd_committer freebsd_triage 2023-10-22 06:56:42 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b84a836ef02de42e262ce44d46c859be288df4b0

commit b84a836ef02de42e262ce44d46c859be288df4b0
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-10-19 10:33:58 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-10-22 06:55:53 +0000

    vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI

    This is a temporary solution to fix PR before release.
    During 15.0 it's necessary to refactor symlinks handling
    between vfs & namecache.

    PR:                     273414
    Reported by:            Vincent Milum Jr, Dan Kotowski, glebius
    Tested by:              Dan Kotowski, glebius
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D41806
    MFC after:              3 days

    (cherry picked from commit bb8ecf259f96510b9c2146d846403393543061b7)

 sys/kern/vfs_cache.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 13 commit-hook freebsd_committer freebsd_triage 2023-10-22 18:48:07 UTC
A commit in branch releng/14.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=accbd5ad06c3eeb17d75cde05597f70f1fedb061

commit accbd5ad06c3eeb17d75cde05597f70f1fedb061
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-10-19 10:33:58 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-10-22 18:46:22 +0000

    vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI

    This is a temporary solution to fix PR before release.
    During 15.0 it's necessary to refactor symlinks handling
    between vfs & namecache.

    Approved by:            re (gjb)
    PR:                     273414
    Reported by:            Vincent Milum Jr, Dan Kotowski, glebius
    Tested by:              Dan Kotowski, glebius
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D41806
    MFC after:              3 days

    (cherry picked from commit bb8ecf259f96510b9c2146d846403393543061b7)
    (cherry picked from commit b84a836ef02de42e262ce44d46c859be288df4b0)

 sys/kern/vfs_cache.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 14 Ed Maste freebsd_committer freebsd_triage 2024-01-24 20:33:04 UTC
This issue wasn't in 13.x