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

bug: if grsecurity patch fails with "patch: **** out of memory" error, build continues instead of failing #40

Closed
zenmonkeykstop opened this issue Oct 12, 2023 · 3 comments · Fixed by #45
Assignees

Comments

@zenmonkeykstop
Copy link
Contributor

zenmonkeykstop commented Oct 12, 2023

As observed in https://raw.githubusercontent.com/freedomofpress/build-logs/main/core/focal/20231011-securedrop-core-5.15.log, if the grsecurity patch isn't applied due to an OOM error, the build script doesn't error out but keeps going, producing the expected packages with no grsecurity changes.

Luckily this doesn't affect the most recent prod kernels, looking at https://raw.githubusercontent.com/freedomofpress/build-logs/main/core/focal/20230906-securedrop-core-5.15.log the patch was applied properly (and hardware tests would have caught it anyway).

Update: I encountered this on a Qubes-based build with 12GB max RAM. Naively bumping it to 20GB didn't help, and the VM's usage didn't get over about 3GB before the patch command failed.

Update the second: Applying the patch to the source tree outside of docker works fine! Patch itself is 14MB or so.

@zenmonkeykstop
Copy link
Contributor Author

zenmonkeykstop commented Oct 12, 2023

Cleared out old Docker images with docker system prune -a, and the patch is now being applied correctly! But the bug still stands IMO, the build script should fail if a patch command fails.

Update: spoke too soon, the kernel build itself is now failing with a bunch of compilation errors

@zenmonkeykstop
Copy link
Contributor Author

Still playing around - make vanilla builds work fine, only builds with the grsec patch applied are failing. Possibly the patch is not being applied correctly?

@legoktm
Copy link
Member

legoktm commented Apr 1, 2024

Despite the set -euo pipefail at the top of the script, we were running find /patches-grsec -maxdepth 1 -type f -exec patch -p 1 -i {} \;., which apparently will keep going even if patch returns a non-zero exit code (per stackoverflow).

As of #45, we do:

        subprocess.check_call(
            ["patch", "-p", "1", "-i", "/patches-grsec/grsec"],
            cwd=f"linux-{linux_version}",
        )

which means that any failure by patch will bubble up and stop execution.

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 a pull request may close this issue.

2 participants