代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/dracut 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 32f6f364ddeb706bf8741f2895d60022aee264e7 Mon Sep 17 00:00:00 2001
From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
Date: Thu, 10 Aug 2023 09:22:28 +0200
Subject: [PATCH] fix(dracut-install): protect against broken links pointing to
themselves
`readlink` does not return an error if a symbolic link points to itself, which
can cause a stack overflow due to infinite recursion in the `get_real_file`
function.
Although this type of recursive links should not exist, we discovered this
issue on a real system. It can be reproduced as follows:
```
> ls -l /lib64/libblkid.so
-rwxr-xr-x 1 root root 224368 Aug 9 15:13 /lib64/libblkid.so
> rm -f /lib64/libblkid.so
> ln -s /lib64/libblkid.so /lib64/libblkid.so
> ls -l /lib64/libblkid.so
lrwxrwxrwx 1 root root 18 Aug 9 15:06 /lib64/libblkid.so -> /lib64/libblkid.so
> dracut -f -I "/lib64/libblkid.so" test.img
...
dracut-install: Handle '/lib64/libblkid.so'
dracut-install: dracut_install('/lib64/libblkid.so', '/lib64/libblkid.so', 0, 0, 1)
dracut-install: get_real_file('/lib64/libblkid.so')
dracut-install: get_real_file: readlink('/lib64/libblkid.so') returns '/lib64/libblkid.so'
dracut-install: get_real_file('/lib64/libblkid.so') => '/lib64/libblkid.so'
...
[infinite recursion]
...
dracut-install: dracut_install('/lib64/libblkid.so', '/lib64/libblkid.so', 0, 0, 1)
dracut-install: get_real_file('/lib64/libblkid.so')
dracut-install: get_real_file: readlink('/lib64/libblkid.so') returns '/lib64/libblkid.so'
dracut-install: get_real_file('/lib64/libblkid.so') => '/lib64/libblkid.so'
dracut-install: dracut_install('/lib64/libblkid.so', '/lib64/libblkid.so', 0, 0, 1)
/usr/lib/dracut/dracut-init.sh: line 298: 20949 Segmentation fault (core dumped) $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
dracut: FAILED: /usr/lib/dracut/dracut-install --debug -D /var/tmp/dracut.dqLmOS/initramfs -a /lib64/libblkid.so
...
```
After applying this patch:
```
> dracut -f -I "/lib64/libblkid.so" test.img
...
dracut-install: Handle '/lib64/libblkid.so'
dracut-install: dracut_install('/lib64/libblkid.so', '/lib64/libblkid.so', 0, 0, 1)
dracut-install: get_real_file('/lib64/libblkid.so')
dracut-install: get_real_file: readlink('/lib64/libblkid.so') returns '/lib64/libblkid.so'
dracut-install: ERROR: '/lib64/libblkid.so' is pointing to itself.
dracut-install: ERROR: installing '/lib64/libblkid.so'
dracut: FAILED: /usr/lib/dracut/dracut-install --debug -D /var/tmp/dracut.4w8FVL/initramfs -a /lib64/libblkid.so
...
```
---
src/install/dracut-install.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c
index 5cfcf5170..485143a58 100644
--- a/src/install/dracut-install.c
+++ b/src/install/dracut-install.c
@@ -480,6 +480,11 @@ static char *get_real_file(const char *src, bool fullyresolve)
log_debug("get_real_file: readlink('%s') returns '%s'", fullsrcpath, linktarget);
+ if (streq(fullsrcpath, linktarget)) {
+ log_error("ERROR: '%s' is pointing to itself", fullsrcpath);
+ return NULL;
+ }
+
if (linktarget[0] == '/') {
_asprintf(&abspath, "%s%s", (sysrootdirlen ? sysrootdir : ""), linktarget);
} else {
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。