ibm-s390-linux / s390-tools

Tools for use with the s390 Linux kernel and device drivers
MIT License
62 stars 58 forks source link

add info about the bundled zlib #157

Closed sharkcz closed 8 months ago

sharkcz commented 9 months ago

As s390-tools project is now bundling (part of) zlib, we need to know what version it is and how/if it has been modified to be able to track such information in the distro package. If it is taken from a fork, providing an URL would be also helpful. I assume it's not technically possible to build with a system zlib.

mzaslonk commented 9 months ago

Actually there are some words on it in zipl/include/zlib/zlib.h. Do you think the text should be expanded?

sharkcz commented 9 months ago

https://github.com/ibm-s390-linux/s390-tools/blob/master/zipl/include/zlib/zlib.h#L38 mentions 1.1.3, while the current zlib version is 1.2.13, so possibly full of CVEs and bugs. Maybe there could be a new section in https://github.com/ibm-s390-linux/s390-tools/blob/master/README.md#dependencies about the bundled deps.

hoeppnerj commented 9 months ago

https://github.com/ibm-s390-linux/s390-tools/blob/master/zipl/include/zlib/zlib.h#L38 mentions 1.1.3, while the current zlib version is 1.2.13, so possibly full of CVEs and bugs. Maybe there could be a new section in https://github.com/ibm-s390-linux/s390-tools/blob/master/README.md#dependencies about the bundled deps.

Hi Dan, we've discussed it and will likely add the required information to the README.md file (which you suggested, too). The version used here was taken from the Linux Kernel, which itself saw multiple changes over time. We will mention those details, rationales, and our own changes as well.

And you're right, including zlib like this is a bit tricky in regards to bugs and CVEs. We'll discuss how to handle updates for it.

mzaslonk commented 9 months ago

Hello Dan,

sorry for the long silence. Here is a README update I've prepared to describe zlib usage by the s390 zipl tool. Please share your thoughts.

+* zipl
+  For CCW-type DASD dump, zlib compression can be used to compress the dump
+  data before writing it to the DASD partition. It can benefit from
+  s390 on-chip compression accelerator (DFLTCC) and provide a faster dumping
+  process, hence lower system downtime.
+  Zlib code used in zipl (zipl/boot/zlib) is based on the linux kernel zlib
+  (kernel version 6.3) which refers to ZLIB_VERSION "1.1.3". Although kernel
+  zlib code had multiple updates over time including s390 hardware
+  compression (DFLTCC) support.
+  Apart from limited number of functions and DFLTCC related tweaks, the major
+  difference of kernel zlib code from the upstream zlib counterpart is that
+  all the memory allocations are to be performed in advance by the caller
+  which perfectly fits zipl needs as well. Since CCW-type standalone dumper
+  is built as a single binary and has to be loaded to stage2 location during
+  boot, all required zlib functions have to be integrated into it. Due to the
+  dumper size limitations, only deflate related parts are taken (no
+  decompression is required during dumping) in order to minimize the dumper
+  size. Apart from removing Inflate code and function prototypes, no other
+  significant modifications to kernel zlib code have been made.

As for the future updates with zlib CVEs and bugs that got fixed upstream, we can pull latest changes from the Kernel with each corresponding s390-tools release.

As for the 'minor' zlib code modifications for s390-tools, those are listed in the following commit message (not sure it's worth reflecting them in README as well): https://github.com/ibm-s390-linux/s390-tools/commit/1057f13cdcb30ec260c7db197f15013235a0f6b7

sharkcz commented 8 months ago

Sorry for the late answer, but the proposed text for README looks good to me, it's even more detailed than I would probably do.