From nobody Wed Jun 15 19:44:49 2022 X-Original-To: freebsd-emulation@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3833C855285 for ; Wed, 15 Jun 2022 19:44:58 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from mail.lispworks.com (mail.lispworks.com [46.17.166.21]) by mx1.freebsd.org (Postfix) with ESMTP id 4LNbP45l44z3rky; Wed, 15 Jun 2022 19:44:54 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (higson.cam.lispworks.com [192.168.1.7]) by lwfs1-cam.cam.lispworks.com (8.16.1/8.16.1) with ESMTP id 25FJiofU086986; Wed, 15 Jun 2022 20:44:50 +0100 (BST) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (localhost.localdomain [127.0.0.1]) by higson.cam.lispworks.com (8.14.4) id 25FJingH024191; Wed, 15 Jun 2022 20:44:49 +0100 Received: (from martin@localhost) by higson.cam.lispworks.com (8.14.4/8.14.4/Submit) id 25FJinlg024188; Wed, 15 Jun 2022 20:44:49 +0100 Date: Wed, 15 Jun 2022 20:44:49 +0100 Message-Id: <202206151944.25FJinlg024188@higson.cam.lispworks.com> From: Martin Simmons To: Sysadmin Lists CC: freebsd-emulation@freebsd.org, dchagin@freebsd.org In-reply-to: <606426103.1627955.1655317573324@ichabod.co-bxl> (message from Sysadmin Lists on Wed, 15 Jun 2022 20:26:13 +0200 (CEST)) Subject: Re: libc6 Compatibility References: <1236409007.1125724.1655169963971@ichabod.co-bxl> <2033861928.1354940.1655236558393@ichabod.co-bxl> <202206151704.25FH4m4d019069@higson.cam.lispworks.com> <606426103.1627955.1655317573324@ichabod.co-bxl> X-Rspamd-Queue-Id: 4LNbP45l44z3rky X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of martin@lispworks.com has no SPF policy when checking 46.17.166.21) smtp.mailfrom=martin@lispworks.com X-Spamd-Result: default: False [-1.93 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.96)[-0.962]; FREEFALL_USER(0.00)[martin]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[lispworks.com]; AUTH_NA(1.00)[]; NEURAL_HAM_LONG(-1.00)[-0.998]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.969]; MLMMJ_DEST(0.00)[freebsd-emulation]; R_SPF_NA(0.00)[no SPF record]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:51055, ipnet:46.17.160.0/21, country:GB] X-ThisMailContainsUnwantedMimeParts: N List-Id: Development of Emulators of other operating systems List-Archive: https://lists.freebsd.org/archives/freebsd-emulation List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-emulation@freebsd.org >>>>> On Wed, 15 Jun 2022 20:26:13 +0200 (CEST), Sysadmin Lists said: > > > ---------------------------------------- > > From: Martin Simmons > > Sent: Wed Jun 15 19:04:48 CEST 2022 > > To: Sysadmin Lists > > Cc: , > > Subject: Re: libc6 Compatibility > > > > > > >>>>> On Tue, 14 Jun 2022 21:55:58 +0200 (CEST), Sysadmin Lists said: > > > > > > > ---------------------------------------- > > > > From: Dmitry Chagin > > > > Sent: Tue Jun 14 09:24:37 CEST 2022 > > > > To: Sysadmin Lists > > > > Cc: Freebsd Emulation > > > > Subject: Re: libc6 Compatibility > > > > > > > > > > > > On Tue, Jun 14, 2022 at 03:26:03AM +0200, Sysadmin Lists wrote: > > > > > Does Linux compat not work with Ubuntu's newest libc6 update? > > > > > I used to run Brave browser from it, but now I get this error message: > > > > > > > > > > $ /compat/ubuntu/opt/brave.com/brave/brave > > > > > ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 > > > > > Abort trap > > > > > > > > > > The shared object is loaded in memory: > > > > > $ ldd /opt/brave.com/brave/brave | grep ld- > > > > > /lib64/ld-linux-x86-64.so.2 (0x0000000001021000) > > > > > > > > > > And it exists on the filesystem: > > > > > $ find /compat/ubuntu/lib**/ -name ld-\* -exec ls -lh '{}' + > > > > > -rwxr-xr-x 1 root wheel 187K Dec 16 2020 /compat/ubuntu/lib/x86_64-linux-gnu/ld-2.31.so > > > > > lrwxr-xr-x 1 root wheel 10B Dec 16 2020 /compat/ubuntu/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -> ld-2.31.so > > > > > lrwxr-xr-x 1 root root 34B Mar 23 2021 /compat/ubuntu/lib64/ld-linux-x86-64.so.2 -> ../lib/x86_64-linux-gnu/ld-2.31.so > > > > > > > > > > This is the update that broke it: > > > > > $ apt-get install libc6 > > > > > Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6 amd64 2.31-0ubuntu9.9 [2722 kB] > > > > > > > > > > > > > try ktrace it, aka ktrace -di /compat/ubuntu/opt/brave.com/brave/brave > > > > then kdump -HAR -m 128 > brave.log > > > > > > > > > > > > > > Thanks, Dmitry. That helped me find the problem. Here's the full log: > > > > > > $ cat brave.log > > > 8184 101222 ktrace 0.000000 RET F64 ktrace 0 > > > 8184 101222 ktrace 0.000014 CALL F64 execve(0x7fffffffeda3,0x7fffffffeac0,0x7fffffffead0) > > > 8184 101222 ktrace 0.000003 NAMI F64 "/compat/ubuntu/opt/brave.com/brave/brave" > > > 8184 101222 ktrace 0.055726 NAMI F64 "/compat/ubuntu/lib64/ld-linux-x86-64.so.2" > > > 8184 101222 ktrace 0.000032 NAMI F64 "/lib64/ld-linux-x86-64.so.2" > > > > > > And here's an updated `ls' printout after upgrading libc6: > > > $ find /compat/ubuntu/lib**/ -name ld-\* -exec ls -lh '{}' + > > > -rwxr-xr-x 1 root wheel 187K Apr 6 18:24 /compat/ubuntu/lib/x86_64-linux-gnu/ld-2.31.so > > > lrwxr-xr-x 1 root wheel 10B Apr 6 18:24 /compat/ubuntu/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -> ld-2.31.so > > > lrwxr-xr-x 1 root wheel 32B Apr 6 18:24 /compat/ubuntu/lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.31.so > > > > > > The new .so is missing 'previous directory' dots in the symlink path. > > > > It looks like the link with the dots was made by hand in 2021, presumably to > > fix this. > > That might be the case. I remember having to make changes to the shared object > before. The question then becomes, why only this update to libc6 and not > previous updates? Based on the file dates, I suspect there were no previous updates to libc6 installed since Dec 16 2020. > > > I thought Linux compat was designed to search compat.linux.emul_path > > > for shared libs first, but apparently it works differently than that. > > > > What does linux compat do in general with absolute symlinks? Does it check > > the target with compat.linux.emul_path prepended? > > That's what the documentation says: > "Linux mode dynamically reroots lookups. This is, in effect, equivalent to > union to file system mounts. First, an attempt is made to look up the file in > /compat/linux/original-path. If that fails, the lookup is done in > /original-path. This makes sure that binaries that require other binaries can > run." > https://docs.freebsd.org/en/books/handbook/linuxemu/#linuxemu-advanced > > Looking at the installer script, it's clear this is a known issue: > $ sed -n '/fix_ld_path(/,/^$/p' /usr/local/share/linux-browser-installer/linux-browser-installer > fix_ld_path() > { > (cd ${chroot_path}/lib64 && \ > (unlink ./ld-linux-x86-64.so.2; \ > ln -s ../lib/x86_64-linux-gnu/ld-${ld_version}.so \ > ld-linux-x86-64.so.2)) > } > > So, either: > 1. The documentation is wrong. > 2. It's a bug. Looking at how it is implemented, the rerooting applies to the argument to the Linux system call before it calls the code that implements the FreeBSD system call to do the actual work. I think the problem here is that symlinks are resolved by FreeBSD system call code (the NAMI operation), but that doesn't do any rerooting. I don't know if that is a bug or a necessary limitation. __Martin