From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7358338671440822272 X-Received: by 2002:a05:6214:4a4d:b0:69b:5c93:524a with SMTP id ph13-20020a0562144a4d00b0069b5c93524amr11009142qvb.23.1713319865280; Tue, 16 Apr 2024 19:11:05 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6214:194a:b0:699:27da:1247 with SMTP id q10-20020a056214194a00b0069927da1247ls1307160qvk.2.-pod-prod-08-us; Tue, 16 Apr 2024 19:11:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHa324xkX+kis3UIyuZA7J71rAIf1C3YGaGeF634CFXswMOtrugi+PZ3dZDKMV/KxerxpFCqePGhA== X-Received: by 2002:a0c:f751:0:b0:69b:6974:b407 with SMTP id e17-20020a0cf751000000b0069b6974b407mr40601qvo.6.1713319864310; Tue, 16 Apr 2024 19:11:04 -0700 (PDT) X-Google-Web-Client: true Date: Tue, 16 Apr 2024 19:11:04 -0700 (PDT) From: Zhibin Dong To: isar-users Message-Id: <99c50a12-bcb3-4d45-83b1-18988deb35bbn@googlegroups.com> In-Reply-To: <18fa0d57df55365ef4aeb0391593a213483a2197.camel@siemens.com> References: <20240416051222.3344127-1-zhibin.dong@siemens.com> <18fa0d57df55365ef4aeb0391593a213483a2197.camel@siemens.com> Subject: Re: [PATCH] image: check if the file is core dump MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_20816_420547721.1713319864026" X-TUID: yZ+WpfnC/FYr ------=_Part_20816_420547721.1713319864026 Content-Type: multipart/alternative; boundary="----=_Part_20817_590040966.1713319864026" ------=_Part_20817_590040966.1713319864026 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =20 > Are we sure this works in cross-arch scenarios? I.e. can an amd64 "file"= =20 detect arm64 coredumps? Did you test this Zhibin Dong? > If so, this patch is fine.=20 On an amd64 platform, I execute these commands. $ file ./core.amd64 ./core.amd64: ELF 64-bit LSB core file, x86-64, version 1 (SYSV),=20 SVR4-style, from './crashing_program', real uid: 1000, effective uid: 1000,= =20 real gid: 1000, effective gid: 1000, execfn: './crashing_program',=20 platform: 'x86_64' $ file ./core.aarch64 ./core.aarch64: ELF 64-bit LSB core file, ARM aarch64, version 1 (SYSV),=20 SVR4-style, from './crashing_program_aarch64', real uid: 1000, effective=20 uid: 1000, real gid: 1001, effective gid: 1001, execfn:=20 './crashing_program_aarch64', platform: 'aarch64' `file` can determine the architecture of a file and also determine if it is= =20 a core file. =E5=9C=A82024=E5=B9=B44=E6=9C=8817=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC+= 8 05:02:35 =E5=86=99=E9=81=93=EF=BC=9A > On Tue, 2024-04-16 at 13:12 +0800, Zhibin Dong wrote: > > The previous code does a wrong judgement in two cases: > > 1. a file is suffixed by .core but is not a core dump file > > 2. a file is a core dump file but is not suffixed by .core > > Hi, just for reference: This is an addition to the pattern implemented > in https://groups.google.com/g/isar-users/c/JtCExK7m4OY/m/F9QaxKBSAQAJ > > >=20 > > The new code uses `file` to determine the type of files, which is > > more > > accurate. > >=20 > > Signed-off-by: Zhibin Dong > > --- > > meta/classes/image.bbclass | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > > index 98741da0..10923947 100644 > > --- a/meta/classes/image.bbclass > > +++ b/meta/classes/image.bbclass > > @@ -444,7 +444,7 @@ EOSUDO > > =20 > > # Sometimes qemu-user-static generates coredumps in chroot, move > > them > > # to work temporary directory and inform user about it. > > - for f in $(sudo find ${ROOTFSDIR} -type f -name *.core); do > > + for f in $(sudo find ${ROOTFSDIR} -type f -exec file {} \; | > > Are we sure this works in cross-arch scenarios? I.e. can an amd64 > "file" detect arm64 coredumps? Did you test this Zhibin Dong? > If so, this patch is fine. > > Best regards, > Felix > > > grep 'core file' | cut -d: -f1); do > > sudo mv "${f}" "${WORKDIR}/temp/" > > bbwarn "found core dump in rootfs, check it in > > ${WORKDIR}/temp/${f##*/}" > > done > > --=20 > > 2.39.2 > >=20 > > --=20 > Siemens AG, Technology > Linux Expert Center > > > ------=_Part_20817_590040966.1713319864026 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

> Are we sure this works in cross-arch scenarios? I.e. can an amd64 "file" detect arm64 coredumps? Did you test this Zhibin Dong?

> If so, this patch is fine.

On an amd64 platform, I execute these commands.
$ fi= le ./core.amd64
./core.amd64: ELF 64-bit LSB core file, x8= 6-64, version 1 (SYSV), SVR4-style, from './crashing_program', real uid: 10= 00, effective uid: 1000, real gid: 1000, effective gid: 1000, execfn: './cr= ashing_program', platform: 'x86_64'
$ file ./core.aarch64<= /span>
./core.aarch64: ELF 64-bit LSB core file, ARM aarch64, ver= sion 1 (SYSV), SVR4-style, from './crashing_program_aarch64', real uid: 100= 0, effective uid: 1000, real gid: 1001, effective gid: 1001, execfn: './cra= shing_program_aarch64', platform: 'aarch64'

`file` can determine the architecture of a file and also determine if it= is a core file.
=E5=9C=A82024=E5=B9=B44=E6=9C=8817=E6=97=A5=E6=98=9F=E6= =9C=9F=E4=B8=89 UTC+8 05:02:35<MOESSBAUER, Felix> =E5=86=99=E9=81=93=EF= =BC=9A
On Tue= , 2024-04-16 at 13:12 +0800, Zhibin Dong wrote:
> The previous code does a wrong judgement in two cases:
> 1. a file is suffixed by .core but is not a core dump file
> 2. a file is a core dump file but is not suffixed by .core

Hi, just for reference: This is an addition to the pattern implemented
in https://groups.google.com/g/i= sar-users/c/JtCExK7m4OY/m/F9QaxKBSAQAJ

>=20
> The new code uses `file` to determine the type of files, which is
> more
> accurate.
>=20
> Signed-off-by: Zhibin Dong <zhibi...@siemens.com>
> ---
> =C2=A0meta/classes/image.bbclass | 2 +-
> =C2=A01 file changed, 1 insertion(+), 1 deletion(-)
>=20
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbcla= ss
> index 98741da0..10923947 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -444,7 +444,7 @@ EOSUDO
> =C2=A0
> =C2=A0=C2=A0=C2=A0=C2=A0 # Sometimes qemu-user-static generates co= redumps in chroot, move
> them
> =C2=A0=C2=A0=C2=A0=C2=A0 # to work temporary directory and inform = user about it.
> -=C2=A0=C2=A0=C2=A0 for f in $(sudo find ${ROOTFSDIR} -type f -nam= e *.core); do
> +=C2=A0=C2=A0=C2=A0 for f in $(sudo find ${ROOTFSDIR} -type f -exe= c file {} \; |

Are we sure this works in cross-arch scenarios? I.e. can an amd64
"file" detect arm64 coredumps? Did you test this Zhibin Dong?
If so, this patch is fine.

Best regards,
Felix

> grep 'core file' | cut -d: -f1); do
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sudo mv "${f= }" "${WORKDIR}/temp/"
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bbwarn "foun= d core dump in rootfs, check it in
> ${WORKDIR}/temp/${f##*/}"
> =C2=A0=C2=A0=C2=A0=C2=A0 done
> --=20
> 2.39.2
>=20

--=20
Siemens AG, Technology
Linux Expert Center


------=_Part_20817_590040966.1713319864026-- ------=_Part_20816_420547721.1713319864026--