All of lore.kernel.org
 help / color / mirror / Atom feed
* U-Boot environment management from userspace
@ 2019-05-28 18:40 Vernon Mauery
  2019-05-29 15:26 ` Thomaiyar, Richard Marian
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vernon Mauery @ 2019-05-28 18:40 UTC (permalink / raw)
  To: OpenBMC Development

Reading U-Boot environment variables from userspace is not difficult, 
but to do it in a standard way, (fw_printenv), it requires a fork and 
exec. We don't have any permissions problems because reading from the 
MTD partition is not restricted. It might be nice, however to have these 
variables exported on D-Bus so that a fork/exec is not necessary, just a 
property fetch.

But writing is a different story. That requires root privileges. To 
architect with a separation of privileges mechanism, this should 
probably be running as a daemon or service that could be spawned via 
D-Bus or something so that ipmid doesn't need root permission to set a 
U-Boot variable.

I see a couple of options:
1) Shoehorn U-Boot variables into the settings daemon so they just show 
up as settings. I am not sure on the details of how this would be done, 
but it might work.

2) Create yet another daemon that would provide a R/W interface 
(probably just using the D-Bus properties interface) that would act as a 
manager of U-Boot environment variables. It might even be able to place 
an inotify watch to get notified when an external process (fw_setenv) 
modifies the environment (like from a script or something) so the D-Bus 
properties could send out a PropertiesChanged notification.

3) Use a one-shot service that parses the 'instance' to extract a 
variable name and variable value. Then the variable could be activated 
by launching ubootenv@foo=bar.service. This would require some fancy 
parameter encoding to make it all work correctly to avoid string 
injections. 

Am I the only one that has a need for this or is there a wider audience 
that would benefit?

Does anyone else already have a solution for this or an opinion on what 
path might be the best?

--Vernon

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

* Re: U-Boot environment management from userspace
  2019-05-28 18:40 U-Boot environment management from userspace Vernon Mauery
@ 2019-05-29 15:26 ` Thomaiyar, Richard Marian
  2019-05-29 15:30 ` Adriana Kobylak
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Thomaiyar, Richard Marian @ 2019-05-29 15:26 UTC (permalink / raw)
  To: openbmc

Vernon,

I just started a daemon for the same as i needed it for RestrictionMode 
(provisioning) . At this point of time, the daemon uses the fw_setenv & 
printenv internally, but atleast application will access the same in D-Bus

Regards,

Richard

On 5/29/2019 12:10 AM, Vernon Mauery wrote:
> Reading U-Boot environment variables from userspace is not difficult, 
> but to do it in a standard way, (fw_printenv), it requires a fork and 
> exec. We don't have any permissions problems because reading from the 
> MTD partition is not restricted. It might be nice, however to have 
> these variables exported on D-Bus so that a fork/exec is not 
> necessary, just a property fetch.
>
> But writing is a different story. That requires root privileges. To 
> architect with a separation of privileges mechanism, this should 
> probably be running as a daemon or service that could be spawned via 
> D-Bus or something so that ipmid doesn't need root permission to set a 
> U-Boot variable.
>
> I see a couple of options:
> 1) Shoehorn U-Boot variables into the settings daemon so they just 
> show up as settings. I am not sure on the details of how this would be 
> done, but it might work.
>
> 2) Create yet another daemon that would provide a R/W interface 
> (probably just using the D-Bus properties interface) that would act as 
> a manager of U-Boot environment variables. It might even be able to 
> place an inotify watch to get notified when an external process 
> (fw_setenv) modifies the environment (like from a script or something) 
> so the D-Bus properties could send out a PropertiesChanged notification.
>
> 3) Use a one-shot service that parses the 'instance' to extract a 
> variable name and variable value. Then the variable could be activated 
> by launching ubootenv@foo=bar.service. This would require some fancy 
> parameter encoding to make it all work correctly to avoid string 
> injections.
> Am I the only one that has a need for this or is there a wider 
> audience that would benefit?
>
> Does anyone else already have a solution for this or an opinion on 
> what path might be the best?
>
> --Vernon

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

* Re: U-Boot environment management from userspace
  2019-05-28 18:40 U-Boot environment management from userspace Vernon Mauery
  2019-05-29 15:26 ` Thomaiyar, Richard Marian
@ 2019-05-29 15:30 ` Adriana Kobylak
  2019-05-30 17:20   ` Vernon Mauery
  2019-05-30 17:25 ` Ed Tanous
  2019-05-31  0:35 ` Joel Stanley
  3 siblings, 1 reply; 9+ messages in thread
From: Adriana Kobylak @ 2019-05-29 15:30 UTC (permalink / raw)
  To: Vernon Mauery; +Cc: OpenBMC Development, openbmc

> Am I the only one that has a need for this or is there a wider
> audience that would benefit?

The software manager (phosphor-bmc-code-mgmt) relies on U-Boot 
environment
variables for managing the images like for determining which image to 
boot
from.

> 3) Use a one-shot service that parses the 'instance' to extract a
> variable name and variable value. Then the variable could be activated
> by launching ubootenv@foo=bar.service. This would require some fancy
> parameter encoding to make it all work correctly to avoid string
> injections.

Yeah, we went that route with an obmc-flash-bmc-setenv@.service[1], with
like you mentioned uses some 'fancy parameter encoding', ex:
"obmc-flash-bmc-setenv@" + entryId + "\\x3d" + std::to_string(value) + 
".service";

This has worked so far but I'd be open on having a mapping of the env
variables to D-Bus properties.

> Reading U-Boot environment variables from userspace is not difficult,
> but to do it in a standard way, (fw_printenv), it requires a fork and
> exec.

We're actually reading the mtd device to get the values of the variables
to avoid having a 'system' or 'fork/exec' call, then we put those values
in D-Bus properties under the software/ path. Having some other app do 
that
parsing would be nice especially if we're to expand the use of the 
U-Boot
env vars.

---
[1] 
https://github.com/openbmc/phosphor-bmc-code-mgmt/blob/master/obmc-flash-bmc-setenv%40.service

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

* Re: U-Boot environment management from userspace
  2019-05-29 15:30 ` Adriana Kobylak
@ 2019-05-30 17:20   ` Vernon Mauery
  2019-06-05 12:35     ` Brad Bishop
  0 siblings, 1 reply; 9+ messages in thread
From: Vernon Mauery @ 2019-05-30 17:20 UTC (permalink / raw)
  To: Adriana Kobylak; +Cc: OpenBMC Development, openbmc

On 29-May-2019 10:30 AM, Adriana Kobylak wrote:
>>Am I the only one that has a need for this or is there a wider
>>audience that would benefit?
>
>The software manager (phosphor-bmc-code-mgmt) relies on U-Boot 
>environment
>variables for managing the images like for determining which image to 
>boot
>from.
>
>>3) Use a one-shot service that parses the 'instance' to extract a
>>variable name and variable value. Then the variable could be activated
>>by launching ubootenv@foo=bar.service. This would require some fancy
>>parameter encoding to make it all work correctly to avoid string
>>injections.
>
>Yeah, we went that route with an obmc-flash-bmc-setenv@.service[1], with
>like you mentioned uses some 'fancy parameter encoding', ex:
>"obmc-flash-bmc-setenv@" + entryId + "\\x3d" + std::to_string(value) + 
>".service";
>
>This has worked so far but I'd be open on having a mapping of the env
>variables to D-Bus properties.
>
>>Reading U-Boot environment variables from userspace is not difficult,
>>but to do it in a standard way, (fw_printenv), it requires a fork and
>>exec.
>
>We're actually reading the mtd device to get the values of the variables
>to avoid having a 'system' or 'fork/exec' call, then we put those values
>in D-Bus properties under the software/ path. Having some other app do 
>that
>parsing would be nice especially if we're to expand the use of the 
>U-Boot
>env vars.
>
>---
>[1] https://github.com/openbmc/phosphor-bmc-code-mgmt/blob/master/obmc-flash-bmc-setenv%40.service
>
>

Brad,

It sounds like Intel is not the only ones that might benefit from a 
service like this, so it might be a good time for a new project/repo. 

Could you create a new repo for us: phosphor-u-boot-env-mgr

--Vernon

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

* Re: U-Boot environment management from userspace
  2019-05-28 18:40 U-Boot environment management from userspace Vernon Mauery
  2019-05-29 15:26 ` Thomaiyar, Richard Marian
  2019-05-29 15:30 ` Adriana Kobylak
@ 2019-05-30 17:25 ` Ed Tanous
  2019-05-31  0:35 ` Joel Stanley
  3 siblings, 0 replies; 9+ messages in thread
From: Ed Tanous @ 2019-05-30 17:25 UTC (permalink / raw)
  To: openbmc

On 5/28/19 11:40 AM, Vernon Mauery wrote:
> 
> 2) Create yet another daemon that would provide a R/W interface
> (probably just using the D-Bus properties interface) that would act as a
> manager of U-Boot environment variables. It might even be able to place
> an inotify watch to get notified when an external process (fw_setenv)
> modifies the environment (like from a script or something) so the D-Bus
> properties could send out a PropertiesChanged notification.

This would be my preference.  It keeps the functionality self contained,
and allows at least some security around adjusting parameters, given
that said daemon could whitelist/blacklist certain parameters at some
point in the future.

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

* Re: U-Boot environment management from userspace
  2019-05-28 18:40 U-Boot environment management from userspace Vernon Mauery
                   ` (2 preceding siblings ...)
  2019-05-30 17:25 ` Ed Tanous
@ 2019-05-31  0:35 ` Joel Stanley
  3 siblings, 0 replies; 9+ messages in thread
From: Joel Stanley @ 2019-05-31  0:35 UTC (permalink / raw)
  To: Vernon Mauery; +Cc: OpenBMC Development

On Tue, 28 May 2019 at 18:41, Vernon Mauery
<vernon.mauery@linux.intel.com> wrote:
>
> Reading U-Boot environment variables from userspace is not difficult,
> but to do it in a standard way, (fw_printenv), it requires a fork and
> exec.

I came across libubootenv the other day. Whatever solution you come up
with to manage the variables could use this library. It's in
tools/env/ in the u-boot sources.

I would caution against the u-boot environment being used as a general
purpose settings store. We should use it for configuring u-boot, and
keep other settings somewhere else in the system.

Cheers,

Joel

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

* Re: U-Boot environment management from userspace
  2019-05-30 17:20   ` Vernon Mauery
@ 2019-06-05 12:35     ` Brad Bishop
  2019-06-05 15:27       ` krtaylor
  2019-06-12 21:00       ` Brad Bishop
  0 siblings, 2 replies; 9+ messages in thread
From: Brad Bishop @ 2019-06-05 12:35 UTC (permalink / raw)
  To: Vernon Mauery, Adriana Kobylak; +Cc: OpenBMC Development

Hi Vernon

> Brad,
> 
> It sounds like Intel is not the only ones that might benefit from a 
> service like this, so it might be a good time for a new
> project/repo. 
> 
> Could you create a new repo for us: phosphor-u-boot-env-mgr

Will do.

It sounds like you are working on something that needs a new repo, will
generate a new dbus API and have applications providing and consuming
that API.  That sounds like a non-trivial enhancement to OpenBMC.

Please consider having someone submit a completed design template and
opening a github issue.  This enables the rest of the community to know
what Intel is working on and when, and thus have input, possibly help,
and avoid duplicate work.  Please let me know if any of my thinking
here is flawed.

thx - brad

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

* Re: U-Boot environment management from userspace
  2019-06-05 12:35     ` Brad Bishop
@ 2019-06-05 15:27       ` krtaylor
  2019-06-12 21:00       ` Brad Bishop
  1 sibling, 0 replies; 9+ messages in thread
From: krtaylor @ 2019-06-05 15:27 UTC (permalink / raw)
  To: Brad Bishop, Vernon Mauery, Adriana Kobylak; +Cc: OpenBMC Development

On 6/5/19 7:35 AM, Brad Bishop wrote:
> Hi Vernon
> 
>> Brad,
>>
>> It sounds like Intel is not the only ones that might benefit from a
>> service like this, so it might be a good time for a new
>> project/repo.
>>
>> Could you create a new repo for us: phosphor-u-boot-env-mgr
> 
> Will do.
> 
> It sounds like you are working on something that needs a new repo, will
> generate a new dbus API and have applications providing and consuming
> that API.  That sounds like a non-trivial enhancement to OpenBMC.

Yes. Non trivial changes require designs.

> Please consider having someone submit a completed design template and
> opening a github issue.  This enables the rest of the community to know
> what Intel is working on and when, and thus have input, possibly help,
> and avoid duplicate work.  Please let me know if any of my thinking
> here is flawed.

Not flawed at all. It has been discussed and agreed upon by all 
participating companies. It also greatly reduces the review time for new 
features being contributed, because the community already knows what to 
expect.

Kurt Taylor (krtaylor)

> 
> thx - brad
> 

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

* Re: U-Boot environment management from userspace
  2019-06-05 12:35     ` Brad Bishop
  2019-06-05 15:27       ` krtaylor
@ 2019-06-12 21:00       ` Brad Bishop
  1 sibling, 0 replies; 9+ messages in thread
From: Brad Bishop @ 2019-06-12 21:00 UTC (permalink / raw)
  To: Vernon Mauery, Adriana Kobylak; +Cc: OpenBMC Development

On Wed, Jun 05, 2019 at 08:35:16AM -0400, Brad Bishop wrote:
>Hi Vernon
>
>> Brad,
>>
>> It sounds like Intel is not the only ones that might benefit from a
>> service like this, so it might be a good time for a new
>> project/repo.
>>
>> Could you create a new repo for us: phosphor-u-boot-env-mgr
>
>Will do.
>
>It sounds like you are working on something that needs a new repo, will
>generate a new dbus API and have applications providing and consuming
>that API.  That sounds like a non-trivial enhancement to OpenBMC.
>
>Please consider having someone submit a completed design template and
>opening a github issue.  This enables the rest of the community to know
>what Intel is working on and when, and thus have input, possibly help,
>and avoid duplicate work.  Please let me know if any of my thinking
>here is flawed.
>
>thx - brad

Hi Vernon

I created this today.

I would still love to hear about what Intel is cooking up that would 
make use of this.

Thanks! - brad

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

end of thread, other threads:[~2019-06-12 20:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-28 18:40 U-Boot environment management from userspace Vernon Mauery
2019-05-29 15:26 ` Thomaiyar, Richard Marian
2019-05-29 15:30 ` Adriana Kobylak
2019-05-30 17:20   ` Vernon Mauery
2019-06-05 12:35     ` Brad Bishop
2019-06-05 15:27       ` krtaylor
2019-06-12 21:00       ` Brad Bishop
2019-05-30 17:25 ` Ed Tanous
2019-05-31  0:35 ` Joel Stanley

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.