diff mbox series

[meta-oe] Update oe selftest case syzkaller.py

Message ID 20240202020149.2950813-1-chi.xu@windriver.com
State Changes Requested
Headers show
Series [meta-oe] Update oe selftest case syzkaller.py | expand

Commit Message

Xu, Chi Feb. 2, 2024, 2:01 a.m. UTC
1. Will meet following error when run test again.
[FATAL] bad config syzkaller param: can't find /root/poky/build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package/usr/bin/linux_amd64/syz-fuzzer
This is because oe-selftest will add "SSTATE_DIR" to local.conf,
bitbake will not build syzkaller again, then test case can not
find syz-fuzzer under work dirertory.
Fix this isseu with adding SSTATE_SKIP_CREATION:pn-syzkaller = "1"
to configure file.

2. Image name has been changed from core-image-minimal-qemux86-64.ext4
to core-image-minimal-qemux86-64.rootfs.ext4, so update the defination
of self.rootfs.

Signed-off-by: Xu, Chi <chi.xu@windriver.com>
---
 meta-oe/lib/oeqa/selftest/cases/syzkaller.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Khem Raj Feb. 2, 2024, 4:45 a.m. UTC | #1
On Thu, Feb 1, 2024 at 6:01 PM Chi Xu <chi.xu@eng.windriver.com> wrote:
>
> 1. Will meet following error when run test again.
> [FATAL] bad config syzkaller param: can't find /root/poky/build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package/usr/bin/linux_amd64/syz-fuzzer

Can this be provided by some sort of native recipe and then a DEPENDS
created to pull this in when
building syzkaller

> This is because oe-selftest will add "SSTATE_DIR" to local.conf,
> bitbake will not build syzkaller again, then test case can not
> find syz-fuzzer under work dirertory.
> Fix this isseu with adding SSTATE_SKIP_CREATION:pn-syzkaller = "1"
> to configure file.
>
> 2. Image name has been changed from core-image-minimal-qemux86-64.ext4
> to core-image-minimal-qemux86-64.rootfs.ext4, so update the defination
> of self.rootfs.
>
> Signed-off-by: Xu, Chi <chi.xu@windriver.com>
> ---
>  meta-oe/lib/oeqa/selftest/cases/syzkaller.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> index 64fc864bf..2c35ba230 100644
> --- a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> +++ b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> @@ -65,6 +65,7 @@ KERNEL_EXTRA_FEATURES += " \
>      cfg/debug/syzkaller/debug-syzkaller.scc \
>  "
>  IMAGE_INSTALL:append = " syzkaller"
> +SSTATE_SKIP_CREATION:pn-syzkaller = "1"
>  """
>  % (self.machine, self.fstype))
>
> @@ -110,7 +111,7 @@ SYZ_QEMU_CPUS="2"'    # number of cpus used by each qemu VM
>
>          self.syz_cfg = os.path.join(self.syz_workdir, 'syzkaller.cfg')
>          self.kernel = os.path.join(self.deploy_dir_image, 'bzImage')
> -        self.rootfs = os.path.join(self.deploy_dir_image, '%s-%s.%s' % (self.image, self.machine, self.fstype))
> +        self.rootfs = os.path.join(self.deploy_dir_image, '%s-%s.rootfs.%s' % (self.image, self.machine, self.fstype))
>
>          self.syz_native_sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'syzkaller-native')
>
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#108522): https://lists.openembedded.org/g/openembedded-devel/message/108522
> Mute This Topic: https://lists.openembedded.org/mt/104111739/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Xu, Chi Feb. 2, 2024, 6:23 a.m. UTC | #2
> -----Original Message-----
> From: Khem Raj <raj.khem@gmail.com>
> Sent: Friday, February 2, 2024 12:46 PM
> To: Xu, Chi <Chi.Xu@windriver.com>
> Cc: openembedded-devel@lists.openembedded.org
> Subject: Re: [oe] [meta-oe][PATCH] Update oe selftest case syzkaller.py
> 
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and
> know the content is safe.
> 
> On Thu, Feb 1, 2024 at 6:01 PM Chi Xu <chi.xu@eng.windriver.com> wrote:
> >
> > 1. Will meet following error when run test again.
> > [FATAL] bad config syzkaller param: can't find
> > /root/poky/build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package
> > /usr/bin/linux_amd64/syz-fuzzer
> 
> Can this be provided by some sort of native recipe and then a DEPENDS
> created to pull this in when building syzkaller

When the test case is executed for the first time through 'oe-selftest -r syzkaller', we will not meet this error.
Because oe-selftest will create new build directory 'build-st' and build all packages from source code, then put  
'syz-fuzzer ' under work directory.  
-----------------------
root@localhost:/root/poky/build$ ls ../build-st/
bitbake-cookerdaemon.log  cache  conf  downloads  meta-selftest  tmp
root@localhost:/root/poky/build $ ls ../build-st/tmp/work/core2-64-poky-linux/syzkaller/git/
0001-executor-Include-missing-linux-falloc.h.patch               deploy-source-date-epoch  pkgdata              recipe-sysroot-native  syzkaller.spec
0001-sys-targets-targets.go-allow-users-to-override-hardc.patch  image                     pkgdata-pdata-input  source-date-epoch      temp
build-tmp                                                        license-destdir           pkgdata-sysroot      spdx
debugsources.list                                                package                   pseudo               sysroot-destdir
deploy-rpms                                                      packages-split            recipe-sysroot       syzkaller-git
root@localhost:/root/poky/build $ ls ../build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package/usr/bin/linux_amd64/
syz-execprog  syz-executor  syz-fuzzer  syz-stress
-----------------------

At the same time, ' sstate-cache' is created under original 'build' directory.
-----------------------
root@localhost:/root/poky/build$ ls sstate-cache/
00  08  10  18  20  28  30  38  40  48  50  58  60  68  70  78  80  88  90  98  a0  a8  b0  b8  c0  c8  d0  d8  e0  e8  f0  f8  universal
01  09  11  19  21  29  31  39  41  49  51  59  61  69  71  79  81  89  91  99  a1  a9  b1  b9  c1  c9  d1  d9  e1  e9  f1  f9
02  0a  12  1a  22  2a  32  3a  42  4a  52  5a  62  6a  72  7a  82  8a  92  9a  a2  aa  b2  ba  c2  ca  d2  da  e2  ea  f2  fa
03  0b  13  1b  23  2b  33  3b  43  4b  53  5b  63  6b  73  7b  83  8b  93  9b  a3  ab  b3  bb  c3  cb  d3  db  e3  eb  f3  fb
04  0c  14  1c  24  2c  34  3c  44  4c  54  5c  64  6c  74  7c  84  8c  94  9c  a4  ac  b4  bc  c4  cc  d4  dc  e4  ec  f4  fc
05  0d  15  1d  25  2d  35  3d  45  4d  55  5d  65  6d  75  7d  85  8d  95  9d  a5  ad  b5  bd  c5  cd  d5  dd  e5  ed  f5  fd
06  0e  16  1e  26  2e  36  3e  46  4e  56  5e  66  6e  76  7e  86  8e  96  9e  a6  ae  b6  be  c6  ce  d6  de  e6  ee  f6  fe
07  0f  17  1f  27  2f  37  3f  47  4f  57  5f  67  6f  77  7f  87  8f  97  9f  a7  af  b7  bf  c7  cf  d7  df  e7  ef  f7  ff
-----------------------

After test complete, 'build-st' will be deleted by oe-selftest automatically.
Then if we want to re-run the same test with same project, we will meet the error about ' can't find syz-fuzzer '.
Because oe-selftest will create 'build-st' again and add SSTATE_DIR ?= "/root/poky/build/sstate-cache" to 
build-st/conf/local.conf
-----------------------
root@localhost:/root/poky/build$ tail ../build-st/conf/local.conf
SYZ_QEMU_MEM="4096"
SYZ_QEMU_CPUS="4"
SANITY_TESTED_DISTROS=""
BB_NUMBER_THREADS ?= "24"
PARALLEL_MAKE ?= "-j 24"
SSTATE_DIR ?= "/root/poky/build/sstate-cache"

#include added by oe-selftest
include machine.inc
include selftest.inc
-----------------------

Because all packages have been built when we run the test first time and all necessary sstate cache are generated, 
the use of SSTATE will cause bitbake will not build syzkaller again.
Then the test case could not find 'syz-fuzzer' in the desired directory.
-----------------------
root@localhost:/root/poky/build$ oe-selftest -r syzkaller
2024-02-02 14:03:00,199 - oe-selftest - INFO - Adding layer libraries:
2024-02-02 14:03:00,199 - oe-selftest - INFO -  /root/poky/meta/lib
2024-02-02 14:03:00,199 - oe-selftest - INFO -  /root/poky/meta-yocto-bsp/lib
2024-02-02 14:03:00,199 - oe-selftest - INFO -  /root/meta-openembedded/meta-oe/lib
2024-02-02 14:03:00,200 - oe-selftest - INFO -  /root/poky/meta-selftest/lib
2024-02-02 14:03:00,202 - oe-selftest - INFO - Checking base configuration is valid/parsable
NOTE: Starting bitbake server...
2024-02-02 14:03:01,362 - oe-selftest - INFO - Adding: "include selftest.inc" in /root/poky/build-st/conf/local.conf
2024-02-02 14:03:01,363 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2024-02-02 14:03:01,363 - oe-selftest - INFO - test_syzkallerFuzzingQemux86_64 (syzkaller.TestSyzkaller)
2024-02-02 14:05:27,206 - oe-selftest - INFO - Running: syz-manager -config /root/fuzz_workdir0201/syzkaller.cfg
2024-02-02 14:05:27,887 - oe-selftest - INFO - 2024/02/02 14:05:27 [FATAL] bad config syzkaller param: can't find /root/poky/build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package/usr/bin/linux_amd64/syz-fuzzer
2024-02-02 14:05:27,911 - oe-selftest - INFO -  ... ok
2024-02-02 14:05:31,297 - oe-selftest - INFO - ----------------------------------------------------------------------
2024-02-02 14:05:31,297 - oe-selftest - INFO - Ran 1 test in 150.178s
2024-02-02 14:05:31,298 - oe-selftest - INFO - OK
2024-02-02 14:05:38,666 - oe-selftest - INFO - RESULTS:
2024-02-02 14:05:38,667 - oe-selftest - INFO - RESULTS - syzkaller.TestSyzkaller.test_syzkallerFuzzingQemux86_64: PASSED (146.55s)
2024-02-02 14:05:38,680 - oe-selftest - INFO - SUMMARY:
2024-02-02 14:05:38,680 - oe-selftest - INFO - oe-selftest () - Ran 1 test in 150.180s
2024-02-02 14:05:38,680 - oe-selftest - INFO - oe-selftest - OK - All required tests passed (successes=1, skipped=0, failures=0, errors=0)
root@localhost:/root/poky/build $ ls ../build-st/tmp/work/core2-64-poky-linux/syzkaller/git/
deploy-rpms          spdx                                sstate-install-package_qa         sstate-install-populate_lic      sysroot-destdir
license-destdir      sstate-install-create_runtime_spdx  sstate-install-package_write_rpm  sstate-install-populate_sysroot  temp
pkgdata-pdata-input  sstate-install-create_spdx          sstate-install-packagedata        sstate-install-recipe_qa
root@localhost:/root/poky/build $ ls ../build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package
ls: cannot access '../build-st/tmp/work/core2-64-poky-linux/syzkaller/git/package': No such file or directory
-----------------------

In order to fix this issue, I added following line in test case syzkaller.py, this is going to make syzkallar skip sstate creation.
SSTATE_SKIP_CREATION:pn-syzkaller = "1"
Then the test case will always finds 'syz-fuzzer' in the desired directory.

BTW, /root/fuzz_workdir0201/syzkaller.cfg is generated by test case syzkaller.py automatically.

Thanks,
Chi

> 
> > This is because oe-selftest will add "SSTATE_DIR" to local.conf,
> > bitbake will not build syzkaller again, then test case can not find
> > syz-fuzzer under work dirertory.
> > Fix this isseu with adding SSTATE_SKIP_CREATION:pn-syzkaller = "1"
> > to configure file.
> >
> > 2. Image name has been changed from core-image-minimal-qemux86-
> 64.ext4
> > to core-image-minimal-qemux86-64.rootfs.ext4, so update the defination
> > of self.rootfs.
> >
> > Signed-off-by: Xu, Chi <chi.xu@windriver.com>
> > ---
> >  meta-oe/lib/oeqa/selftest/cases/syzkaller.py | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> > b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> > index 64fc864bf..2c35ba230 100644
> > --- a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> > +++ b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
> > @@ -65,6 +65,7 @@ KERNEL_EXTRA_FEATURES += " \
> >      cfg/debug/syzkaller/debug-syzkaller.scc \  "
> >  IMAGE_INSTALL:append = " syzkaller"
> > +SSTATE_SKIP_CREATION:pn-syzkaller = "1"
> >  """
> >  % (self.machine, self.fstype))
> >
> > @@ -110,7 +111,7 @@ SYZ_QEMU_CPUS="2"'    # number of cpus used by
> each qemu VM
> >
> >          self.syz_cfg = os.path.join(self.syz_workdir, 'syzkaller.cfg')
> >          self.kernel = os.path.join(self.deploy_dir_image, 'bzImage')
> > -        self.rootfs = os.path.join(self.deploy_dir_image, '%s-%s.%s' %
> (self.image, self.machine, self.fstype))
> > +        self.rootfs = os.path.join(self.deploy_dir_image,
> > + '%s-%s.rootfs.%s' % (self.image, self.machine, self.fstype))
> >
> >          self.syz_native_sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE',
> > 'syzkaller-native')
> >
> > --
> > 2.25.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#108522):
> > https://lists.openembedded.org/g/openembedded-devel/message/108522
> > Mute This Topic: https://lists.openembedded.org/mt/104111739/1997914
> > Group Owner: openembedded-devel+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-
> devel/unsub
> > [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
diff mbox series

Patch

diff --git a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
index 64fc864bf..2c35ba230 100644
--- a/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
+++ b/meta-oe/lib/oeqa/selftest/cases/syzkaller.py
@@ -65,6 +65,7 @@  KERNEL_EXTRA_FEATURES += " \
     cfg/debug/syzkaller/debug-syzkaller.scc \
 "
 IMAGE_INSTALL:append = " syzkaller"
+SSTATE_SKIP_CREATION:pn-syzkaller = "1"
 """
 % (self.machine, self.fstype))
 
@@ -110,7 +111,7 @@  SYZ_QEMU_CPUS="2"'    # number of cpus used by each qemu VM
 
         self.syz_cfg = os.path.join(self.syz_workdir, 'syzkaller.cfg')
         self.kernel = os.path.join(self.deploy_dir_image, 'bzImage')
-        self.rootfs = os.path.join(self.deploy_dir_image, '%s-%s.%s' % (self.image, self.machine, self.fstype))
+        self.rootfs = os.path.join(self.deploy_dir_image, '%s-%s.rootfs.%s' % (self.image, self.machine, self.fstype))
 
         self.syz_native_sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'syzkaller-native')