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

Ensure future compatibility, drop old code (v1/v2 support) #1

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

kolyshkin
Copy link
Owner

This PR does two things.

Make sure that once (if ever) Linux kernel will start supporting capabilities v4, this library won't stop working. This relies on the assumption that v3 will still be supported.

Drops v1 and v2 API.

v3 API is used since the Linux kernel 2.6.26.

Since go 1.18 (no longer supported as of go 1.20 release), the minimum Linux kernel requirement is 2.6.32 (see 1). So, it does not make sense to support capabilities v1 and v2 any more.

Drop the support.


Same as syndtr#23

@kolyshkin kolyshkin changed the title Ensure future compatibility, drop old code (v1/v2 support) #23 Ensure future compatibility, drop old code (v1/v2 support) Jul 22, 2024
In case kernel folks will ever release capability v4, the chances are
high v3 is still supported. Therefore, we should not error out upon
seeing an unknown version from the kernel, but assume we can go with v3.

While at it, treat the uninitialized capVers as an error. Before this
patch, it was still treated as an error, but "unknown capability version"
is not exactly what the error is, so let's be more specific.

Reported-by: Andrei Vagin <avagin@google.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Capabilities v3 API was added by the Linux kernel 2.6.26.

Since go 1.18 (no longer supported as of go 1.20 release), the minimum
Linux kernel requirement is 2.6.32 (see [1]). So, it does not make sense
to support capabilities v1 and v2 any more.

Drop the support, returning the appropriate error message.

[1] https://tip.golang.org/doc/go1.18#linux

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Owner Author

Previously LGTMed by @avagin here.

@kolyshkin kolyshkin merged commit 96ee438 into master Jul 22, 2024
kolyshkin added a commit that referenced this pull request Aug 1, 2024
Earlier commit (see #1) made sure we don't error out if the kernel
capability version is unknown; this ensures compatibility with future
kernels.

Looking at the code, I realized p.hdr.version should be initialized to
linuxCapVer3 in that case, not the version returned by the kernel,
otherwise we supply v3 data structure with (say) v4 version set in
header.

Practically, this was not a real bug (yet) because v4 is not (yet)
available, but if it will ever be introduced later, this fix makes us
ready.

Fixes: 5584105 ("Fix future version compatibility")
@kolyshkin kolyshkin deleted the drop-old-code branch August 1, 2024 08:55
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.

1 participant