Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with resolving relative symlinks during linux header detection #2038

Conversation

ddelnano
Copy link
Member

@ddelnano ddelnano commented Oct 3, 2024

Summary: Fix bug with resolving relative symlinks during linux header detection

Please see linked issue for details

Relevant Issues: Closes #2037

Type of change: /kind bugfix

Test Plan: Verified the following

  • Confirmed with user that reported the issue that this works for openSUSE's MicroOS linux headers
  • Verified on Ubuntu that using an absolute symlink works (upstream package, no modification)
ddelnano@dev-vm:/lib/modules/6.8.0-1015-gcp$ ls -l build
lrwxrwxrwx 1 root root 37 Sep  2 14:42 build -> /usr/src/linux-headers-6.8.0-1015-gcp

# Verify custom built stirling_wrapper identifies absolute headers
$ sudo docker run -v /:/host -v /sys:/sys -v /var/lib/docker:/var/lib/docker --pid=host --cgroupns host --env "PL_HOST_PATH=/host"  bazel/src/stirling/binaries:stirling_wrapper_image

I20241011 21:32:38.893605 395713 linux_headers.cc:257] Looking for host Linux headers at /host/lib/modules/6.8.0-1015-gcp/build.
I20241011 21:32:38.893646 395713 linux_headers.cc:237] Symlink target is an absolute path. Converting that to host path: /usr/src/linux-headers-6.8.0-1015-gcp -> /host/usr/src/linux-headers-6.8.0-1015-gcp.
I20241011 21:32:38.893750 395713 linux_headers.cc:261] Linked host headers at /host/usr/src/linux-headers-6.8.0-1015-gcp to symlink in pem namespace at /lib/modules/6.8.0-1015-gcp/build.
I20241011 21:32:38.893783 395713 linux_headers.cc:257] Looking for host Linux headers at /host/lib/modules/6.8.0-1015-gcp/source.
# Verify build is a relative symlink and resolves outside a container
ddelnano@dev-vm:/lib/modules/6.8.0-1015-gcp$ ls -l
total 1480
lrwxrwxrwx  1 root root     48 Oct 11 20:39 build -> ../../../../usr/src/linux-headers-6.8.0-1015-gcp

# Verify custom built stirling_wrapper identifies relative headers
$ sudo docker run -v /:/host -v /sys:/sys -v /var/lib/docker:/var/lib/docker --pid=host --cgroupns host --env "PL_HOST_PATH=/host"  bazel/src/stirling/binaries:stirling_wrapper_image

I20241011 21:30:16.825937 395471 linux_headers.cc:257] Looking for host Linux headers at /host/lib/modules/6.8.0-1015-gcp/build.
I20241011 21:30:16.825973 395471 linux_headers.cc:242] Symlink target is a relative path. Concatenating it to parent directory: /host/lib/modules/6.8.0-1015-gcp/../../../../usr/src/linux-headers-6.8.0-1015-gcp
I20241011 21:30:16.826067 395471 linux_headers.cc:261] Linked host headers at /host/lib/modules/6.8.0-1015-gcp/../../../../usr/src/linux-headers-6.8.0-1015-gcp to symlink in pem namespace at /lib/modules/6.8.0-1015-gcp/build.

Changelog Message: Fixed an issue where certain linux upstream distro's header packages would fail to be identified

@ddelnano ddelnano requested a review from a team as a code owner October 3, 2024 22:05
@feynmanliang
Copy link

Thank you!

src/stirling/utils/linux_headers.cc Outdated Show resolved Hide resolved
src/stirling/utils/linux_headers.cc Outdated Show resolved Hide resolved
@ddelnano ddelnano merged commit 1bd9ace into pixie-io:main Oct 11, 2024
34 checks passed
@ddelnano ddelnano deleted the ddelnano/fix-header-path-resolution-for-relative-symlinks branch October 11, 2024 22:21
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.

Upstream kernel header packages with relative symlinks always fall back to Pixie prepackaged headers
4 participants