[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 &lt;<a \
href="mailto:git@sphalerite.org">git@sphalerite.org</a>&gt; 於 2024年4月23日 \
星期二寫道:<br>&gt;<br>&gt; I don&#39;t really see the existence of /init \
being so critical for<br>&gt; this check given that we check below that it&#39;s a \
ramfs or tmpfs, which<br>&gt; seems to me to be enough that people won&#39;t be \
destroying filesystems<br>&gt; they cared a great deal about.<br>&gt;<br><br>The \
ramfs/tmpfs check was good as it won&#39;t destroy any _permanent_ file the user \
could have, but it wouldn&#39;t hurt either when there is another sanity \
check.<br><br><br>&gt;&gt; Perhaps a better approach is to check the existence of \
what&#39;s specified in<br>&gt;&gt; the &quot;rdinit&quot; parameter \
instead.<br>&gt;<br>&gt; That would introduce an additional dependency on /proc being \
mounted and<br>&gt; require additional parsing. I don&#39;t think the check is that \
necessary,<br>&gt; again because we have the /-is-ramfs-or-tmpfs check. But if you do \
think<br>&gt; we need it I can rewrite the patch to check for rdinit= on cmdline as \
well.<br>&gt;<br><br>/proc should be mounted by most init systems anyway. But we can \
skip the check when /proc doesn&#39;t exist, just in case.<br><br>The logic would be \
roughly like this:<br><br>If &quot;/proc/cmdline&quot; exists<br>      Read the \
&quot;rdinit&quot; parameter from &quot;/proc/cmdline&quot;; if it&#39;s unspecified, \
default to &quot;/init&quot;<br>      If the file in &quot;rdinit&quot; doesn&#39;t \
exist, stop.<br>Else<br>      Skip the &quot;rdinit&quot; 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