加载共享库时出错

Les*_*Les 5 wine ubuntu-16.04

我为我的 Ubuntu 16.04 机器从 WineHQ 安装了 Wine,但出现以下错误:

\n\n

/opt/wine-stable/bin/wine: error while loading shared libraries: libwine.so.1: cannot\xc2\xa0create shared\xc2\xa0object descriptor: Operation not permitted.

\n

小智 6

简短回答 \xe2\x80\x93 运行以下命令:

\n\n
sudo sysctl -w vm.mmap_min_addr=0\n
Run Code Online (Sandbox Code Playgroud)\n\n

更长的答案:

\n\n

一天前,从Ubuntu 16.04 升级到 18.04(并从 WineHQ 重新安装 wine-staging)后,我遇到了完全相同的错误。

\n\n

我发现只有当尝试通过 Wine(在 64 位系统上)运行 32 位 Windows 可执行文件时才会发生这种情况。

\n\n

经过大量调试后,我通过尝试在以下位置运行 Wine notepad.exe 得到了线索strace

\n\n
$ strace /usr/bin/wine notepad.exe\nexecve("/usr/bin/wine", ["/usr/bin/wine", "notepad.exe"], 0x7ffc266e8478 /* 55 vars */) = 0\nstrace: [ Process PID=19507 runs in 32 bit mode. ]\nbrk(NULL)                               = 0x7c423000\n\n[ \xe2\x80\xa6 140 lines snipped \xe2\x80\xa6 ]\n\nopenat(AT_FDCWD, "/opt/wine-staging/lib/libwine.so.1", O_RDONLY|O_CLOEXEC) = 3\nread(3, "\\177ELF\\1\\1\\1\\0\\0\\0\\0\\0\\0\\0\\0\\0\\3\\0\\3\\0\\1\\0\\0\\0\\220d\\0\\0004\\0\\0\\0"..., 512) = 512\nfstat64(3, {st_mode=S_IFREG|0644, st_size=1832828, ...}) = 0\nmmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EPERM (Operation not permitted)\nclose(3)                                = 0\nwritev(2, [{iov_base="/opt/wine-staging/bin/wine", iov_len=26}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="libwine.so.1", iov_len=12}, {iov_base=": ", iov_len=2}, {iov_base="cannot create shared object desc"..., iov_len=38}, {iov_base=": ", iov_len=2}, {iov_base="Operation not permitted", iov_len=23}, {iov_base="\\n", iov_len=1}], 10/opt/wine-staging/bin/wine: error while loading shared libraries: libwine.so.1: cannot create shared object descriptor: Operation not permitted\n) = 144\nexit_group(127)                         = ?\n+++ exited with 127 +++\n
Run Code Online (Sandbox Code Playgroud)\n\n

关键是mmap2失败。阅读手册页后mmap2然后阅读手册mmap,它似乎只是试图映射一个 8192 字节的匿名块 \xe2\x80\x93 ,甚至没有链接到磁盘上的文件。这看起来非常无聊,而不是那种应该失败的事情。

\n\n

所以我想我应该调查一下sysctl设置,看看我的 Ubuntu 16.04 \xe2\x86\x92 18.04 升级中是否有任何可能已更改的内容,特别是任何可能影响mmap2或仅影响mmap.

\n\n

我在以下位置找到了可能的候选人/etc/sysctl.d/10-zeropage.conf

\n\n
# Protect the zero page of memory from userspace mmap to prevent kernel\n# NULL-dereference attacks against potential future kernel security\n# vulnerabilities.  (Added in kernel 2.6.23.)\n#\n# While this default is built into the Ubuntu kernel, there is no way to\n# restore the kernel default if the value is changed during runtime; for\n# example via package removal (e.g. wine, dosemu).  Therefore, this value\n# is reset to the secure default each time the sysctl values are loaded.\nvm.mmap_min_addr = 65536\n
Run Code Online (Sandbox Code Playgroud)\n\n

这看起来是一个强有力的候选者的主要原因是因为它提到了葡萄酒。

\n\n

之后,我在 WineHQ Wiki 上找到了这个页面:Preloader Page Zero Problem

\n\n

虽然该页面没有明确提到我们遇到的错误,但它提到了许多其他听起来可疑相关的事情。

\n\n

所以我尝试了它推荐的 \xe2\x80\x9c正确的解决方法\xe2\x80\x9d,即sudo sysctl -w vm.mmap_min_addr=0\xe2\x80\x93,突然间我可以再次在 Wine 下运行 Windows 32 位应用程序了!:-)

\n\n

注意:WineHQ Wiki 页面还提供了使该更改永久化的说明,但如果这样做可能会产生一些系统安全隐患。

\n