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

remove the libbzip2 package #3944

Merged
merged 4 commits into from
May 7, 2024
Merged

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented May 4, 2024

Issue number:
N/A

Description of changes:
In the wake of the xz event, I'd like to continue removing older, rarely updated compression libraries. bzip2 is the obvious next candidate since it's only depended on by two packages.

In the case of makedumpfile it's not actually even required; it's just specified in the default link flags under the assumption that libelf and libdw will depend on that library.

Removing the libsemanage dependency is a bit more involved. The resulting patch is not upstreamable in this form, but suffices for Bottlerocket with its tiny SELinux policy files. It shouldn't be difficult to maintain given that compressed_file.c hasn't changed in the past two years.

Testing done:
Verified that semodule works with the uncompressed files:

bash-5.2# semodule -B
bash-5.2# dmesg|tail
[   12.595054] SELinux:  Converting 29 SID table entries...
[   12.598671] SELinux:  policy capability network_peer_controls=1
[   12.598675] SELinux:  policy capability open_perms=1
[   12.598677] SELinux:  policy capability extended_socket_class=1
[   12.598678] SELinux:  policy capability always_check_network=0
[   12.598679] SELinux:  policy capability cgroup_seclabel=1
[   12.598680] SELinux:  policy capability nnp_nosuid_transition=1
[   12.598680] SELinux:  policy capability genfs_seclabel_symlinks=1
[   12.598681] SELinux:  policy capability ioctl_skip_cloexec=0
[   12.652009] audit: type=1403 audit(1714852856.659:3): auid=4294967295 ses=4294967295 lsm=selinux res=1

Verified that makedumpfile works:

bash-5.2# echo c >/proc/sysrq-trigger
[   28.567910] sysrq: Trigger a crash
[   28.568274] Kernel panic - not syncing: sysrq triggered crash
...

bash-5.2# tail -n20 /var/log/kdump/dmesg.log 
[   28.570155] Call trace:
[   28.570392]  dump_backtrace+0xe4/0x140
[   28.570759]  show_stack+0x20/0x30
[   28.571082]  dump_stack_lvl+0x68/0x84
[   28.571438]  dump_stack+0x18/0x34
[   28.571763]  panic+0x12c/0x314
[   28.572064]  sysrq_reset_seq_param_set+0x0/0xa0
[   28.572503]  __handle_sysrq+0x90/0x1a0
[   28.572869]  write_sysrq_trigger+0xe4/0x1b0
[   28.573272]  proc_reg_write+0xac/0x100
[   28.573636]  vfs_write+0xdc/0x360
[   28.573962]  ksys_write+0x74/0x110
[   28.574288]  __arm64_sys_write+0x24/0x30
[   28.574665]  invoke_syscall+0x50/0x120
[   28.575030]  el0_svc_common.constprop.0+0x54/0x190
[   28.575488]  do_el0_svc+0x38/0x50
[   28.575810]  el0_svc+0x34/0x110
[   28.576114]  el0t_64_sync_handler+0xbc/0x140
[   28.584885] Starting crashdump kernel...
[   28.585268] Bye!

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Our libelf and libdw are not built with bzip2 support, so there is no
need to link the makedumpfile binary with libbz2.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Bottlerocket's modules are only a few hundred KiB, versus several MiB
for the "targeted" reference policy, so compression doesn't save very
much space.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Patch out support for reading and writing bzip2-compressed modules,
to avoid the otherwise-unneeded dependency on libbz2.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Signed-off-by: Ben Cressey <bcressey@amazon.com>
@@ -64,7 +64,7 @@ install -d "${moddir}"
for m in *.cil ; do
mod="${m%.*}"
install -d "${moddir}/${mod}"
bzip2 -c "${m}" > "${moddir}/${mod}/cil"
install -p -m 0644 "${m}" "${moddir}/${mod}/cil"
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we consider using ZSTD?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will we consider using ZSTD?

I'd like to, but probably only if it ends up as an upstream feature. The benefits from compression here are so modest that I don't think it's worth carrying an even larger patch to implement that.

#include <unistd.h>
#include <fcntl.h>

-#include <bzlib.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if upstream will be interested in a patch that includes conditionals for compressed modules. Are you aware of any discussion about other compression libraries?

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 haven't seen any recent discussion; in past threads, compression tended to be challenged with "is this really necessary?" which strikes me as totally correct and fair.

If we really needed compression, we could work around this in Bottlerocket with a combination of squashfs/erofs (as we do with licenses and kernel devel files) and overlayfs (to add a writable upper layer). But that seems like overkill here.

@@ -1,19 +0,0 @@
[package]
name = "libbzip2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Lovely! One less package to update!

@bcressey bcressey merged commit 9e61389 into bottlerocket-os:develop May 7, 2024
33 checks passed
@bcressey bcressey deleted the dump-libbzip2 branch May 7, 2024 19:10
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.

None yet

3 participants