Skip to content

fix: detect arm64 Linux kernel images in the kernel cataloger - #5145

Open
l46983284-cpu wants to merge 1 commit into
anchore:mainfrom
l46983284-cpu:5126-arm64-kernel-image
Open

fix: detect arm64 Linux kernel images in the kernel cataloger#5145
l46983284-cpu wants to merge 1 commit into
anchore:mainfrom
l46983284-cpu:5126-arm64-kernel-image

Conversation

@l46983284-cpu

Copy link
Copy Markdown

Problem

The linux-kernel cataloger recognizes x86 bzImage layouts, but arm64 kernel images produce no linux-kernel component at all — while kernel modules from the same system are cataloged normally. Reported cases: raw arm64 Image, whole-file gzip-compressed images (Ubuntu), and EFI zboot PE wrappers with embedded gzip/zstd/xz streams (Amazon Linux, RHEL).

Fixes #5126

Fix

Keep the existing x86/deitch-magic path first, then fall back to an arm64 parser:

  • detect the arm64 kernel header magic (ARM\x64 at 0x38);
  • search through embedded compressed streams (gzip/zstd/xz/bzip2, vendored decoders only) the way extract-vmlinux does, with bounded reads (64MB file / 256MB decompressed);
  • extract the version from the Linux version banner, preserving the x86 empty-version behavior when no banner is present.

Tests

New parse_arm64_linux_kernel_file_test.go: 5 positive matrix rows (raw, gzip, zboot+gzip, zboot+zstd, zboot+xz), 4 negative cases (no false positives on random non-kernel data, no-banner parity with the x86 empty-version rule, pre-existing magic-error behavior preserved), plus an x86 bzImage regression test. At head: the full syft/pkg/cataloger/kernel package suite passes; the only failure in the wider cataloger run is the pre-existing docker-dependent Test_KernelCataloger, unavailable on this host.

The linux-kernel cataloger only handled x86 bzImage layouts, so arm64
kernel images (raw Image, whole-file gzip, and EFI zboot PE wrappers
with embedded gzip/zstd/xz streams) produced no linux-kernel component.

Detect the arm64 header magic, search through embedded compressed
streams with vendored decoders under bounded reads, and extract the
version from the Linux version banner, keeping the x86 path first.

Refs anchore#5126

Signed-off-by: Alex Chen <l46983284@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linux-kernel-cataloger emits no package for arm64 kernel images

1 participant