Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: Zac Medico <zmedico@g.o>
Cc: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] config.environ: delay export of A and AA (bug 720180)
Date: Tue, 26 May 2020 17:16:35
Message-Id: CAAr7Pr8er7FKxQG_33mbO-W=dkfZCh=4_ZCHooVT4XCDniJCcg@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] [PATCH] config.environ: delay export of A and AA (bug 720180) by Zac Medico
1 On Tue, May 26, 2020 at 9:46 AM Zac Medico <zmedico@g.o> wrote:
2
3 > On 5/26/20 1:43 AM, Alec Warner wrote:
4 > > On Mon, May 25, 2020 at 9:34 PM Zac Medico <zmedico@g.o
5 > > <mailto:zmedico@g.o>> wrote:
6 > >
7 > > Since variables like A and AA can contain extremely large values
8 > which
9 > > may trigger E2BIG errors during attempts to execute subprocesses,
10 > delay
11 > > export until the last moment, and unexport when appropriate.
12 > >
13 > >
14 > > So I think if you want to do this because PMS says:
15 > > AA should not be visible in EAPI > 3.
16 > > A should only be visible in src_*, pkg_nofetch.
17 > >
18 > > That part of the patch makes sense to me. The part that is confusing to
19 > > me is the 'delay' part; can you explain that further? When you say
20 > > "delay until the last moment" what do you mean by that and what value is
21 > > it delivering?
22 >
23 > If we export an environment variable which contains an extremely large
24 > value, then there's a vulnerability in execve which causes it to fail
25 > with an E2BIG error. Since A and AA values can easily grow large enough
26 > to trigger this vulnerability, portage can protect itself from execve
27 > failures by delaying the export until the moment that it hands control
28 > to the ebuild phase.
29 >
30
31 > > Is it simply that we don't export these variables on the python side,
32 > > and we only use them in the shell portion?
33 >
34 > That's correct. Here's a test case which demonstrates the E2BIG error,
35 > and shows that 'export -n A' can suppress it:
36 >
37
38 I've run similar tests, but I'm less excited by this work around. I think
39 its reasonable to work toward eventually not exporting A and AA (the latter
40 already done in EAPIs > 3). Then when ebuilds encounter problems, we can
41 tell authors "Upgrade to EAPI X" (where X is >3 or >=8; in the potential
42 case of A.) Having a hard limit on A for EAPIs 0-7 and a hard limit on AA
43 for EAPIs 0-3 seems perfectly fine and we should expect authors to refactor
44 (as texlive did) in order to meet the existing API limitations.
45
46 Basically unless there are more practical use cases today, the delaying of
47 export seems like a feature no one will use and added complexity. I dunno
48 how large the go-mod use cases are yet; but I myself have not seen any with
49 this many deps.
50
51 -A
52
53
54 >
55 > $ A=$(dd if=/dev/zero bs=1M count=1 | tr '\0' ' ')
56 > 10+0 records in
57 > 10+0 records out
58 > 10485760 bytes (10 MB, 10 MiB) copied, 0.086557 s, 121 MB/s
59 > $ echo ${#A}
60 > 10485760
61 > $ export A
62 > $ ls
63 > bash: /bin/ls: Argument list too long
64 > $ export -n A
65 > $ /bin/echo hello world
66 > hello world
67
68
69 > --
70 > Thanks,
71 > Zac
72 >
73 >

Replies