Bug 289678 - git commit 56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7 broke compatibility with old freebsd releases
Summary: git commit 56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7 broke compatibility with ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.3-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: Konstantin Belousov
URL:
Keywords: regression
Depends on:
Blocks: 15.0-metabug
  Show dependency tree / graph
 
Reported: 2025-09-18 07:28 UTC by Vitalij Satanivskij
Modified: 2025-10-20 08:01 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vitalij Satanivskij 2025-09-18 07:28:39 UTC
There are some jails that was working with         osrelease = 11.1-STABLE;        osreldate = 1101506; and COMPAT11 in kernel. But after upgrade system to latest stable there are problem with directory listing in some binaries 

for example - #!/usr/local/bin/python2.7
# -*- coding: utf-8 -*-
import os
path ='/root/'

try:
    print(os.listdir(path))
except OSError as e:
    print("Error:", e)

rise ('Error:', OSError(22, 'Invalid argument'))

Also same problem seen in postgres: postgres[36569]: [1-1] FATAL:  could not read directory "pg_notify": Invalid argument

Also problem notice on older jails with FreeBSD 10 code.

I found exactly which commit broke it.

Is it possible to fix it in way so it will tolerate old binaries when COMPATxx options used in kernel?
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2025-09-18 07:49:40 UTC
^Triage: assign to committer.
Comment 2 Paul 2025-09-18 09:06:46 UTC
Running this script via truss under different conditions:

[[1]]
Host FreeBSD 14.2 
Jail: copied from original host @ FreeBSD 11.1
Python: 2.7
Last getdirentries(): receives EINVAL errno

# truss -f -s512 python2.7 t.py
...
90485: read(3,"#!/usr/local/bin/python2.7\n# -*- coding: utf-8 -*-\nimport os\npath ='/root/'\n\ntry:\n    print(os.listdir(path))\nexcept OSError as e:\n    print("Error:", e)\n",4096) = 154 (0x9a)
90485: lseek(3,0x0,SEEK_CUR)                     = 154 (0x9a)
90485: read(3,0x355da292000,4096)                = 0 (0x0)
90485: close(3)                                  = 0 (0x0)
90485: open("/root/",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,04632425500) = 3 (0x3)
90485: fstatfs(3,{ fstypename=zfs,mntonname=/,mntfromname=MFILES2/jails/cnv4/converter2,fsid= }) = 0 (0x0)
90485: getdirentries(0x3,0x355da292000,0x1000,0x355da284088) = 464 (0x1d0)
90485: getdirentries(0x3,0x355da292000,0x1000,0x355da284088) ERR#22 'Invalid argument'
90485: close(3)                                  = 0 (0x0)
90485: fstat(1,{ mode=crw--w---- ,inode=299,size=0,blksize=4096 }) = 0 (0x0)
90485: ioctl(1,TIOCGETA,0x820c912c0)             = 0 (0x0)
('Error:', OSError(22, 'Invalid argument'))
90485: write(1,"('Error:', OSError(22, 'Invalid argument'))\n",44) = 44 (0x2c)
90485: sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
90485: sigaction(SIGINT,{ SIG_DFL 0x0 ss_t },{ 0x8223d5d60 SA_SIGINFO ss_t }) = 0 (0x0)
90485: sigprocmask(SIG_SETMASK,{ },0x0)          = 0 (0x0)
90485: exit(0x0)
90485: process exit, rval = 0


[[2]]
Host FreeBSD 11.1
Jail: Same jail as above, but original to this host
Python: 2.7
Last getdirentries(): receives 0 errno

# truss -f -s512 python2.7 t.py
...
29765: read(3,"#!/usr/local/bin/python2.7\n# -*- coding: utf-8 -*-\nimport os\npath ='/root/'\n\ntry:\n    print(os.listdir(path))\nexcept OSError as e:\n    print("Error:", e)\n",4096) = 154 (0x9a)
29765: close(3)                                  = 0 (0x0)
29765: stat("t.py",{ mode=-rw-r--r-- ,inode=12,size=154,blksize=4096 }) = 0 (0x0)
29765: open("t.py",O_RDONLY,0666)                = 3 (0x3)
29765: fstat(3,{ mode=-rw-r--r-- ,inode=12,size=154,blksize=4096 }) = 0 (0x0)
29765: ioctl(3,TIOCGETA,0x7fffffffe960)          ERR#25 'Inappropriate ioctl for device'
29765: lseek(3,0x0,SEEK_CUR)                     = 0 (0x0)
29765: fstat(3,{ mode=-rw-r--r-- ,inode=12,size=154,blksize=4096 }) = 0 (0x0)
29765: read(3,"#!/usr/local/bin/python2.7\n# -*- coding: utf-8 -*-\nimport os\npath ='/root/'\n\ntry:\n    print(os.listdir(path))\nexcept OSError as e:\n    print("Error:", e)\n",4096) = 154 (0x9a)
29765: lseek(3,0x0,SEEK_CUR)                     = 154 (0x9a)
29765: read(3,0x801c8e000,4096)                  = 0 (0x0)
29765: close(3)                                  = 0 (0x0)
29765: open("/root/",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,0140605500) = 3 (0x3)
29765: fstatfs(3,{ fstypename=zfs,mntonname=/,mntfromname=jails/converter2,fsid= }) = 0 (0x0)
29765: getdirentries(0x3,0x801c8e000,0x1000,0x801c80088) = 464 (0x1d0)
29765: getdirentries(0x3,0x801c8e000,0x1000,0x801c80088) = 0 (0x0)
29765: close(3)                                  = 0 (0x0)
29765: fstat(1,{ mode=crw--w---- ,inode=167,size=0,blksize=4096 }) = 0 (0x0)
29765: ioctl(1,TIOCGETA,0x7fffffffe480)          = 0 (0x0)
['.mysql_history', '.cache', '.psql_history', '.k5login', '.lesshst', '.npm', '.cshrc', '.config', 'OnlyOffice', 'bin', '.history', 'test', '.node-gyp', '.zsh-histfile', '.bash_history', '.w3m', 'nginx', 'linux_base-c7-7.3.1611_6.txz', '.local', '.login', '.rediscli_history', '.profile']
29765: write(1,"['.mysql_history', '.cache', '.psql_history', '.k5login', '.lesshst', '.npm', '.cshrc', '.config', 'OnlyOffice', 'bin', '.history', 'test', '.node-gyp', '.zsh-histfile', '.bash_history', '.w3m', 'nginx', 'linux_base-c7-7.3.1611_6.txz', '.local', '.login', '.rediscli_history', '.profile']\n",289) = 289 (0x121)
29765: sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
29765: sigaction(SIGINT,{ SIG_DFL 0x0 ss_t },{ 0x80082fd60 SA_SIGINFO ss_t }) = 0 (0x0)
29765: sigprocmask(SIG_SETMASK,{ },0x0)          = 0 (0x0)
29765: exit(0x0)
29765: process exit, rval = 0


[[3]]
Host FreeBSD 14.2
Jail: Jain with python3, original to this host
Python: 3.11
Last getdirentries(): receives 0 errno

# truss -f -s512 python3.11 t.py
...
90595: read(3,"#!/usr/local/bin/python3.11\n# -*- coding: utf-8 -*-\nimport os\npath ='/root/'\n\ntry:\n    print(os.listdir(path))\nexcept OSError as e:\n    print("Error:", e)\n",156) = 155 (0x9b)
90595: read(3,0x3a7b2b69c9eb,1)                  = 0 (0x0)
90595: lseek(3,0x0,SEEK_SET)                     = 0 (0x0)
90595: close(3)                                  = 0 (0x0)
90595: fstatat(AT_FDCWD,"/tmp/t.py",{ mode=-rw-r--r-- ,inode=1795,size=155,blksize=4096 },0x0) = 0 (0x0)
90595: readlink("t.py",0x820d46720,1024)         ERR#22 'Invalid argument'
90595: __realpathat(AT_FDCWD,"t.py","/tmp/t.py",1024,0) = 0 (0x0)
90595: open("/tmp/t.py",O_RDONLY,0666)           = 3 (0x3)
90595: ioctl(3,FIOCLEX,0x0)                      = 0 (0x0)
90595: fstat(3,{ mode=-rw-r--r-- ,inode=1795,size=155,blksize=4096 }) = 0 (0x0)
90595: ioctl(3,TIOCGETA,0x820d4aa14)             ERR#25 'Inappropriate ioctl for device'
90595: lseek(3,0x0,SEEK_CUR)                     = 0 (0x0)
90595: fstat(3,{ mode=-rw-r--r-- ,inode=1795,size=155,blksize=4096 }) = 0 (0x0)
90595: read(3,"#!/usr/local/bin/python3.11\n# -*- coding: utf-8 -*-\nimport os\npath ='/root/'\n\ntry:\n    print(os.listdir(path))\nexcept OSError as e:\n    print("Error:", e)\n",4096) = 155 (0x9b)
90595: lseek(3,0x0,SEEK_CUR)                     = 155 (0x9b)
90595: read(3,0x3a7b2bb8f000,4096)               = 0 (0x0)
90595: close(3)                                  = 0 (0x0)
90595: open("/root/",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,00) = 3 (0x3)
90595: fcntl(3,F_ISUNIONSTACK,0x0)               = 0 (0x0)
90595: getdirentries(3,"\f\^E\0\0\0\0\0\0\^A\0\0\0\0\0\0\0 \0\^D\0\^A\0\0\0.\0\0\0\0\0\0\0"\0\0\0\0\0\0\0\^B\0\0\0\0\0\0\0 \0\^D\0\^B\0\0\0..\0\0\0\0\0\0\M-$B\^C\0\0\0\0\0\M-K\M-kj\^Q\0\0\0\0 \0\^D\0\^F\0\0\0.cache\0\0\^W?\0\0\0\0\0\0u\^^|\^R\0\0\0\0(\0\b\0\b\0\0\0.lesshst\0\0\0\0\0\0\0\0\M^B\M^H\^C\0\0\0\0\0\M-d\M-q\M--\^S\0\0\0\0 \0\^D\0\a\0\0\0.screen\0c;\^C\0\0\0\0\0\M-V\M-B\M-S\^S\0\0\0\0000\0\b\0\^R\0\0\0portmasterfail.txt\0\0\0\0\0\0\M^C\M-+\^E\0\0\0\0\0}\M-M(\^T\0\0\0\0 \0\^D\0\^D\0\0\0.ssh\0\0\0\0\^C\^E\0\0\0\0\0\0J\M^F"...,4096,{ 0x0 }) = 632 (0x278)
90595: getdirentries(3,0x3a7b2bb8f000,4096,{ 0x1fd6873a }) = 0 (0x0)
90595: close(3)                                  = 0 (0x0)
['.cache', '.lesshst', '.screen', 'portmasterfail.txt', '.ssh', '.cshrc', '.k5login', 'bin', '.sh_history', '.profile', '.zsh-histfile', '.config', '.local', '.shrc', '.zshrc', '.login']
90595: write(1,"['.cache', '.lesshst', '.screen', 'portmasterfail.txt', '.ssh', '.cshrc', '.k5login', 'bin', '.sh_history', '.profile', '.zsh-histfile', '.config', '.local', '.shrc', '.zshrc', '.login']\n",187) = 187 (0xbb)
90595: sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
90595: sigaction(SIGINT,{ SIG_DFL SA_ONSTACK ss_t },{ 0x825f7cd30 SA_ONSTACK|SA_SIGINFO ss_t }) = 0 (0x0)
90595: sigprocmask(SIG_SETMASK,{ },0x0)          = 0 (0x0)
90595: munmap(0x3a7b2b665000,1048576)            = 0 (0x0)
90595: munmap(0x3a7b2b765000,16384)              = 0 (0x0)
90595: exit(0x0)
90595: process exit, rval = 0


It seems like the contract for this syscal has been changed, but the old version of libc simply passes this new error value up to the client?
Comment 3 Konstantin Belousov freebsd_committer freebsd_triage 2025-09-18 19:46:42 UTC
Try to revert 9a3edc8d5dbcb896179cfa7867f961184e146a09.
If it helps, I will commit the revert.
Comment 4 Vitalij Satanivskij 2025-09-19 07:10:16 UTC
I'm already test revisiaon where it broke 
it  for stable/14
d5cd41f2f1cffcf302ff80fc8a6a51ceeb81bfa5 - ok
56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7 - not ok

56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7 - is a 
(cherry picked from commit 9a3edc8d5dbcb896179cfa7867f961184e146a09)

and d5cd41f2f1cffcf302ff80fc8a6a51ceeb81bfa5 - is a 
(cherry picked from commit adba3e087173b8ca6c5e9db7241812d4ac752608)

Yes revert help.
Comment 5 Vitalij Satanivskij 2025-09-19 10:27:13 UTC
I'm make revert 

Author: Charlie Root <root@ng5.ukr.net>
Date:   Fri Sep 19 12:23:23 2025 +0300

    Revert "zfs readdir: if there were no dirents to copy out, return EINVAL same as UFS"

    This reverts commit 56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7.

commit 6f59cb79e84a86d7b864d709652ec57b6928a6cf (origin/stable/14)
Author: Steve Kargl <kargl@FreeBSD.org>
Date:   Thu Sep 11 19:38:17 2025 +0300

    lib/msun: cpow{,f,l}(CMLX(0.0, 0.0)) should return 1.0

    PR:     289447

    (cherry picked from commit 8b41ba845c7e10b5f241a1f944fe9a8e19ad75a9)

and rebuild system - problem gone. So confimed - just reverting 56e00aca338cc45c3fbd4f95c2a8bb8dfac1efb7/9a3edc8d5dbcb896179cfa7867f961184e146a0 help
Comment 6 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-09-19 15:36:18 UTC
Should this be reverted in main as well?  It doesn't seem right to me.
Comment 7 Konstantin Belousov freebsd_committer freebsd_triage 2025-09-19 15:40:30 UTC
(In reply to Dag-Erling Smørgrav from comment #6)
Of course it must be reverted in main first.
I am working on it.
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-09-19 17:12:25 UTC
A commit in branch main references this bug:

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

commit 932e404f12c172e3d4ec47dedee02da400ef8f92
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-09-19 17:05:08 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-09-19 17:11:50 +0000

    Revert "zfs readdir: if there were no dirents to copy out, return EINVAL same as UFS"

    This reverts commit 9a3edc8d5dbcb896179cfa7867f961184e146a09.
    Apparently returning EINVAL is more aggressive than UFS does it, and
    this causes compatibility issues with apps that actually trigger the
    behavior.

    PR:     289485, 289678
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days

 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-09-22 04:54:04 UTC
A commit in branch stable/15 references this bug:

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

commit de19a7d54d30483343dbc526af8e0b4cb83892f7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-09-19 17:05:08 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-09-21 23:25:16 +0000

    Revert "zfs readdir: if there were no dirents to copy out, return EINVAL same as UFS"

    PR:     289485, 289678

    (cherry picked from commit 932e404f12c172e3d4ec47dedee02da400ef8f92)

 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-09-22 04:55:07 UTC
A commit in branch stable/14 references this bug:

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

commit 5367bef138862b21f937a66b5647f8f81e6f2ab7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-09-19 17:05:08 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-09-22 04:54:00 +0000

    Revert "zfs readdir: if there were no dirents to copy out, return EINVAL same as UFS"

    PR:     289485, 289678

    (cherry picked from commit 932e404f12c172e3d4ec47dedee02da400ef8f92)

 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Comment 11 Colin Percival freebsd_committer freebsd_triage 2025-10-20 05:17:25 UTC
Can this PR now be closed?