Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: Gentoo Dev <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] [PATCH] linux-mod.eclass: support module signing
Date: Mon, 27 Jun 2022 21:50:48
Message-Id: CAJ0EP4331QT12w=CQiscubEo9Z=Ma9CH7RyvrGJjhCeY7w+Y_Q@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH] linux-mod.eclass: support module signing by Georgy Yakovlev
1 On Mon, Jun 27, 2022 at 5:11 PM Georgy Yakovlev <gyakovlev@g.o> wrote:
2 >
3 > On Mon, 2022-06-27 at 15:49 -0400, Mike Gilbert wrote:
4 > > On Mon, Jun 27, 2022 at 3:42 PM Georgy Yakovlev
5 > > <gyakovlev@g.o> wrote:
6 > > >
7 > > > On Mon, 2022-06-27 at 14:56 -0400, Mike Gilbert wrote:
8 > > > > On Mon, Jun 27, 2022 at 2:35 PM Kenton Groombridge
9 > > > > <concord@g.o> wrote:
10 > > > > > > so looks like we need to combine both methods and do the
11 > > > > > > following:
12 > > > > > > - if signing requested without compression - sign in
13 > > > > > > pkg_preinst.
14 > > > > > > - if signing requested with compression - sign in
15 > > > > > > src_install
16 > > > > > >
17 > > > > >
18 > > > > > Why can't we do both in pkg_preinst? I am thinking it would be
19 > > > > > best
20 > > > > > if
21 > > > > > we drop the current compression implementation and rework your
22 > > > > > old
23 > > > > > code
24 > > > > > to handle both compression and signing since the signing code
25 > > > > > is
26 > > > > > more or
27 > > > > > less already complete.
28 > > > >
29 > > > > Signing modules in pkg_preinst seems like a bad idea to me. That
30 > > > > means
31 > > > > you need to copy your private keys around to every host where the
32 > > > > package might be installed.
33 > > > >
34 > > > > If you sign in src_compile or src_install, you only need private
35 > > > > keys
36 > > > > on the system building your binpkg.
37 > > > >
38 > > >
39 > > > unfortunately portage will unconditionally strip .ko objects,
40 > > > rendering
41 > > > modules unloadable by stripping signature, unless we do dostrip -x
42 > > > (requires EAPI7+, which should not be a problem nowadays, but was a
43 > > > problem back in 2018), which can be quite unfortunate on debug
44 > > > enabled
45 > > > kernels.
46 > >
47 > > Sounds like something to fix/change in Portage. It could probably be
48 > > updated to not strip the signature. However, I would guess the
49 > > signature needs to be updated after the binary is modified in any
50 > > case.
51 > >
52 > > Or as a workaround you could disable automatic striping via dostrip -
53 > > x
54 > > and run the proper commands to strip the modules in src_install as
55 > > well.
56 > >
57 > I think even strip itself does not have proper options not to break
58 > module. Several years back it was the case, basically one has to strip
59 > first, sign second, otherwise module will be unloadable.
60 >
61 > "Signed modules are BRITTLE as the signature is outside of the defined
62 > ELF container. Thus they MAY NOT be stripped once the signature is
63 > computed and attached. Note the entire module is the signed payload,
64 > including any and all debug information present at the time of
65 > signing."
66 >
67 > https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#signed-modules-and-stripping
68 >
69
70 In that case, I think the only viable way to make this work is to
71 disable automatic stripping and handle stripping via custom code in
72 the ebuild/eclass.

Replies

Subject Author
Re: [gentoo-dev] [PATCH] linux-mod.eclass: support module signing Georgy Yakovlev <gyakovlev@g.o>