Skip to content

build: use libpathrs by default#5103

Merged
cyphar merged 11 commits intoopencontainers:mainfrom
cyphar:libpathrs-by-default
Mar 12, 2026
Merged

build: use libpathrs by default#5103
cyphar merged 11 commits intoopencontainers:mainfrom
cyphar:libpathrs-by-default

Conversation

@cyphar
Copy link
Copy Markdown
Member

@cyphar cyphar commented Feb 8, 2026

Draft until these PRs / issues are resolved and libpathrs has a new release:


pathrs-lite supports transparently switching to libpathrs.so as a backend
with the libpathrs build tag. In order to permit us to eventually require
libpathrs.so (and get rid of some of the duplicated wrappers in
internal/pathrs), we need to make libpathrs opt-out for at least one
release before making it mandatory.

Signed-off-by: Aleksa Sarai cyphar@cyphar.com

@cyphar cyphar added this to the 1.5.0-rc.1 milestone Feb 8, 2026
@cyphar cyphar force-pushed the libpathrs-by-default branch 4 times, most recently from d8dd6b0 to 11671a9 Compare February 8, 2026 23:32
@cyphar

This comment was marked as resolved.

@cyphar cyphar force-pushed the libpathrs-by-default branch 7 times, most recently from af83d54 to d25c6d6 Compare February 11, 2026 13:45
Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly LGTM. I like that it is basically contained on the CI/release files. Ping me when you want another review.

I left some comments. I think I'd nto try to figure out the "correct" location for a library on each distro, if something like /usr/local works on all. I'd let the right destdir to when we have an OBS package for each distro or so. But I feel usr/local probably doesn't work?

Left some other comments too, mostly nits.

@cyphar cyphar force-pushed the libpathrs-by-default branch from d25c6d6 to dbdd4c2 Compare February 13, 2026 06:50
cyphar added 6 commits March 12, 2026 17:58
Ever since v0.6.0 of github.com/cyphar/filepath-securejoin, pathrs-lite
has been able to transparently switch to using libpathrs as the backend
for safe path resolution (at compile-time, using a build tag). Note that
because build-tags apply globally, this allows for us to easily opt
pure-Go dependencies into all using libpathrs as well for our binaries.

In a future patch this will likely be enabled by default, but document
that this is an option for downstreams that want to opt-in to using
libpathrs.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This includes a few fixes for 32-bit builds.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
pathrs-lite supports transparently switching to libpathrs.so as the
backend with the "libpathrs" build tag. In order to make this work
properly with our CI and release build scripts, we we need to have a
similar setup as with we do with libseccomp.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
libpathrs will be opt-out in a future patch so we need to test with it
in our CI.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
libpathrs has better hardening against certain attacks (most notably on
older kernels) so we should use it by default. This opens the door to
us using cyphar.com/go-pathrs in the future in order to remove some of
our internal/pathrs wrappers (that reimplement bits of libpathrs).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
We do plan to make libpathrs required in the future, but in the meantime
we should test both with and without libpathrs in our CI to catch
regressions for users that will not use libpathrs initially.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
@cyphar cyphar mentioned this pull request Mar 12, 2026
@cyphar cyphar force-pushed the libpathrs-by-default branch from b87e9c2 to 0e1fe36 Compare March 12, 2026 09:02
@cyphar cyphar merged commit d0444a6 into opencontainers:main Mar 12, 2026
62 checks passed
@cyphar cyphar deleted the libpathrs-by-default branch March 12, 2026 09:57
@lifubang
Copy link
Copy Markdown
Member

I believe this constitutes a breaking change when building runc, and we should address it with the following three improvements:

  1. Explicitly specify the supported version range for the current libpathrs dependency.
  2. Since libpathrs is already the default build tag, the system should automatically install it if missing — otherwise, both individual users and upstream maintainers will be forced to consult the installation documentation manually.
  3. Add clear installation instructions for libpathrs to the README.md.
    @cyphar

@rata
Copy link
Copy Markdown
Member

rata commented Mar 12, 2026

@lifubang install automatically? That seems wrong, we don't do that with seccomp either, right?

@lifubang
Copy link
Copy Markdown
Member

That seems wrong, we don't do that with seccomp either, right?

The key difference here is that libseccomp is widely available in the default package repositories of most Linux distributions, making it straightforward for users to install via standard package managers. However, libpathrs has not yet been included in these distribution repositories, meaning users cannot easily install it through common package management commands.

This distinction justifies the need for automated installation support for libpathrs . While seccomp relies on existing distribution packages (and our documentation already covers its installation), libpathrs requires a more proactive approach to ensure users can build runc without manual, error-prone steps to locate and compile the dependency. Automating this process would address the accessibility gap and maintain consistency with the default-enabled build tag for libpathrs .

@cyphar cyphar mentioned this pull request Mar 12, 2026
local tar="libpathrs-${ver}.tar.xz"

# Download, check, and extract.
wget "https://github.com/cyphar/libpathrs/releases/download/v${ver}/${tar}"{,.asc}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we suggest users to use ./script/build-libpathrs.sh to build libpathrs in the future, could you also download these files to a temporary directory—outside the runc source code directory?

@cyphar
Copy link
Copy Markdown
Member Author

cyphar commented Mar 12, 2026

I'm fine with adding some more details to the README, but I'm really not in favour of installing libpathrs automatically as part of our build process. For one thing, it violates user expectations and would break within a fair few build systems (which disable network access to avoid build scripts downloading stuff from the internet).

At the moment libpathrs is only packaged for openSUSE but once runc has a soft requirement on it (in 1.5.0) every distribution will fairly create packages for it (it is a fairly low-dependency Rust project -- Debian already has all of the necessary dependencies packaged so even they shouldn't have too much trouble packaging it) and so the problem will resolve itself quite quickly IMHO. If we really want to provide a simple way to install libpathrs ourselves, (as discussed earlier in this thread) I plan to get OBS package builds for most distributions working soon and so we could point people to that repo until their distro provides packages for libpathrs. Either solution is better than running build-libpathrs.sh (which has a bunch of hacks to work within our CI and make release environments) on users' machines IMHO.

@lifubang
Copy link
Copy Markdown
Member

lifubang commented Mar 12, 2026

If containerd wants to upgrade to 1.5.0 after we release 1.5.0, their maintainers will need to install cargo and build libpathrs in their CI, or they could disable the libpathrs build tag, but currently the only way to do that is to manually specify another default tag, such as "seccomp".

@rata
Copy link
Copy Markdown
Member

rata commented Mar 12, 2026

@lifubang What if we move libpathrs to EXTRABUILDTAGS?

@rata
Copy link
Copy Markdown
Member

rata commented Mar 12, 2026

It's not perfect, not sure I like it now that I think about it more... The other option is to do the filter-out makefile thing. I think I've seen it in some PR already?

IMHO, having to specify seccomp doesn't seem too bad, though.

@cyphar
Copy link
Copy Markdown
Member Author

cyphar commented Mar 12, 2026

@kolyshkin suggested making modifying build-tags easier above, I opened #5165 to track that. I think putting it in EXTRA_BUILDTAGS is less than ideal because it means people setting additional build-tags would unset default ones -- this has been an issue in the past and so we should probably come up with a more robust solution (like the one @kolyshkin suggested).

@ngopalak-redhat
Copy link
Copy Markdown

I was able to use the script added in this PR and build runc for cri-o: cri-o/cri-o#9813

Figgeer

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants