env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Since commit 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set") a warning message is displayed when setenv -f is used WITHOUT CONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate() returns 0 if the access is accepted, or non zero if it is refused.
So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endif
was correct, it returns 0 (accepts the modification) if forced UNLESS IGNORE_FORCE is set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.
To obtain the intent of the patch we need this:
if (flag & H_FORCE) {
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE
printf("## Error: Can't force access to \"%s\"\n", name);
#else
return 0;
#endif
}--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
env/flags.c +3 -2
@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif + }switch (op) {case env_op_delete:if (item->flags &ENV_FLAGS_VARACCESS_PREVENT_DELETE ) {
Signature · 1 line
1.9.1
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 45 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-1@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) {
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 575
Quoted 10 lines
env/flags.c +3
-1+#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif + }switch (op) {case env_op_delete:if (item->flags &ENV_FLAGS_VARACCESS_PREVENT_DELETE ) {
Marek, does this look right to you? Heinrich, I think this means there''s a follow-up commit that I made to one of the tests that can probably be reverted as well? Thanks for digging in to this Martin!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210115/15268e04/attachment.sig>
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 45 lines · Tom Rini
Quoted 43 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif
Quoted 16 lines
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 575
Quoted 12 lines
env/flags.c +3
-2-#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif + }switch (op) {case env_op_delete:if (item->flags &ENV_FLAGS_VARACCESS_PREVENT_DELETE ) {Marek, does this look right to you? Heinrich, I think this means there''s a follow-up commit that I made to one of the tests that can probably be reverted as well? Thanks for digging in to this Martin!
Marek? Heinrich? I really want a little feedback on this patch since I think it addresses a tricky problem. Thanks.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210128/947c0eef/attachment.sig>
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
In reply to Martin Fuzzeyenv/flags.c int env_flags_validate(const struct env_entry *item, const char *newval,
Quoted 40 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,
Please, add a Sphinx style function description in include/env_flags.h explaining exactly what this function is meant to do.
Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 568
Quoted 7 lines
env/flags.c +1
-1return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name);
If this is an error, why don't you return 1 (failure)? Please, use log_err() for error messages.
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 2 lines
env/flags.c +1
-0+#else return 0 ;
Why shouldn't the other tests be executed?
Best regards
Heinrich
Quoted 7 lines
env/flags.c +1
-1- }#endif + }switch (op) {case env_op_delete:if (item->flags &ENV_FLAGS_VARACCESS_PREVENT_DELETE ) {
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
On 1/28/21 10:11 AM, Heinrich Schuchardt wrote:
[...]
Quoted 11 lines
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval,
Quoted 5 lines
env/flags.c +0
-0@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,Please, add a Sphinx style function description in
include/env_flags.hexplaining exactly what this function is meant to do.Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
This is irrelevant, it's a bugfix so docs/improvements are a separate patch.
Quoted 11 lines
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 568
Quoted 7 lines
env/flags.c +1
-1return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name);If this is an error, why don't you return 1 (failure)? Please, use
log_err()for error messages.
Quoted 4 lines
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 2 lines
env/flags.c +1
-0+#else return 0 ;Why shouldn't the other tests be executed?
Because the code is a total mess and thus error prone.
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
In reply to Martin FuzzeyQuoted 41 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;
env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 571
Quoted 10 lines
env/flags.c +2
-2#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif
Based on env/Kconfig description of this option:
config ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations" default n
help
If defined, don't allow the -f switch to env set override
variable
access flags.
I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE
if (flag & H_FORCE) {
printf("## Error: Can't force access to \"%s\"\n", name);
return 1;
}#else
if (flag & H_FORCE)
return 0;
#endif
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 68 lines · Marek Vasut
Quoted 40 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 10 lines
env/flags.c +2
-2@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations"
default n
help
If defined, don't allow the -f switch to env set override variable access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }
Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endif
So, prior to 0f036bf4b87e we had what you're suggesting, and that lead to 8a5cdf601f8d (which is the commit I was trying to think of) which Heinrich did not like, but was what was needed to get things to function again. Wouldn't what you're proposing break the use case you had in the first place?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210128/3575122d/attachment.sig>
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 74 lines · Tom Rini
Quoted 68 lines · Marek Vasut
Quoted 40 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 10 lines
env/flags.c +2
-2@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations"
default n
help
If defined, don't allow the -f switch to env set override variable access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endif
Quoted 5 lines
So, prior to
0f036bf4b87ewe had what you're suggesting, and that lead to8a5cdf601f8d(which is the commit I was trying to think of) which Heinrich did not like, but was what was needed to get things to function again. Wouldn't what you're proposing break the use case you had in the first place?
No, the idea is to completely block the -f flag if CONFIG_ENV_ACCESS_IGNORE_FORCE is set from setting anything in the environment. That's how I understand the Kconfig entry help text.
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 81 lines · Marek Vasut
Quoted 74 lines · Tom Rini
Quoted 68 lines · Marek Vasut
Quoted 40 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 10 lines
env/flags.c +2
-2@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations"
default n
help
If defined, don't allow the -f switch to env set override variable access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endifQuoted 5 lines
So, prior to
0f036bf4b87ewe had what you're suggesting, and that lead to8a5cdf601f8d(which is the commit I was trying to think of) which Heinrich did not like, but was what was needed to get things to function again. Wouldn't what you're proposing break the use case you had in the first place?
Quoted 3 lines
No, the idea is to completely block the -f flag if
CONFIG_ENV_ACCESS_IGNORE_FORCEis set from setting anything in the environment. That's how I understand theKconfigentry help text.
So was this all a "by inspection" bug then and not something you ran in to in use? I'm a bit worried that "how it's implemented" is relied upon more than "how it's documented in the help", esp since the former is probably older than the latter.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210201/a4b49527/attachment.sig>
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 82 lines · Tom Rini
Quoted 81 lines · Marek Vasut
Quoted 79 lines · Tom Rini
Quoted 68 lines · Marek Vasut
Quoted 40 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>--- env/flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)env/flags.c +0
-0env/flags.c int env_flags_validate(const struct env_entry *item, const char *newval, · line 570
Quoted 10 lines
env/flags.c +2
-2@@ -563,12 +563,13 @@ int env_flags_validate(const struct env_entry *item, const char *newval,return 1 ;#endif -#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag &H_FORCE ) { +#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf ("## Error: Can't force access to \"%s\"\n" , name); +#else return 0 ; - }#endif Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations"
default n
help
If defined, don't allow the -f switch to env set override variable access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endifSo, prior to
0f036bf4b87ewe had what you're suggesting, and that lead to8a5cdf601f8d(which is the commit I was trying to think of) which Heinrich did not like, but was what was needed to get things to function again. Wouldn't what you're proposing break the use case you had in the first place?
Quoted 8 lines
Quoted 3 lines
No, the idea is to completely block the -f flag if
CONFIG_ENV_ACCESS_IGNORE_FORCEis set from setting anything in the environment. That's how I understand theKconfigentry help text.So was this all a "by inspection" bug then and not something you ran in to in use? I'm a bit worried that "how it's implemented" is relied upon more than "how it's documented in the help", esp since the former is probably older than the latter.
The usecase of the writeable list is to completely block the -f flag. Maybe some further cleanup of the env config options is required, because it is poorly documented it seems.
Fuzzey
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
In reply to Marek VasutHi Marek,
Quoted 18 lines · Marek Vasut
Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations" default n
help
If defined, don't allow the -f switch to env set override
variable
access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }
Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endif
I don't think that is right.
If you do that force update will be refused when CONFIG_ENV_ACCESS_IGNORE_FORCE, regardless if the access would be valid without the force
The kconfig options says don't allow the -f switch to OVERRIDE variable access flags, not "don't allow the -f switch to be used"
I think we want this truth table
-f used ENV_ACCESS_IGNORE _FORCE Access valid ====> result
N X
N refused
N X
Y accepted
Y N
Y accepted
Y N
N accepted (forced)
Y Y
Y accepted
Y Y
N refused with warning
Regards,
Martin
Signature · 5 lines
Martin Fuzzey | Software Architect Transport Intelligence Division Parc La Fayette - 6 rue Isaac Newton | Besan?on | 25075 | FR Office: +33381546880 Mobile: +33677158582 martin.fuzzey at flowbird.group | www.flowbird.group/transport
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 1 line · Martin
Hi Marek,
Hi,
Quoted 24 lines · Marek Vasut
Quoted 18 lines
Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations" default n
help
If defined, don't allow the -f switch to env set override
variable
access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }Quoted 4 lines
#else
if (flag &H_FORCE)
return 0;
#endif
Quoted 5 lines
I don't think that is right.
If you do that force update will be refused when
CONFIG_ENV_ACCESS_IGNORE_FORCE, regardless if the access would be valid without the force
That's how I understand the option was intended to work, based on the Kconfig help text.
Quoted 2 lines
The kconfig options says don't allow the -f switch to OVERRIDE variable access flags, not "don't allow the -f switch to be used"
I suspect the help text needs clarification then.
Fuzzey
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 30 lines · Marek Vasut
Quoted 1 line · Martin
Hi Marek,
Hi,
Quoted 24 lines · Marek Vasut
Quoted 22 lines
Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations" default n
help
If defined, don't allow the -f switch to env set override
variable
access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }#else
if (flag &H_FORCE)
return 0;
#endif
Quoted 9 lines
Quoted 5 lines
I don't think that is right.
If you do that force update will be refused when
CONFIG_ENV_ACCESS_IGNORE_FORCE, regardless if the access would be valid without the forceThat's how I understand the option was intended to work, based on the
Kconfighelp text.
Ok we are understanding different things about what it's supposed to do then.
But if everyone agrees that the option should completely disable -f then I'm fine with that, in which case the version of the patch you propose is good (and easier to understand).
The problem I have is with the current 0f036bf4b87e which leads to log spam on boards that *don't* have CONFIG_ENV_ACCESS_IGNORE_FORCE set and do use -f.
Quoted 4 lines
Quoted 2 lines
The kconfig options says don't allow the -f switch to OVERRIDE variable access flags, not "don't allow the -f switch to be used"
I suspect the help text needs clarification then.
Agreed
Martin
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
Quoted 43 lines · Martin
Quoted 30 lines · Marek Vasut
Quoted 1 line · Martin
Hi Marek,
Hi,
Quoted 24 lines · Marek Vasut
Quoted 22 lines
Based on env/Kconfig description of this option:
config
ENV_ACCESS_IGNORE_FORCE
bool "Block forced environment operations" default n
help
If defined, don't allow the -f switch to env set override
variable
access flags.I would think the code should look like this:
#ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) { printf("## Error: Can't force access to \"%s\"\n", name); return 1; }#else
if (flag &H_FORCE)
return 0;
#endifQuoted 9 lines
Quoted 5 lines
I don't think that is right.
If you do that force update will be refused when
CONFIG_ENV_ACCESS_IGNORE_FORCE, regardless if the access would be valid without the forceThat's how I understand the option was intended to work, based on the
Kconfighelp text.Ok we are understanding different things about what it's supposed to do then.
Quoted 7 lines
But if everyone agrees that the option should completely disable -f then I'm fine with that, in which case the version of the patch you propose is good (and easier to understand).
The problem I have is with the current
0f036bf4b87ewhich leads to log spam on boards that *don't* haveCONFIG_ENV_ACCESS_IGNORE_FORCEset and do use -f.
Yes, that should be fixed, one way or the other. (in fact, can you also write a test for this case ?)
PATCH 1/1 env: Fix warning when forcing environment without ENV_ACCESS_IGNORE_FORCE
In reply to Martin FuzzeyQuoted 28 lines · Martin Fuzzey
Since commit
0f036bf4b87e("env: Warn on force access ifENV_ACCESS_IGNORE_FORCEset") a warning message is displayed when setenv -f is used WITHOUTCONFIG_ENV_ACCESS_IGNORE_FORCE, but the variable is set anyway, resulting in lots of log pollution.
env_flags_validate()returns 0 if the access is accepted, or non zero if it is refused.So the original code
#ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE if (flag & H_FORCE) return 0; #endifwas correct, it returns 0 (accepts the modification) if forced UNLESS
IGNORE_FORCEis set (in which case access checks in the following code are applied). The broken patch just added a printf to the force accepted case.To obtain the intent of the patch we need this:
if (flag & H_FORCE) { #ifdef CONFIG_ENV_ACCESS_IGNORE_FORCE printf("## Error: Can't force access to \"%s\"\n", name); #else return 0; #endif }
Quoted 3 lines
Fixes 0f036bf4b87e ("env: Warn on force access if ENV_ACCESS_IGNORE_FORCE set")Signed-off-by Martin Fuzzey <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210418/9f8bc0d5/attachment.sig>