openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Kachalov <rnouse@google.com>
To: Ed Tanous <ed@tanous.net>
Cc: OpenBMC Maillist <openbmc@lists.ozlabs.org>
Subject: Re: /etc/migration.d
Date: Fri, 16 Oct 2020 19:10:04 +0200	[thread overview]
Message-ID: <CADVsX88gap3t+P2L_hM7KUNcz-jPN1vMBV2XTRTsPRVpn-o5mA@mail.gmail.com> (raw)
In-Reply-To: <CACWQX80Bm1W0Y8JT+n3rf3qmWLeDi1pGTLSmr_piQQtuJMOdpw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3929 bytes --]

On Fri, 16 Oct 2020 at 18:50, Ed Tanous <ed@tanous.net> wrote:

> On Wed, Oct 14, 2020 at 11:49 AM Anton Kachalov <rnouse@google.com> wrote:
> >
> > With moving from root-only environment to unprivileged users' space, we
> need to ensure a smooth transition. To achieve that we need a mechanism for
> one-shot per-package scripts that would take care of migration. That's not
> only about groups & owners, but a general approach.
>
> Are there other use cases that necessitate a general approach?  I'm
> not against it, but owners and groups seems unique in the regard that
> the migration has to run as root.  Most (all?) other migrations don't
> seem to, or haven't in the past, and therefore can be run as a
> pre-init, or as part of the service itself.  If the service itself
> does the migration, the startup dependencies are a lot easier to track
> as a maintainer, and running your migrations in a compiled language
> likely has a positive effect on boot time, which has been a problem in
> the past (still is depending on who you ask).
>

For instance, the bmcweb has some internal logic for migration of some
files. The problem with "in-service" compiled code is that the service will
be run with least privileges and could be sandboxed, thus, wouldn't be able
to modify filesystem.

The migration scripts have to be part of the corresponding package, thus,
it will be easy to track & maintain.

The one-time run scripts wouldn't make too much overhead if they run once.

Pre-init like StartExecPre= option in the service file isn't a good choice
because it will run every time and really increase the boot time.


>
> It should be noted, several apps have done simple migrations of config
> file formats in the past, so there's some precedent for it, just not
> in a generalist solution.
>
> >  It's similar to firstboot, but has a different purpose.
> >
> > I'm going to prototype a robust / naive solution to start a service
> before everything else in the system with a condition (non-empty
> /etc/migration.d) and iterate through all files. Each script has to run at
> list with "set -e" to bail out on failures. If the script succeeded -- it
> will be removed.
>
> The script itself will be removed?  Presumably that means you're
> executing the script out of non-volatile?  That seems like a security
> gap in that an attacker could inject migration scripts that did
> anything, and have the system run them for them.  Maybe just keeping
> some kind of external log of "these scripts have completed" or,
> preferably, enforcing that migration scripts are idempotent would be
> better, and would reduce the possibility of a bad actor getting
> permanent execution privileges if they somehow overwrote the scripts?
>

Basically, we can have a SHA-sum with a list of approved scripts to run.
Such lists have to be placed on the read-only part. The way how to mark the
succeeded scripts may vary. We can have scripts available on the same
read-only partition and touch files somewhere under /var/lib for the
succeeded ones. As well as make the scripts re-entrant in case of
losing state files.


>
> >
> > The tricky part is: what if the script fails? Keep it, ignore the
> failure and proceed with others and then boot the system? Or proceed other
> scripts as well and then enter some "failure state"?
>
> Assuming you can have migrations that are interlinked, have to be run
> in order, and sometimes can fail, maybe the "best" thing to do is to
> simply stop on the failing one, and try to boot the system as well as
> it's able to in the degraded state.  This would mean that flakey
> scripts would be rerun on the next boot, and hopefully succeed, and
> consistently failing scripts could be replaced on a subsequent
> firmware update with more robust versions, and rerun.
>

Are there any read-to-use API / scripts to make the system boot in degraded
mode? Otherwise, we can just add this functionality later.

[-- Attachment #2: Type: text/html, Size: 4968 bytes --]

  reply	other threads:[~2020-10-16 17:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 18:47 /etc/migration.d Anton Kachalov
2020-10-16 16:50 ` /etc/migration.d Ed Tanous
2020-10-16 17:10   ` Anton Kachalov [this message]
2020-10-16 20:25 ` /etc/migration.d Patrick Williams
2020-10-16 21:01   ` /etc/migration.d Anton Kachalov
2020-10-20 11:22     ` /etc/migration.d Anton Kachalov
2020-10-22 16:19       ` /etc/migration.d Anton Kachalov
2020-10-22 19:51         ` /etc/migration.d Ed Tanous
     [not found]         ` <CAH2-KxA9cX49Kfp4SbRPdY1wRt3u8T7o-hUfkBORZNZ9yUXoSg@mail.gmail.com>
2020-10-22 20:39           ` [gbmc-team] /etc/migration.d Anton Kachalov
2020-10-22 20:45             ` Ed Tanous

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADVsX88gap3t+P2L_hM7KUNcz-jPN1vMBV2XTRTsPRVpn-o5mA@mail.gmail.com \
    --to=rnouse@google.com \
    --cc=ed@tanous.net \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).