Skip to content

Commit a6fd000

Browse files
committed
flatcar-postinst: Take the real path of the dynamic linker
When we find the dynamic linker in the new partition, then we derive the library path by getting the basename of the dynamic linker. The found linker and the library path are used to invoke binaries inside the new partition (currently, cgpt). On arm64, /lib and /lib64 are separate directories. Libc and the dynamic linker are installed to /lib64, but there is also a symlink to the dynamic linker in /lib. If the symlink in /lib gets found first, then the library path is erroneously set to /lib. When calling the found dynamic linker with the wrong library path, the linker will load libraries from the old partition. This may work by accident, but updating glibc to 2.34 broke it.
1 parent 6c0237c commit a6fd000

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

flatcar-postinst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,13 @@ LDSO=
403403
#
404404
# glibc 2.35 installs a symlink to the dynamic linker under
405405
# /usr/bin/ld.so. Check this one too.
406+
#
407+
# Since we derive library path from the linker path, make sure we are
408+
# dealing with the actual executable, not with a symlink. We do it by
409+
# using realpath on the found file.
406410
for l in "${INSTALL_MNT}"/{,usr/}bin/ld.so "${INSTALL_MNT}"/lib*/ld-2.??.so "${INSTALL_MNT}"/lib*/ld-linux-*.so.?; do
407411
if [[ -x "$l" ]]; then
408-
LDSO="$l"
412+
LDSO=$(realpath "$l")
409413
break
410414
fi
411415
done

0 commit comments

Comments
 (0)