From: Alexey Gladkov <legion@kernel.org>
To: make-initrd@lists.altlinux.org
Subject: Re: [make-initrd] [RFC PATCH] runtime: fix a suspended boot after rdshell
Date: Fri, 16 Oct 2026 12:20:36 +0200
Message-ID: <atH6dGZqdk5Hg9W3@example.org> (raw)
In-Reply-To: <atDn0Ig9+O3k772p@silver>
On Thu, Oct 15, 2026 at 02:48:48PM +0000, Egor Shestakov wrote:
> Привет, я похоже нашел причину почему все зависает. Применил патч у себя и
> все теперь работает нормально.
Простите за задержку. Уехал на openssl конференцию и думал, что никто не
заметит. И пропустил всю движуху :)
Да, ты прав. Это бага из-за рефакторинга. Исторически эта ошибка появилась
в два шага:
1. В коммите 598a4b241a ("Rewrite console locking") блокировка через
директорию /.initrd/rdshell.lock была заменена на `fd_lock 90 /dev/console`.
На тот момент логика жила в короткоживущем uevent-хендлере 400-rootdelay,
который делал:
fd_lock 90 /dev/console
rdshell "Emergency shell" &
exit
Сам хендлер тут же завершался (exit), закрывая у себя fd 90, а фоновый
процесс rdshell наследовал fd 90 и удерживал flock на /dev/console, пока
пользователь не выйдет из шелла.
2. В коммите 5bba8d357a ("Convert rootdelay to service") одноразовый
хендлер превратился в постоянный демон rootdelayd с бесконечным циклом, а
exit механически заменили на continue.
В результате rootdelayd берёт эксклюзивный лок fd_lock 90 /dev/console,
запускает rdshell & и уходит на continue, где бесконечно крутится в:
if [ -e "$disabled" ] || rootdelay_paused; then
sleep $period
continue
fi
Когда пользователь нажимает Ctrl-D в rdshell, процесс rdshell завершается,
но демон rootdelayd остаётся жить с открытым дескриптором 90 и никогда не
вызывает fd_unlock 90.
> -- >8 --
>
> Rdshell takes a write lock to /dev/console but never release it. Rdshell
> can run in foreground, because the rootdelayd doesn't wait for anything
> else and fails in an idle loop after rdshell has been invoked.
>
> Signed-off-by: Egor Shestakov <ved@altlinux.org>
> ---
> features/runtime/data/sbin/rootdelayd | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/features/runtime/data/sbin/rootdelayd b/features/runtime/data/sbin/rootdelayd
> index 7ea82afcf..85060cefd 100755
> --- a/features/runtime/data/sbin/rootdelayd
> +++ b/features/runtime/data/sbin/rootdelayd
> @@ -37,7 +37,8 @@ while :; do
> mkdir -p -- "$disabled"
>
> fd_lock 90 /dev/console
> - rdshell "Emergency shell" &
> + rdshell "Emergency shell"
> + fd_unlock 90
>
> continue
> fi
> @@ -91,7 +92,9 @@ while :; do
>
> mkdir -p -- "$disabled"
>
> - rdshell "$msg" &
> + rdshell "$msg"
> +
> + fd_unlock 90
>
> continue
> fi
Патч правильный, но неполный. В твоём пвтче дескриптор 90 унаследуется
rdshell и остальными утилитами из него. Правильнее закрыть дескриптор:
fd_lock 90 /dev/console
rdshell "Emergency shell" 90<&-
fd_unlock 90
и во втором месте тоже.
--
Rgrds, legion
next prev parent reply other threads:[~2026-10-16 10:20 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 22:42 [make-initrd] Параметр rdshell Leonid Krivoshein
2026-10-14 10:04 ` Egor Shestakov
2026-10-14 16:01 ` Leonid Krivoshein
2026-10-15 14:48 ` [make-initrd] [RFC PATCH] runtime: fix a suspended boot after rdshell Egor Shestakov
2026-10-16 10:20 ` Alexey Gladkov [this message]
2026-10-16 13:39 ` Egor Shestakov
2026-10-16 14:09 ` Alexey Gladkov
2026-10-16 14:13 ` Egor Shestakov
2026-10-16 14:11 ` Egor Shestakov
2026-10-19 10:22 ` [make-initrd] Параметр rdshell Alexey Gladkov
2026-10-19 12:51 ` [make-initrd] kmscon (was: Параметр rdshell) Egor Shestakov
2026-10-19 13:38 ` Alexey Gladkov
2026-10-19 15:09 ` Egor Shestakov
2026-10-19 16:14 ` Alexey Gladkov
2026-10-16 12:06 ` [make-initrd] [PATCH 0/2] runtime: Fix console locking Alexey Gladkov
2026-10-16 12:06 ` [make-initrd] [PATCH 1/2] runtime: Fix a lock leak in rootdelayd Alexey Gladkov
2026-10-16 12:06 ` [make-initrd] [PATCH 2/2] runtime: Fix console lock shadowing by /dev mount Alexey Gladkov
2026-10-16 20:02 ` Leonid Krivoshein
2026-10-17 9:45 ` Alexey Gladkov
2026-10-17 16:19 ` Leonid Krivoshein
2026-10-17 16:41 ` Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 00/11] Improve support for atomic actions Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 01/11] runtime: Fix a lock leak in rootdelayd Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 02/11] runtime: Fix console lock shadowing by /dev mount Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 03/11] runtime: Avoid leaking lock descriptor 90 to child processes Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 04/11] runtime: Replace /.initrd/initenv locking with atomic file update Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 05/11] runtime: Centralize file and console locking helpers Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 06/11] create-rootfs: Require bash 4.1 or newer for initramfs Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 07/11] network: Share DHCP hook lock between IPv4 and IPv6 on the same interface Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 08/11] luks: Serialize /etc/luks.keys updates and avoid duplicate entries Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 09/11] runtime: Synchronize concurrent /etc/fstab access with shared and exclusive locks Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 10/11] runtime: Update rootdelay deadline and failure message atomically Alexey Gladkov
2026-10-19 9:57 ` [make-initrd] [PATCH v2 11/11] runtime: Centralize atomic file replacement in write_atomic helper Alexey Gladkov
2026-10-19 19:30 ` [make-initrd] [PATCH v2 00/11] Improve support for atomic actions Leonid Krivoshein
2026-10-20 14:59 ` Alexey Gladkov
2026-10-20 19:04 ` Leonid Krivoshein
2026-10-20 19:23 ` [make-initrd] Уточнение по rootdelay_unpause() Leonid Krivoshein
2026-10-21 10:10 ` [make-initrd] [PATCH] runtime: Freeze rootdelay countdown while paused Alexey Gladkov
2026-10-21 7:18 ` [make-initrd] [PATCH v2 00/11] Improve support for atomic actions Alexey Gladkov
2026-10-21 8:50 ` Leonid Krivoshein
2026-10-21 10:18 ` Alexey Gladkov
2026-10-21 18:52 ` Leonid Krivoshein
2026-10-21 19:30 ` Alexey Gladkov
2026-10-21 19:33 ` Leonid Krivoshein
2026-10-21 19:31 ` Leonid Krivoshein
2026-10-21 20:03 ` Alexey Gladkov
2026-10-21 20:48 ` Leonid Krivoshein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=atH6dGZqdk5Hg9W3@example.org \
--to=legion@kernel.org \
--cc=make-initrd@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Make-initrd development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
public-inbox-index make-initrd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.make-initrd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git