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

many: update apparmor to 4.0.1 #14150

Merged
merged 17 commits into from
Jul 11, 2024
Merged

Conversation

zyga
Copy link
Contributor

@zyga zyga commented Jul 2, 2024

This is a rebase of #13354

This is replacement for older attempt by Alex M: #13354

Bug reports and fixes to consider: https://ubuntu-archive-team.ubuntu.com/pending-sru.html

@zyga zyga marked this pull request as ready for review July 4, 2024 11:01
@alexmurray
Copy link
Contributor

Thanks @zyga - so like the original PR, we still see failures in tests/main/snapd-homedirs-vendored which I also explained back in the original PR - #13354 (comment) - I am not sure there is a good fix for this - every time we update to a newer vendored AppArmor which has a new default ABI, this test will likely fail in the same way due to the mismatch between the old and new ABIs. But once this is merged to master then the test will pass 🙃

alexmurray and others added 11 commits July 8, 2024 09:44
Unlike the Launchpad tarball, the one from apparmor gitlab tarball
requires this to be present as it is just a snapshot of the git tree,
not a release tarball like those provided by Launchpad.

Signed-off-by: Alex Murray <[email protected]>
This was already included upstream as part of the 3.1.0 release and
hence is included in the 4.0.1 release which we are now vendoring.

Signed-off-by: Alex Murray <[email protected]>
They are already included in apparmor 4.x release.

Signed-off-by: Zygmunt Krynicki <[email protected]>
All local patches are now merged in the 4.x release.

Signed-off-by: Zygmunt Krynicki <[email protected]>
This is helpful when trying to debug why certain features may not be supported.

Signed-off-by: Alex Murray <[email protected]>
@ernestl ernestl added this to the 2.64 milestone Jul 8, 2024
Copy link
Contributor

@valentindavid valentindavid left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1,13 +1,16 @@
/*
this file was generated on a Ubuntu kinetic install from the upstream
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably remove this file once we have moved to using core24 as build base. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit of an annoying part. The parser looks at the host's socket.h file to determine what kind of sockets one can create and to know their names.

If the snap is built on an old system, where the definition of old is always inaccurate. In theory we could drop it but we'd alwayd be at the risk of compiling but silently failing to understand specific network types.

@ernestl ernestl requested a review from pedronis July 8, 2024 09:54
@ernestl ernestl requested a review from jslarraz July 8, 2024 11:42
Copy link
Contributor

@jslarraz jslarraz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@ernestl ernestl left a comment

Choose a reason for hiding this comment

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

Some comments/questions for consideration

Copy link
Collaborator

@ernestl ernestl Jul 8, 2024

Choose a reason for hiding this comment

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

Have this been considered: https://github.com/snapcore/snapd/blob/master/sandbox/apparmor/apparmor.go#L786-L788

Not covered by test: https://github.com/snapcore/snapd/blob/master/sandbox/apparmor/apparmor.go#L790

Maybe a test for external parser abi options: 4.0, 3.0, other?
cmd/snapd-apparmor TestLoadAppArmorProfiles is exercising 3.0 abi, is this still sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you clarify the 2nd link to a diff that's about not covered by test? Either the link is wonky or I don't understand what the question is.

I'll look into 4.0 testing in snapd-apparmor, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made a separate patch to enable apparmor 4.0 ABI when using the host compiler. I do not want to introduce it here as it's something we cannot easily synchronize with. It should be considered and reviewed separately. I also write some tests in the same pass.

The follow-up is: #14167

if tryAppArmorParserFeature(cmd, fp.flags, fp.probe) {
err := tryAppArmorParserFeature(cmd, fp.flags, fp.probe)
if err != nil {
logger.Debugf("cannot probe apparmor feature %q: %v", fp.feature, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice addition

@@ -816,9 +819,9 @@ func tryAppArmorParserFeature(cmd *exec.Cmd, flags []string, rule string) bool {
// older versions of apparmor_parser can exit with success even
// though they fail to parse
if err != nil || strings.Contains(string(output), "parser error") {
return false
return fmt.Errorf("apparmor_parser failed: %v: %s", err, output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice addition

sandbox/apparmor/apparmor.go Show resolved Hide resolved
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator

@ernestl ernestl left a comment

Choose a reason for hiding this comment

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

Thanks

@zyga
Copy link
Contributor Author

zyga commented Jul 9, 2024

There's a number of failures that need investigation. Please don't merge this yet @ernestl

@zyga
Copy link
Contributor Author

zyga commented Jul 9, 2024

This is hitting the /dev/mqueue issue with apparmor on the host.

@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

AppArmor 4.0.1 SRU has been released to Noble.

It seems that mediation of mqueue is miscompiled by apparmor_parser
4.0.0~beta3 that was present in Ubuntu 24.04 until the 10th of July
2024. Detect this and mask the presence of mqueue unless apparmor parser
4.0.1, or newer, is used.

Signed-off-by: Zygmunt Krynicki <[email protected]>
@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

Various tests are now failing on:

+ snap debug sandbox-features --required apparmor:parser:snapd-internal
error: sandbox feature not available: "apparmor:parser:snapd-internal"

I have a hunch that this is because apparmor on the host and in snapd is the same version. Perhaps we need to fake the version to "+1" or fix the tests to cope?

@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

The test google:ubuntu-18.04-64:tests/main/snapd-homedirs-vendored fails as in the original branch from Alex, due to the fact that when using apparmor re-execution we assume 4.0 is present and in that specific case, it is not as we repackage snapd snap from the store without injecting updated apparmor.

zyga added 2 commits July 10, 2024 16:05
Mirror the logic used in apparmor-from-the-host to apparmor-from-snapd-snap.
This mainly fixes tests that repackage old snapd snap without touching
apparmor, but in general seems like the right thing to do.

The logic is such, that abi 4 is preferred.

Signed-off-by: Zygmunt Krynicki <[email protected]>
@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

I've improved the code a little so that tests might actually pass now.

@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

If tests are happy this needs a re-review.

@zyga
Copy link
Contributor Author

zyga commented Jul 10, 2024

Dear reviewers, please see patches:

Those are non-test changes that have happened since the branch was mainly approved.

Copy link
Collaborator

@ernestl ernestl left a comment

Choose a reason for hiding this comment

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

Thanks, nice upgrade with ability to now manage version specific feature bugs and also the ability to use available internal ABI file!

Some nitpick comments for consideration.

@ernestl ernestl changed the title build-aux,sandbox: update apparmor to 4.0.1 many: update apparmor to 4.0.1 Jul 11, 2024
@ernestl ernestl merged commit 0b52b0e into canonical:master Jul 11, 2024
49 of 53 checks passed
@zyga zyga deleted the feature/apparmor-bump branch July 12, 2024 07:48
@ernestl ernestl mentioned this pull request Aug 19, 2024
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.

6 participants