mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
@ 2026-01-14 22:02 Harry Austen
  2026-01-15  2:47 ` Andrew Morton
  2026-01-15 20:02 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Harry Austen @ 2026-01-14 22:02 UTC (permalink / raw)
  To: Andrew Morton, Huacai Chen; +Cc: linux-kernel, Lillian Berry, Harry Austen

If rdinit was not explicitly provided on cmdline, and default /init does
not exist, no warning should be printed.

Fixes: 98aa4d5d242d ("init/main.c: add warning when file specified in rdinit is inaccessible")
Signed-off-by: Harry Austen <hpausten@protonmail.com>
---
 init/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index b84818ad9685f..fcf99d1adbe02 100644
--- a/init/main.c
+++ b/init/main.c
@@ -162,6 +162,7 @@ static size_t initargs_offs;
 
 static char *execute_command;
 static char *ramdisk_execute_command = "/init";
+static bool __initdata ramdisk_execute_command_provided = false;
 
 /*
  * Used to generate warnings if static_key manipulation functions are used
@@ -623,6 +624,7 @@ static int __init rdinit_setup(char *str)
 	unsigned int i;
 
 	ramdisk_execute_command = str;
+	ramdisk_execute_command_provided = true;
 	/* See "auto" comment in init_setup */
 	for (i = 1; i < MAX_INIT_ARGS; i++)
 		argv_init[i] = NULL;
@@ -1699,8 +1701,9 @@ static noinline void __init kernel_init_freeable(void)
 	int ramdisk_command_access;
 	ramdisk_command_access = init_eaccess(ramdisk_execute_command);
 	if (ramdisk_command_access != 0) {
-		pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
-			ramdisk_execute_command, ramdisk_command_access);
+		if (ramdisk_execute_command_provided || ramdisk_command_access != -ENOENT)
+			pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
+				ramdisk_execute_command, ramdisk_command_access);
 		ramdisk_execute_command = NULL;
 		prepare_namespace();
 	}
-- 
2.52.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
  2026-01-14 22:02 [PATCH] init/main.c: prevent warning on lack of default implicit rdinit Harry Austen
@ 2026-01-15  2:47 ` Andrew Morton
  2026-01-15  7:32   ` Harry Austen
  2026-01-15 20:02 ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2026-01-15  2:47 UTC (permalink / raw)
  To: Harry Austen; +Cc: Huacai Chen, linux-kernel, Lillian Berry

On Wed, 14 Jan 2026 22:02:27 +0000 Harry Austen <hpausten@protonmail.com> wrote:

> If rdinit was not explicitly provided on cmdline, and default /init does
> not exist, no warning should be printed.
> 
> Fixes: 98aa4d5d242d ("init/main.c: add warning when file specified in rdinit is inaccessible")

Details, please?  What was wrong about the above commit?

> --- a/init/main.c
> +++ b/init/main.c
> @@ -162,6 +162,7 @@ static size_t initargs_offs;
>  
>  static char *execute_command;
>  static char *ramdisk_execute_command = "/init";
> +static bool __initdata ramdisk_execute_command_provided = false;
>  
>  /*
>   * Used to generate warnings if static_key manipulation functions are used
> @@ -623,6 +624,7 @@ static int __init rdinit_setup(char *str)
>  	unsigned int i;
>  
>  	ramdisk_execute_command = str;
> +	ramdisk_execute_command_provided = true;
>  	/* See "auto" comment in init_setup */
>  	for (i = 1; i < MAX_INIT_ARGS; i++)
>  		argv_init[i] = NULL;
> @@ -1699,8 +1701,9 @@ static noinline void __init kernel_init_freeable(void)
>  	int ramdisk_command_access;
>  	ramdisk_command_access = init_eaccess(ramdisk_execute_command);
>  	if (ramdisk_command_access != 0) {
> -		pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
> -			ramdisk_execute_command, ramdisk_command_access);
> +		if (ramdisk_execute_command_provided || ramdisk_command_access != -ENOENT)
> +			pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
> +				ramdisk_execute_command, ramdisk_command_access);

Replacing the !=0 check with !=ENOENT appears to be off-topic.  What's
happening here?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
  2026-01-15  2:47 ` Andrew Morton
@ 2026-01-15  7:32   ` Harry Austen
  0 siblings, 0 replies; 6+ messages in thread
From: Harry Austen @ 2026-01-15  7:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Huacai Chen, linux-kernel, Lillian Berry

On Thursday, 15 January 2026 at 02:47, Andrew Morton <akpm@linux-foundation.org> wrote:

> 
> 
> On Wed, 14 Jan 2026 22:02:27 +0000 Harry Austen hpausten@protonmail.com wrote:
> 
> > If rdinit was not explicitly provided on cmdline, and default /init does
> > not exist, no warning should be printed.
> > 
> > Fixes: 98aa4d5d242d ("init/main.c: add warning when file specified in rdinit is inaccessible")
> 
> 
> Details, please? What was wrong about the above commit?

The above commit introduced a warning regardless of whether rdinit execution
was actually wanted or not. If a system does not have the default /init file and
rdinit=* was not passed on the kernel cmdline, then it probably wasn't wanted.
This is the case on my personal system, i.e. after the above mentioned
commit, I now get the following logged by the kernel, at warning level:

check access for rdinit=/init failed: -2, ignoring

> 
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -162,6 +162,7 @@ static size_t initargs_offs;
> > 
> > static char *execute_command;
> > static char *ramdisk_execute_command = "/init";
> > +static bool __initdata ramdisk_execute_command_provided = false;
> > 
> > /*
> > * Used to generate warnings if static_key manipulation functions are used
> > @@ -623,6 +624,7 @@ static int __init rdinit_setup(char *str)
> > unsigned int i;
> > 
> > ramdisk_execute_command = str;
> > + ramdisk_execute_command_provided = true;
> > /* See "auto" comment in init_setup */
> > for (i = 1; i < MAX_INIT_ARGS; i++)
> > argv_init[i] = NULL;
> > @@ -1699,8 +1701,9 @@ static noinline void __init kernel_init_freeable(void)
> > int ramdisk_command_access;
> > ramdisk_command_access = init_eaccess(ramdisk_execute_command);
> > if (ramdisk_command_access != 0) {
> > - pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
> > - ramdisk_execute_command, ramdisk_command_access);
> > + if (ramdisk_execute_command_provided || ramdisk_command_access != -ENOENT)
> > + pr_warn("check access for rdinit=%s failed: %i, ignoring\n",
> > + ramdisk_execute_command, ramdisk_command_access);
> 
> 
> Replacing the !=0 check with !=ENOENT appears to be off-topic. What's
> happening here?

Note that it wasn't _replaced_. I have added an _extra_ check for file existence.

Thanks for the review,
Harry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
  2026-01-14 22:02 [PATCH] init/main.c: prevent warning on lack of default implicit rdinit Harry Austen
  2026-01-15  2:47 ` Andrew Morton
@ 2026-01-15 20:02 ` Andrew Morton
  2026-01-15 23:09   ` Harry Austen
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2026-01-15 20:02 UTC (permalink / raw)
  To: Harry Austen; +Cc: Huacai Chen, linux-kernel, Lillian Berry

On Wed, 14 Jan 2026 22:02:27 +0000 Harry Austen <hpausten@protonmail.com> wrote:

> If rdinit was not explicitly provided on cmdline, and default /init does
> not exist, no warning should be printed.

Seems that we already have a very similar patch from Lillian:

https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning.patch
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning-fix.patch

What's happening here?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
  2026-01-15 20:02 ` Andrew Morton
@ 2026-01-15 23:09   ` Harry Austen
  2026-01-15 23:28     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Harry Austen @ 2026-01-15 23:09 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Huacai Chen, linux-kernel, Lillian Berry

On Thursday, 15 January 2026 at 20:02, Andrew Morton <akpm@linux-foundation.org> wrote:

> 
> 
> On Wed, 14 Jan 2026 22:02:27 +0000 Harry Austen hpausten@protonmail.com wrote:
> 
> > If rdinit was not explicitly provided on cmdline, and default /init does
> > not exist, no warning should be printed.
> 
> 
> Seems that we already have a very similar patch from Lillian:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning.patch
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning-fix.patch
> 
> What's happening here?

Oh, interesting. Have those already been accepted? Looks like there's no
additional ENOENT check, so the warning gets printed even less often, which is fine by me.

Apologies for missing that this appears to have already been fixed and feel free
to ignore my patch.

Thanks,
Harry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] init/main.c: prevent warning on lack of default implicit rdinit
  2026-01-15 23:09   ` Harry Austen
@ 2026-01-15 23:28     ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2026-01-15 23:28 UTC (permalink / raw)
  To: Harry Austen; +Cc: Huacai Chen, linux-kernel, Lillian Berry

On Thu, 15 Jan 2026 23:09:07 +0000 Harry Austen <hpausten@protonmail.com> wrote:

> On Thursday, 15 January 2026 at 20:02, Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > 
> > 
> > On Wed, 14 Jan 2026 22:02:27 +0000 Harry Austen hpausten@protonmail.com wrote:
> > 
> > > If rdinit was not explicitly provided on cmdline, and default /init does
> > > not exist, no warning should be printed.
> > 
> > 
> > Seems that we already have a very similar patch from Lillian:
> > 
> > https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning.patch
> > https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/init-mainc-check-if-rdinit-was-explicitly-set-before-printing-warning-fix.patch
> > 
> > What's happening here?
> 
> Oh, interesting. Have those already been accepted?

They're in the mm.git queue for the next merge window.  As such they
are subject to test/review/alteration/dropping/etc.

> Looks like there's no
> additional ENOENT check, so the warning gets printed even less often, which is fine by me.
> 
> Apologies for missing that this appears to have already been fixed and feel free
> to ignore my patch.

OK, no probs, thanks, please send along any alterations to Lillian's
patch if you see a need.  linux-next would be a suitable base for
that.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-15 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-14 22:02 [PATCH] init/main.c: prevent warning on lack of default implicit rdinit Harry Austen
2026-01-15  2:47 ` Andrew Morton
2026-01-15  7:32   ` Harry Austen
2026-01-15 20:02 ` Andrew Morton
2026-01-15 23:09   ` Harry Austen
2026-01-15 23:28     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®