[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] switch_root: remove /init check
From: Kang-Che Sung <explorer09 () gmail ! com>
Date: 2024-04-23 10:07:21
Message-ID: CADDzAfNUsTMM4eV9Bj95mt+1f+UOJ8B_A+zDMT7K6zBjr59KTQ () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Linus Heckemann <git@sphalerite.org> 於 2024年4月23日 星期二寫道:
>
> I don't really see the existence of /init being so critical for
> this check given that we check below that it's a ramfs or tmpfs, which
> seems to me to be enough that people won't be destroying filesystems
> they cared a great deal about.
>
The ramfs/tmpfs check was good as it won't destroy any _permanent_ file the
user could have, but it wouldn't hurt either when there is another sanity
check.
>> Perhaps a better approach is to check the existence of what's specified
in
>> the "rdinit" parameter instead.
>
> That would introduce an additional dependency on /proc being mounted and
> require additional parsing. I don't think the check is that necessary,
> again because we have the /-is-ramfs-or-tmpfs check. But if you do think
> we need it I can rewrite the patch to check for rdinit= on cmdline as
well.
>
/proc should be mounted by most init systems anyway. But we can skip the
check when /proc doesn't exist, just in case.
The logic would be roughly like this:
If "/proc/cmdline" exists
Read the "rdinit" parameter from "/proc/cmdline"; if it's unspecified,
default to "/init"
If the file in "rdinit" doesn't exist, stop.
Else
Skip the "rdinit" existence check and continue the switch_root process
[Attachment #5 (text/html)]
<br>Linus Heckemann <<a \
href="mailto:git@sphalerite.org">git@sphalerite.org</a>> 於 2024年4月23日 \
星期二寫道:<br>><br>> I don't really see the existence of /init \
being so critical for<br>> this check given that we check below that it's a \
ramfs or tmpfs, which<br>> seems to me to be enough that people won't be \
destroying filesystems<br>> they cared a great deal about.<br>><br><br>The \
ramfs/tmpfs check was good as it won't destroy any _permanent_ file the user \
could have, but it wouldn't hurt either when there is another sanity \
check.<br><br><br>>> Perhaps a better approach is to check the existence of \
what's specified in<br>>> the "rdinit" parameter \
instead.<br>><br>> That would introduce an additional dependency on /proc being \
mounted and<br>> require additional parsing. I don't think the check is that \
necessary,<br>> again because we have the /-is-ramfs-or-tmpfs check. But if you do \
think<br>> we need it I can rewrite the patch to check for rdinit= on cmdline as \
well.<br>><br><br>/proc should be mounted by most init systems anyway. But we can \
skip the check when /proc doesn't exist, just in case.<br><br>The logic would be \
roughly like this:<br><br>If "/proc/cmdline" exists<br> Read the \
"rdinit" parameter from "/proc/cmdline"; if it's unspecified, \
default to "/init"<br> If the file in "rdinit" doesn't \
exist, stop.<br>Else<br> Skip the "rdinit" existence check and \
continue the switch_root process<br>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic