[2/2] image.bbclass: remove core files generated in rootfs

Message ID 20230807163512.19570-3-venkata.pyla@toshiba-tsip.com
State Superseded, archived
Headers show
Series Fix reproducible issues in armhf | expand

Commit Message

venkata.pyla@toshiba-tsip.com Aug. 7, 2023, 4:35 p.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

Sometimes core dumps are created in rootfs and left in the final image,
and that results into non-reproducible images, so move those files to
${WORKDIR}/temp location and warn the user.

In armhf there is an issue with qemu-user-static that results in
creating core dumps which is reported in Debian upstream [1], meanwhile
move these core dumps outside the rootfs.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040981

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 meta/classes/image.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

MOESSBAUER, Felix Aug. 31, 2023, 6:21 a.m. UTC | #1
On Mon, 2023-08-07 at 22:05 +0530, venkata.pyla@toshiba-tsip.com wrote:
> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
> 
> Sometimes core dumps are created in rootfs and left in the final
> image,
> and that results into non-reproducible images, so move those files to
> ${WORKDIR}/temp location and warn the user.
> 
> In armhf there is an issue with qemu-user-static that results in
> creating core dumps which is reported in Debian upstream [1],
> meanwhile
> move these core dumps outside the rootfs.
> 
> [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040981
> 
> Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
> ---
>  meta/classes/image.bbclass | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 08b6d3d6..80509d0d 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -461,6 +461,12 @@ do_rootfs_finalize() {
>          fi
>  EOSUDO
>  
> +    # Move core dump files generated in rootfs to temp folder in
> workdir.
> +    for f in ${ROOTFSDIR}/*.core; do

The name of the coredump file depends on the values of
/proc/sys/kernel/core_uses_pid and /proc/sys/kernel/core_pattern.

The stock kernel default configuration is just "core".
For further details, see [1].

[1] https://github.com/DynamoRIO/dynamorio/issues/6126

Felix

> +        sudo mv "${f}" "${WORKDIR}/temp/"
> +        bbwarn "found core dump in rootfs, moved it to
> ${WORKDIR}/temp/"
> +    done
> +
>      # Set same time-stamps to the newly generated file/folders in
> the
>      # rootfs image for the purpose of reproducible builds.
>      if [ -n "${SOURCE_DATE_EPOCH}" ]; then

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 08b6d3d6..80509d0d 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -461,6 +461,12 @@  do_rootfs_finalize() {
         fi
 EOSUDO
 
+    # Move core dump files generated in rootfs to temp folder in workdir.
+    for f in ${ROOTFSDIR}/*.core; do
+        sudo mv "${f}" "${WORKDIR}/temp/"
+        bbwarn "found core dump in rootfs, moved it to ${WORKDIR}/temp/"
+    done
+
     # Set same time-stamps to the newly generated file/folders in the
     # rootfs image for the purpose of reproducible builds.
     if [ -n "${SOURCE_DATE_EPOCH}" ]; then