sonic-buildimage/files/initramfs-tools
Samuel Angebault 0c4d4ace76
[kdump] Fix OOM events in crashkernel (#6447)
A few issues where discovered with crashkernel on Arista platforms.

1) platforms using `docker_inram=on` would end up OOM in kdump environment.
This happens because the same initramfs is used by SONiC and the crashkernel.
With `docker_inram=on` the `dockerfs.tar.gz` is extracted in a `tmpfs` created for the occasion.
Since `dockerfs.tar.gz` weights more than 1.5G, it doesn't fit into the kdump environment and ends up OOM.
This OOM event can in turn trigger a panic.

2) Arista platforms with `secureboot` enabled would fail to load the crashkernel because the kernel parameter would be discarded on boot.
This happens because the `boot0` in secureboot mode is strict about kernel parameter injection.

3) The secureboot path allowlist would remove kernel crash reports.

4) The kdump service would fail on Arista products since `/boot/` is empty in `secureboot`

**- How I did it**

1) To prevent an OOM event in the crashkernel the fix is to avoid the codepaths in `union-mount` that create tmpfs and populate them. Some more codepath specific to Arista devices are also skipped to make the kdump process faster.
This relies on detecting that the initramfs is starting in a kdump environment and skipping some initialization.
The `/usr/sbin/kdump-config` tool appends a few kernel cmdline arguments when loading the crashkernel.
The most unique one is `systemd.unit=kdump-tools.service` which is used in a few initramfs hooks to set `in_kdump`.

2) To allow `kdump` to work in `secureboot` environment the cmdline generation in boot0 was slightly modified.
The codepath to load kernel parameters changed by SONiC is now running for booting in secure mode.
It was altered to prevent an append only behavior which would grow the `kernel-cmdline` at every reboot.
This ever growing behavior would lead `kexec` to fail to load the kernel due to a too long cmdline.

3) To get the kernel crash under /var/crash this path has to be added to `allowlist_paths`

4) The `/host/image-XXX/boot` folder is now populated in `secureboot` mode but not used.

**- How to verify it**

Regular boot:
 - enable kdump
 - enable docker_inram=on via kernel-params
 - reboot
 - generate a crash `echo c > /proc/sysrq-trigger`
 - before: witness OOM events on the console
 - after: crash kernel works and crash available under /var/crash

Secure boot:
 - enable kdump
 - reboot
 - generate a crash `echo c > /proc/sysrq-trigger`
 - before: witness no kdump
 - after: crash kernel works and crash available under /var/crash


Co-authored-by: Boyang Yu <byu@arista.com>
2021-02-02 01:55:09 -08:00
..
arista-convertfs.j2 [kdump] Fix OOM events in crashkernel (#6447) 2021-02-02 01:55:09 -08:00
arista-hook [kdump] Fix OOM events in crashkernel (#6447) 2021-02-02 01:55:09 -08:00
arista-net [Arista] Set MAC address of mangement port in initramfs (#1565) 2018-04-06 10:48:13 -07:00
fsck-rootfs [baseimage]: Run fsck filesystem check support prior mounting filesystem (#4431) 2020-04-30 00:33:20 -07:00
mke2fs [initramfs]: move mke2fs to /usr/local/sbin 2020-04-17 04:51:51 +00:00
modules [NVMe] Add NVMe SSD disc type support to installer.sh script (#6142) 2020-12-09 19:03:27 -08:00
modules.arm [platform][marvell] Arm 32-bit Arch support changes (#5749) 2020-12-03 12:38:50 -08:00
resize-rootfs Reduce SONiC migration partition from 8G to 1G. (#1343) 2018-02-07 22:07:01 +08:00
setfacl [aboot]: Add setfacl in the initramfs (#1185) 2017-11-24 17:30:11 -08:00
uboot-utils [initramfs] Updated required tools for initramfs (#3734) 2020-01-15 08:25:01 -08:00
udev.patch [baseimage]: build root filesystem via overlay fs instead of aufs 2018-08-11 09:07:59 +00:00
union-fsck New release v1.0.0 2016-03-08 11:42:20 -08:00
union-mount.j2 [kdump] Fix OOM events in crashkernel (#6447) 2021-02-02 01:55:09 -08:00
varlog [initramfs] Updated required tools for initramfs (#3734) 2020-01-15 08:25:01 -08:00