1716 Commits

Author SHA1 Message Date
Ben Hutchings
f4ff132415 Merge branch 'unmkinitramfs-unsplit' into 'debian/latest'
unmkinitramfs: Stop splitting into "early"  and "main" subdirectories

See merge request kernel-team/initramfs-tools!169
2025-05-28 18:13:39 +00:00
Ben Hutchings
d04a3289d8 Merge branch 'log-copy_file-failures' into 'debian/latest'
hook-functions: Print error message on copy_file failure

See merge request kernel-team/initramfs-tools!167
2025-05-28 18:13:23 +00:00
Ben Hutchings
e375f529c8 Merge branch 'simple-framebuffer-modules' into 'debian/latest'
Handle simple-framebuffer drivers and framebuffer_coreboot built as modules

See merge request kernel-team/initramfs-tools!142
2025-05-28 18:12:16 +00:00
Ben Hutchings
36c3ee4e10 Releasing version 0.148.
Signed-off-by: Ben Hutchings <benh@debian.org>
v0.148
2025-05-28 19:09:56 +02:00
Benjamin Drung
ea2977533e hook-functions: Print error message on copy_file failure
Print an error message when copy_file cannot find the source file. This
will ease debugging in cases of failures like LP #1641230.
2025-04-25 11:19:30 +02:00
Ben Hutchings
c7fc4a424f Merge branch 'unmkinitramfs-c' into 'debian/latest'
unmkinitramfs: Rewrite in C to make it acceptably fast

See merge request kernel-team/initramfs-tools!168
2025-04-23 00:28:22 +00:00
Ben Hutchings
810421833a unmkinitramfs: Stop splitting into "early" and "main" subdirectories
We originally unpacked each cpio archive into its own subdirectory for
security reasons.  Since we are now able to stitch together multiple
cpio archives to feed to a single cpio process, that concern no longer
applies.

We maintained the split up to the release of "trixie" out of concern
for possible breakage of callers that relied on this split.  Since
that release is done, stop splitting and always unpack everything
directly into the output directory.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-04-22 03:10:23 +02:00
Ben Hutchings
49f3bbadce test: Add autopkgtest case for unmkinitramfs
Add a test that exercises unmkinitramfs with:

- 0-2 early cpio archives
- 0-2 main cpio archives
- All supported compressors, including none, for the last main archive

and verifies that the output is as expected.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-04-22 03:09:39 +02:00
Ben Hutchings
9e37d8b38d Move unmkinitramfs to new initramfs-tools-bin package
Since unmkinitramfs is now native code, it needs to be built as part
of an arch:any package.  Introduce initramfs-tools-bin and move it
there.

CI: Remove the variables that disable arch:any builds.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-04-22 02:37:00 +02:00
Ben Hutchings
a797b423d2 unmkinitramfs: Rewrite in C to make it acceptably fast
Parsing uncompressed cpio archives in this shell script requires
running multiple processes for each archive member.

This was not too bad when there were usually only a few microcode
blobs in an uncompressed archive, but now that we put compressed
kernel modules in an uncompressed archive, it became very slow indeed.

Rewrite it in C so that it's acceptably fast.

This should have no functional changes, except that it adds support
for an initramfs with no compressed part.

Fixes: 81fd41f72dd8 ("Put compressed kernel modules and firmware in an uncompressed cpio")
Signed-off-by: Ben Hutchings <benh@debian.org>
2025-04-22 02:37:00 +02:00
Alper Nebi Yasak
72899f8d89 Handle framebuffer_coreboot driver built as a module
The driver for coreboot firmware-initialized framebuffer can be built as
a module. Debian kernels so far have it as built-in because they would
not be probed automatically when built as a module. This is fixed now,
likely with a patchset included in v6.9-rc1, so we might encounter it as
a module either in Debian or with custom-built kernels.

For MODULES=dep, check for the coreboot framebuffer in a different block
from other platform drivers, and include the framebuffer_coreboot module
if we find the device. For MODULES=most, add driver to the framebuffer
modules list. Explicitly try to probe the module for break=top because
it would not automatically probe there otherwise. Since it requires a
driver for the "simple-framebuffer" device, add simpledrm and simplefb
as its hidden dependencies.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2025-04-21 09:05:08 +03:00
Alper Nebi Yasak
d11ba241dc Handle simple-framebuffer drivers built as modules
Recent Debian kernels have the simplefb driver built-in on a few
architectures, except in cloud flavours. It handles 'simple-framebuffer'
devices registered from elsewhere: possibly in a device-tree fragment,
or from another driver like framebuffer_coreboot, or via SYSFB_SIMPLEFB.
The more modern alternative to it is simpledrm which also handles
the same 'simple-framebuffer' devices.

We haven't switched to simpledrm, but if we do it's possible we will
want it to be a module, since it depends on the drm subsystem and would
require that to be built-in otherwise. Regardless of what we choose for
Debian kernels, it's still possible for custom-built kernels to have
either/both of simplefb and simpledrm as modules instead of built-in.

Include these modules in initramfs unconditionally when MODULES=dep.
For MODULES=most, add the two drivers to the framebuffer modules list.

When MODULES=dep and these drives are (probed) modules, our check for
platform framebuffers always finds a "module" directory in the driver's
sysfs directory and incorrectly skips handling graphics modules, ignore
the false positive.

Unfortunately, these drivers sometimes do not get probed automatically.
One such case is efifb with SYSFB_SIMPLEFB=y, which is quite important.
Add a init-top script that tries to probe simpledrm, with a fallback to
simplefb. Explicitly try to probe these modules for break=top as well.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2025-04-21 09:05:08 +03:00
Ben Hutchings
33075edd68 Releasing version 0.147.
Signed-off-by: Ben Hutchings <benh@debian.org>
v0.147
2025-03-28 02:38:25 +01:00
Ben Hutchings
203b5c85a8 Merge branch 'debian-policy' into 'debian/latest'
Bump Standards-Version to 4.7.2

See merge request kernel-team/initramfs-tools!166
2025-03-26 19:53:07 +00:00
Ben Hutchings
20cc17c2ee Merge branch 'test-order' into 'debian/latest'
test: run quick copy-file autopkgtest first

See merge request kernel-team/initramfs-tools!165
2025-03-26 19:51:44 +00:00
Benjamin Drung
32aa7432d2 Bump Standards-Version to 4.7.2
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2025-03-26 12:35:44 +01:00
Benjamin Drung
dad2c90a74 test: run quick copy-file autopkgtest first
The autopkgtest copy-file is a quickly running test. Run it before the
more expensive tests are run.
2025-03-26 11:01:18 +01:00
Ben Hutchings
1f682eecf5 Merge branch 'spelling' into 'debian/latest'
Fix spelling mistakes in d/changelog

See merge request kernel-team/initramfs-tools!163
2025-03-26 00:07:17 +00:00
Ben Hutchings
0df1765e90 Merge branch 'block-modules' into 'debian/latest'
Filter block kernel modules by symbol regex from dracut

See merge request kernel-team/initramfs-tools!149
2025-03-25 23:58:06 +00:00
Ben Hutchings
f740273bb0 Merge branch 'avoid-double-generation' into 'debian/latest'
Avoid updating the initramfs twice for some cases

See merge request kernel-team/initramfs-tools!157
2025-03-25 23:53:49 +00:00
Benjamin Drung
7f2ed354cc Avoid updating the initramfs twice for some cases
When installing/upgrading packages (e. g. a kernel and initramfs-tools),
the same initrd is generated twice:

```
$ apt-get install --no-install-recommends -y zstd initramfs-tools linux-image-generic
[...]
Setting up initramfs-tools-core (0.146) ...
Setting up initramfs-tools (0.146) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-6.12.20-amd64 (6.12.20-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.20-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.20-amd64
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
Setting up linux-image-amd64 (6.12.20-1) ...
Processing triggers for initramfs-tools (0.146) ...
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
```

Remember the timestamp when the dpkg trigger is set in the file
`/run/update-initramfs.dpkg-trigger`. Then only update the initramfs if
it is not newer than the time the trigger was created.

This will solve the example given above:

```
$ apt-get install --no-install-recommends -y zstd initramfs-tools linux-image-generic
[...]
Setting up initramfs-tools-core (0.146) ...
Setting up initramfs-tools (0.146) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-6.12.20-amd64 (6.12.20-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.20-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.20-amd64
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
Setting up linux-image-amd64 (6.12.20-1) ...
Processing triggers for libc-bin (2.41-6) ...
Processing triggers for initramfs-tools (0.146) ...
update-initramfs: /boot/initrd.img-6.12.20-amd64 has already been updated since Tue Mar 25 11:48:49 2025.
```

This approach will not help, when the update-initramfs trigger is set by
another package (e. g. clevis-initramfs). That would need support from
the dpkg trigger (see Debian bug #1099136).

LP: #1466965
2025-03-25 12:49:23 +01:00
Benjamin Drung
40694280ef update-initramfs: add -s parameter
When installing/upgrading packages (e. g. a kernel and initramfs-tools),
the same initrd is generated twice:

```
$ apt-get install --no-install-recommends -y zstd initramfs-tools linux-image-generic
[...]
Setting up initramfs-tools-core (0.145) ...
Setting up initramfs-tools (0.145) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-6.12.16-amd64 (6.12.16-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.16-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.16-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.16-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.16-amd64
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.16-amd64
Setting up linux-image-amd64 (6.12.16-1) ...
Processing triggers for libc-bin (2.40-7) ...
Processing triggers for initramfs-tools (0.145) ...
update-initramfs: Generating /boot/initrd.img-6.12.16-amd64
```

Add a `-s` parameter to `update-initramfs` to set a Unix time stamp
(seconds since 1970) for the update mode. An existing initramfs will
only be updated if it is not newer than the specified Unix time stamp.

This feature is the first step to avoid generating the initrd twice.

LP: #1466965
2025-03-25 12:40:14 +01:00
Benjamin Drung
19b85a5685 Filter block kernel modules by symbol regex from dracut
dracut-install can filter modules by symbol (`--mod-filter-symbol`) to
select modules more fine-grain. Harmonize the set of modules that
initramfs-tools and dracut install.

The modules mptfc, mptsas, mptscsih, mptspi, and zfcp are covered by
including `=drivers/message/fusion` to the block devices.

LP: #2031841
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2025-03-25 11:55:34 +01:00
Benjamin Drung
3ed407721c hook-functions: Move UFS storage drivers to block class
Including only UFS storage drivers that match the symbol regexp
`${blockfuncs}|iscsi_register_transport` is not enough.

Move UFS storage drivers to the `block` class instead of the more
specific `scsi`.

LP: #2081020
2025-03-25 11:49:28 +01:00
Benjamin Drung
7ef47552c1 Fix spelling mistakes in d/changelog
lintian complains:

```
W: initramfs-tools: spelling-error-in-changelog depency dependency [usr/share/doc/initramfs-tools/changelog.gz]
W: initramfs-tools: spelling-error-in-changelog plaforms platforms [usr/share/doc/initramfs-tools/changelog.gz]
W: initramfs-tools-core: spelling-error-in-changelog depency dependency [usr/share/doc/initramfs-tools-core/changelog.gz]
W: initramfs-tools-core: spelling-error-in-changelog plaforms platforms [usr/share/doc/initramfs-tools-core/changelog.gz]
```
2025-03-25 11:38:49 +01:00
Ben Hutchings
8722bb830a Merge branch 'unmk-regression' into 'debian/latest'
unmkinitramfs: Restore split to "early" and "main" subdirectories

See merge request kernel-team/initramfs-tools!162
2025-03-24 23:50:00 +00:00
Ben Hutchings
f48fbc6e86 Merge branch 'iscsi' into 'debian/latest'
Add qemu-net-iscsi autopkgtest

See merge request kernel-team/initramfs-tools!154
2025-03-24 23:48:28 +00:00
Ben Hutchings
a781aa7924 Merge branch 'update-initramfs' into 'debian/latest'
kernel/postinst.d: check for correct update-initramfs provider

See merge request kernel-team/initramfs-tools!159
2025-03-24 23:39:50 +00:00
Benjamin Drung
2334de30e4 kernel/postinst.d: check for correct update-initramfs provider
Ubuntu's dracut package ships an `update-initramfs` command with the
same interface as initramfs-tools'. The difference is that it calls
dracut instead of mkinitramfs.

When installing dracut without purging initramfs-tools,
`/etc/kernel/postinst.d/initramfs-tools` will still execute
`update-initramfs` (in addition to dracut's kernel postinst hook).

So query the newly add `--version` parameter to determine which package
provided the `update-initramfs` script. Only run the kernel postinst
hook when the provider matches.
2025-03-24 11:31:13 +01:00
Benjamin Drung
65166a6ff3 update-initramfs: add --version parameter 2025-03-24 11:30:45 +01:00
Benjamin Drung
716491a8ce mkinitramfs: add --version parameter 2025-03-24 11:30:24 +01:00
Benjamin Drung
20c564a90b Add qemu-net-iscsi autopkgtest
Add an autopkgtest for iSCSI similar to TEST-70-ISCSI from dracut.

LP: #2091904
2025-03-24 11:06:05 +01:00
Benjamin Drung
ab1fe4e20d test-common: introduce intermediate _run_qemu_default_devices
Introduce an intermediate function `_run_qemu_default_devices` to allow
reusing `_run_qemu` for cases where block or network devices are not
wanted.
2025-03-24 10:55:12 +01:00
Benjamin Drung
5401bf3528 test: support setting a disk label in build_fs_ext2 2025-03-24 10:47:10 +01:00
Benjamin Drung
a6884dc1ad test: let run_qemu* take extra kernel parameters as single parameter
Let the run_qemu* functions take extra kernel parameters as one single
parameter. This allows taking additional parameters later.
2025-03-24 10:42:56 +01:00
Ben Hutchings
bab0ea332f Merge branch 'squashfs' into 'debian/latest'
hook-functions: add squashfs driver

See merge request kernel-team/initramfs-tools!151
2025-03-23 18:48:32 +00:00
Ben Hutchings
bbbe1d37b3 unmkinitramfs.8: Update and expand description of multi-archive handling
The current behaviour of creating sub-directories for multi-archive
initramfs images was never documented.  Document what we do now, with
a note that we may stop creating sub-directories in future.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-03-20 02:40:42 +01:00
Scott Moser
cec12d7d80 hook-functions: add squashfs driver
Add squashfs support by default.

LP: #1501834
2025-03-17 10:16:30 +01:00
Ben Hutchings
736391d3ea Merge branch 'dep-add-reset' into 'debian/latest'
hook-functions: Add reset drivers when MODULES=dep

See merge request kernel-team/initramfs-tools!158
2025-03-16 21:54:16 +00:00
Ben Hutchings
2aa5542019 Merge branch 'devpts' into 'debian/latest'
Tighten /dev/pts permissions

See merge request kernel-team/initramfs-tools!161
2025-03-16 18:26:19 +00:00
Ben Hutchings
ca1a68b2c9 unmkinitramfs: Restore split to "early" and "main" subdirectories
unmkinitramfs used to assume that any uncompressed cpio archives at
the beginning of an initramfs image belonged to the early initramfs
and only a final compressed archive belonged to the the main
initramfs.  If it found any uncompressed archives it extracted them
into "early", "early2", etc. subdirectories and the compressed archive
into a "main" subdirectory.

The reason for using a separate subdirectory for each archive is to
guard against a symlink traversal attack from an untrusted initramfs,
e.g. the extraction of "link" as a symlink to "/etc" followed by
"link/shadow" which overwrites "/etc/shadow".  cpio itself protects
against this if we extract a single archive into an empty directory,
but not if we extract multiple archives successively into the same
directory.

mkinitramfs now splits the main initramfs files between uncompressed
and compressed archives.  unmkinitramfs was changed to use
subdirectory names "cpio1", "cpio2", etc. since the previous
distinction was no longer valid.

Several packages that integrate with initramfs-tools have autopkgtests
that run unmkinitramfs and were broken by this new behaviour.  It's
also quite possible that there are also user scripts that would also
be broken.

Therefore, try to restore the old behaviour in unmkinitramfs:

1. Distinguish whether uncompressed archives are "early" or "main"
   by checking for a kernel/ subdirectory.  Currently all filenames
   the kernel looks for in an early initramfs are in this
   subdirectory, but we should never create this in the main
   initramfs.

2. Extract early archives as before, but concatenate any "main"
   uncompressed archives to a temporary file.  Exclude the trailer
   from them so that cpio won't stop early when reading them.

3. Pass both the "main" uncompressed archives and the compressed
   archive to xcpio, and make it concatenate the uncompressed and
   decompressed archives as input to cpio.

The concatenation in steps 2 and 3 is done to preserve the protection
against symlink traversal.

Fixes: 81fd41f72dd8 ("Put compressed kernel modules and firmware in an uncompressed cpio")
Fixes: cb0618177b26 ("unmkinitramfs: use directory names 'cpio1', 'cpio2', etc.")
Closes: #1100008
Signed-off-by: Ben Hutchings <benh@debian.org>
2025-03-16 18:35:09 +01:00
Ben Hutchings
25b0c6164b unmkinitramfs: Fix detection of EOF marker
We currently split the initramfs when we see zero padding after an
file rather than a new file header.  However, the real EOF marker in a
cpio archive is a file header with the name "TRAILER!!!".  Look for
that first, then skip zero padding after it.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-03-16 17:52:59 +01:00
Ben Hutchings
025ce79bed unmkinitramfs: Create temporary directory for initramfs parts
Currently we extract the compressed archive from the initramfs to a
temporary file, but in future we will need to extract multiple
archives.  Create a temporary directory at the top level of the
script, and put the compressed archive inside that.

Signed-off-by: Ben Hutchings <benh@debian.org>
2025-03-16 17:52:01 +01:00
Chris Hofstaedtler
319cdc98f1 Tighten /dev/pts permissions
Apply a fuller fix for CVE-2024-28085 and remove g+w from
pseudo-terminals by default.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
2025-03-06 22:44:05 +01:00
Benjamin Drung
81f2063c45 Merge branch 'bug1099461' into 'debian/latest'
hook-functions: avoid aborting in chroots

See merge request kernel-team/initramfs-tools!160
2025-03-06 18:11:29 +00:00
Chris Hofstaedtler
297a9e292a hook-functions: avoid aborting in chroots
chroots and other build environments often do not have /sys mounted.
Nevertheless they want to build initrds. As a complication, live-boot
calls these functions from a hook that has "set -e" turned on, turning
the ignored error from "read" into an abort of update-initramfs.

Fixes: b3e8cc4011334b6f39ba915149d5518b1644f87b
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1099461
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
2025-03-04 13:15:19 +01:00
Ben Hutchings
571db506ce Releasing version 0.146.
Signed-off-by: Ben Hutchings <benh@debian.org>
v0.146
2025-03-02 17:48:24 +01:00
Ben Hutchings
34f9acde87 hook-functions: Add reset drivers when MODULES=dep
Reset drivers are currently included when MODULES=most but not when
MODULES=dep.  Since they are outside the device model, match them by
module name not by driver class.

Closes: #1027458
Signed-off-by: Ben Hutchings <benh@debian.org>
2025-03-02 16:05:01 +01:00
Ben Hutchings
af25dc3ff4 Merge branch 'shellcheck-tests' into 'debian/latest'
fix shellcheck complaints in tests

See merge request kernel-team/initramfs-tools!144
2025-02-25 01:23:59 +00:00
Benjamin Drung
3ad3f72e63 d/salsa-ci.yml: include tests in shellcheck
Check shell scripts in `debian/tests` and `tests` with shellcheck as
well.
2025-02-24 17:40:05 +01:00