All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Protected variable 'ethaddr' can be reset to default value (or deleted)
@ 2014-05-28 10:28 Hector Palacios
  0 siblings, 0 replies; only message in thread
From: Hector Palacios @ 2014-05-28 10:28 UTC (permalink / raw)
  To: u-boot

Hello,

I have enabled environment flags and have protected "ethaddr" variable in write-once 
mode: "ethaddr:mo".

As expected, once set, I cannot overwrite this variable with standard setenv command.
Also as expected, I can overwrite it at any time by passing the -f (forced) option to 
setenv:
	setenv -f ethaddr XX:XX:XX:XX:XX:XX

The 'env default' command is supposed to reset the environment to the default values. 
Its help is:

env default [-f] -a - [forcibly] reset default environment
env default [-f] var [...] - [forcibly] reset variable(s) to their default values

So I expect that 'env default ethaddr' does not change the value of 'ethaddr' (which 
actually occurs) because the variable is protected, but that adding the -f option does 
change the value to the default (which doesn't occur). In other words:

   env default ethaddr		Does not change 'ethaddr' (OK)
   env default -f ethaddr	Does not change 'ethaddr' (Problem #1)

Similarly, I was also expecting that 'env default -a', which resets the whole 
environment to its default values, does not modify protected 'ethaddr' (like it 
happens when you specify the variable) and that 'env default -f -a' resets it. 
However, both commands do reset the protected variables. In other words:

   env default -a		Changes/deletes 'ethaddr' (Problem #2)
   env default -f -a		Changes/deletes 'ethaddr' (OK)

Actually the '-f' option, despite being in the help text is not taken into 
consideration at the 'default' subcommand. This can easily be checked in function 
do_env_default() in common/cmd_nvedit.c, where the local variable 'flag' is not 
propagated anywhere in the function.

I can easily fix Problem #1 by propagating local variable 'flag' in do_env_default() 
to set_default_vars().

Problem #2 is more difficult because U-Boot is creating a new env table from scratch, 
disregarding previous existing entries, and calling env_flags_validate() in 
'env_op_create' mode, which only checks for ENV_FLAGS_VARACCESS_PREVENT_CREATE permission.
Any ideas on how to properly fix this?

Best regards,
--
Hector Palacios

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-28 10:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-28 10:28 [U-Boot] Protected variable 'ethaddr' can be reset to default value (or deleted) Hector Palacios

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.