Merge branch 'stable' into devel
[tails.git] / wiki / src / contribute / Linux_kernel.mdwn
blobdc5ceb94c1de73fd4a691dbd7dcba53a67ad5db3
1 This document is about:
3 * How we keep track of upcoming Linux kernel upgrades we may want, or
4   have to, apply in Tails.
5 * How we apply such upgrades.
7 [[!toc levels=2]]
9 # Background
11 … where the reader learns why this page is even needed and a few
12 relevant facts they should be aware of.
14 ## APT repositories
16 Tails is built using a combination of snapshots of the Debian archive
17 and overlay APT suites. This greatly impact the timeline and processes
18 of upgrading any Debian package in Tails, and in particular the Linux
19 kernel. This document assumes a good understanding of this [[somewhat
20 complex system|contribute/APT_repository]].
22 ## The Debian side of things
24 We generally ship the latest Linux kernel from Debian _unstable_ or
25 _stable backports_. There's a delay for new Linux uploads to migrate
26 from Debian _unstable_ to _testing_ and then to be uploaded and
27 accepted into _stable backports_. So in practice we tend to ship the
28 Linux kernel from Debian _unstable_: it happens regularly that the
29 version we want to ship is in _unstable_ but not in _stable
30 backports_ yet.
32 The Linux kernel binary packages include an ABI version number, e.g.
33 for `linux-image-4.18.0-2-amd64` the ABI is version 2.
35 Tracking the kernel from Debian _unstable_ has one significant
36 drawback: sometimes the only way to include security fixes is to
37 upgrade Linux to a major new version. For example, say the current
38 Tails release includes Linux 5.18.8, an important security issue was
39 fixed in 5.18.9 and in 5.19.6. If 5.19.6 was uploaded to _unstable_
40 but 5.18.9 never was, then our only option to include this security
41 fix is to upgrade to 5.19.6.
43 ## _We_ need to decide
45 Which exact Linux kernel version we ship in a given Tails release is
46 a trade-off between packages availability, security fixes, stability,
47 and hardware support. The Foundations Team has to make this decision
48 during every Tails release cycle. Due to the way we manage our APT
49 repositories and to the fact we don't publish release candidates for
50 Tails bugfix releases, how this decision is made and implemented
51 depends in great part on what kind of Tails release is upcoming (major
52 or bugfix).
54 The `KERNEL_VERSION` variable in [[!tails_gitweb config/amnesia]]
55 determines what version of the kernel will be installed during the
56 build. This includes the ABI version number, so even our `devel`
57 branch does not get Linux point-release (e.g. 4.19.7) upgrades
58 automatically if the ABI is bumped.
60 # Process
62 A Foundations Team member (generally the team lead, so far) creates
63 a tracking ticket whenever:
65  - A new major version of Linux is released. At this point, that
66    version is generally available only in Debian _experimental_.
67  - A Linux point-release (e.g. 4.19.7) that includes potentially
68    relevant security fixes or changes the ABI is uploaded to Debian
69    _unstable_.
71 Once this new kernel is available in our APT snapshots a Foundations
72 Team member (you!) gathers the data that will inform our decision.
73 There are two aspects to it: how it works for us and what the
74 risk/benefit of the upgrade is.
76 ## Test the new kernel
78 To learn how the new kernel works for us:
80 1. Fork a branch off `devel` called
81    `feature/NNNNN-linux-X.Y+force-all-tests`.
82 2. Adjust `KERNEL_VERSION` in `config/amnesia`. If `KERNEL_VERSION` is
83    unchanged (point-release without ABI bump), then this branch is
84    identical to `devel` and its only purpose is to force Jenkins to
85    run our entire test suite (`+force-all-tests`). But since this
86    branch has no commit on top of `devel`, Jenkins will ignore it, so
87    you need to create a dummy commit.
88 2. Adjust the `aufs` submodule: in the `submodules/aufs4-standalone`
89    directory, use `git fetch` and `git branch -a` to find the most
90    suitable branch for this kernel version, check it out, then move
91    back to the top level directory. `git diff` should show an updated
92    `Subproject commit` accordingly, and that can be committed.
93 3. Push this new branch to our CI.
94 4. Set the _Feature Branch_ field on the ticket to the name of your
95    new branch.
96 5. Quickly test a build from this branch on your hardware.
97 6. Compare the Jenkins build and test results to the ones for our
98    `stable` and `devel` branch.
99 7. Report your findings on the ticket.
101 ## Gather other data that will inform our decision
103 You'll find the relevant data in:
105  - [Changelog](https://salsa.debian.org/kernel-team/linux/blob/sid/debian/changelog?expanded=true&viewer=simple)
106    of the Debian package
107  - Kernelnewbies's [human-readable
108    changelog](https://kernelnewbies.org/LinuxChanges) of upstream
109    changes (only relevant for a new major Linux release)
110  - [Debian BTS](https://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=0;dist=unstable;ordering=normal;repeatmerged=0;src=linux)
111  - Debian [security tracker for
112    Linux](https://security-tracker.debian.org/tracker/source-package/linux)
114 In there, look for:
116  - Security issues fixed in _unstable_ since the version we currently ship
117  - Major security fixes still not fixed in _unstable_ (in which case,
118    depending on when we are in our own release process, it may be worth
119    delaying the analysis a bit)
120  - Important regressions i.e. bugs with severity _important_ or higher
121    recently reported to Debian against this version of the kernel
122  - Relevant hardware support improvements
124 Take notes on the ticket of the most relevant bits or lack thereof.
126 ## Make a decision
128 With all the information you gathered earlier, use your best judgement
129 to make a decision. The kind of decision you need to make depends on
130 several factors:
132  - If the upcoming Tails release is a major one and upgrading the
133    kernel did not require modifying `KERNEL_VERSION`, then if we do
134    nothing particular, our next release will get the upgrade. So you
135    need to decide whether this kernel upgrade is bad enough for us to
136    opt-out, or important enough for us to fix whatever regressions it
137    may bring. In practice, opting-out of the upgrade is rarely the
138    best choice but YMMV.
140  - Otherwise, upgrading Linux in our next release will require work,
141    so you need to decide whether the overall cost/benefit of the
142    upgrade is worth it, factoring in the work needed and all the data
143    you've gathered earlier.
145 If in doubt, ask your team-mates :)
147 If the decision is "do nothing", close the ticket and stop reading here.
148 Else, read on.
150 ## Implement the decision
152 How to implement the decision depends on what kind of Tails release is
153 upcoming.
155 ### Bugfix release
157 The branch you've used so far to get results from our CI was forked
158 off `devel` so it's not a valid candidate for merging into `stable`.
159 Therefore, create a new
160 `feature/NNNNN-linux-X.Y-stable+force-all-tests` topic branch forked
161 off `stable` and transplant onto it the commits you had to create on
162 your `devel`-based topic branch (`git rebase --onto` or `git
163 cherry-pick`). Update the _Feature Branch_ field accordingly
164 in Redmine.
166 But the new resulting topic branch will likely not build: a bugfix
167 release is built from our `stable` branch, that uses a set of APT
168 snapshots frozen during the last major release process, and these old
169 snapshots probably don't include the version of the kernel you want to
170 upgrade to. So there are two options:
172  - Either bump the APT snapshot of the `debian` archive to the oldest
173    one that includes this new kernel. When it can reasonably be done,
174    this is the cheapest option so it's worth trying it first:
176    1. Update `config/APT_snapshots.d/debian/serial`, commit, push and
177       trigger a build on Jenkins.
178    2. Compare the `.build-manifest` and `.packages` files generated
179       by building your topic branch with [[!tails_gitweb_dir desc="the
180       ones for the current Tails release" wiki/src/torrents/files]].
181    3. If the diff seems reasonable, fine. Otherwise, fall back to the
182       next option (freeze exception).
184  - Or use our [[freeze
185    exception|contribute/APT_repository/time-based_snapshots#design-freeze-exceptions]]
186    mechanism i.e. import the new Linux packages into a dedicated
187    overlay suite in our custom APT repository and make your topic
188    branch use it.
190 The CI results you got with your previous topic branch based on
191 `devel` are not valid for your new branch: the new kernel may work
192 fine in the former case thanks to corresponding userspace changes, but
193 cause trouble in the context of our `stable` branch. So push your
194 branch to our CI, trigger a build in Jenkins and analyze the
195 test results. Once happy:
197 1. Follow our usual process to get it reviewed and merged.
198 2. Follow the instructions to [[enable new security
199    features|Linux_kernel#new-security-features]].
201 ### Major release
203 If you decided to opt-out from a kernel upgrade we would otherwise
204 automatically include: piggy-back on our [[freeze
205 exception|contribute/APT_repository/time-based_snapshots#design-freeze-exceptions]]
206 to force the installation of an older kernel.
208 Else, you're trying to upgrade the kernel. It turns out you already
209 have prepared the very topic branch we need to do that, so:
211 1. Follow our usual process to get it reviewed and merged.
212 2. Follow the instructions to [[enable new security
213    features|Linux_kernel#new-security-features]].
215 <a id="new-security-features"></a>
217 # Enable new security features
219 This section assumes we have decided to upgrade to a major new version
220 of Linux.
222 Major new kernel versions often bring new security features.
223 After each major kernel release, Kees Cook publishes on
224 [his blog](https://outflux.net/blog/) an article titled
225 "security things in Linux $VERSION" about these improvements.
227 What you need to do depends on what it takes to benefit from each such
228 improvement:
230  - Enabled by default: nothing to do, profit :)
232  - Guarded by local configuration such as a sysctl or a kernel command
233    line option: file a ticket about it on Redmine and add this ticket
234    to the Foundations Team' radar. Optionally, do the work yourself:
235    once you've got CI results about your topic branch with this new
236    option disabled, add a commit that enables it and compare the
237    results (including test suite total run time, to spot important
238    performance regressions).
240  - Needs to be enabled at kernel configuration time: check if it's
241    been enabled in the Debian kernel; if it's not been enabled there
242    yet and enabling it would make sense in a general-purpose distro
243    kernel where UX breakage and performance regressions can be serious
244    problems, file a wishlist bug against the `linux` source package.
245    Point to Kees' post and explain why you think it's worth it.