[PATCH 1/3] startup: check for console before showing menu
Fabian Pflug
f.pflug at pengutronix.de
Tue Oct 28 06:43:06 PDT 2025
Hello Ahmad,
On Tue, 2025-10-28 at 13:39 +0100, Ahmad Fatoum wrote:
> Hi Fabian,
>
> On 10/28/25 1:18 PM, Fabian Pflug wrote:
> > If there is no input available or possible due to policy settings, it
> > does not make sense to show a menu and ask for input.
> >
> > Signed-off-by: Fabian Pflug <f.pflug at pengutronix.de>
> > ---
> > common/startup.c | 18 ++++++++++--------
> > 1 file changed, 10 insertions(+), 8 deletions(-)
> >
> > diff --git a/common/startup.c b/common/startup.c
> > index 8d36ffceb4..3bc2609006 100644
> > --- a/common/startup.c
> > +++ b/common/startup.c
> > @@ -45,6 +45,7 @@
> > #include <pbl/handoff-data.h>
> > #include <libfile.h>
> > #include <fuzz.h>
> > +#include <security/config.h>
> >
> > extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
> > __barebox_initcalls_end[];
> > @@ -361,14 +362,15 @@ static int run_init(void)
> > run_shell();
> > }
> >
> > - do {
> > - /*
> > - * Let's run the command once at least, so an error
> > - * message is printed if the file doesn't exist
> > - */
> > - run_command(MENUFILE);
> > - } while (stat(MENUFILE, &s) == 0);
> > -
> > + if(!IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT) && IS_ALLOWED(SCONFIG_CONSOLE_INPUT)) {
>
> CONFIG_CONSOLE_DISABLE_INPUT only influences the default, it can still
> be changed later at runtime, so this is not necessarily correct.
>
> > + do {
>
> Move the IS_ALLOWED(SCONFIG_CONSOLE_INPUT) check here?
>
> Feels more natural to do it in the loop than outside. Extra benefit: We
> could use it for testing purposes (Menu entry that locks the console..)
I see the extra benefit for testing the console, but at this point, if there is no input possible, then we cannot enter
something into the console. The menu is a new screen on the device, which makes it hard to read the possible error
messages before going to console here, because the security policy did something during development, that was not
intended. I would love to have the system hang here instead and tell me as much.
I will not stop you in implementing it differently, but I will not do that.
Kind regards
Fabian
>
> Cheers,
> Ahmad
>
> > + /*
> > + * Let's run the command once at least, so an error
> > + * message is printed if the file doesn't exist
> > + */
> > + run_command(MENUFILE);
> > + } while (stat(MENUFILE, &s) == 0);
> > + }
> > hang();
> > }
> >
More information about the barebox
mailing list