Skip to contentSkip to conversation

Check compiled files to filter kernel CVEs

PATCH Superseded [email protected] 3 participants 19 messages Apr 29, 2025 – May 13, 2025 1 message not in the archive

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover Check compiled files to filter kernel CVEs

From: Daniel Turull <[email protected]>

Since kernel.org became a CNA, more information is available in the published CVEs, including details about which files are affected by a given CVE.

This series adds functionality to fetch the database from kernel.org CNA information:
git.kernel.org/pub/scm/linux/security/vulns.git

I have rewritten the original patch and integrated it with cve_check.py, cve_check, vex and create-spdx.

To filter out CVEs that are not applicable, we extract the files used during the kernel compilation and compare it with the metadata in the CVE.

The CVE_CHECK_KERNEL is enabled by default, but not the CVE_CHECK_KERNEL_CONFIG, since it needs to build the kernel and it is dependent on kernel configuration.

To include the files into SPDX, SPDX_INCLUDE_SOURCES needs to be enabled.

This could use as a base to run the vulnerability check independently and run an external tool to filter the CVEs.

In addition, we also integrate the data with the output of cve_check, vex, and create-spdx.

As a side effect of using better data from directly the kernel CNA, the number of vulnerabilities reported increases.

Numbers from 2025-04-28

Standing CVEs:
- Before: 18 CVEs, mostly old that needs to be checked and clean up in a new commit. There is only one from 2025
- Checking with kernel vulns database: 82 CVEs
- Checking with only compiled files: 46 CVEs

v1: initial proposal
v2:
- rewrite kernel_vulns to fetch similarly as cve-update-db-native
- add functionality into cve_check.py, for the classes that uses oe.get_patched_cves function
- add linux-vulns into the cve-check results
- add only compiled files in the spdx, so the check can be done outside the build
- include compiled files into spdx when CVE_CHECK_KERNEL_CONFIG and SPDX_INCLUDE_SOURCES is enabled
v3:
- make inclusion of compiled files generic for SPDX, so other systems that has knowledge of used files can also make more accurate sboms
- have the functions to extract files in kernel.bbclass. For other recipes that in the future want to use this feature can add the function in their recipe or in a build bbclass.
- move order of patches
- explicitly have the save_compiled_files added only when having the CVE_CHECK_KERNEL_CONFIG
- add first kernel cves in cve_check, so manual CVE_STATUS is preserved
- add CVE_STATUS for false positives

Daniel Turull

Daniel Turull (8):
linux-vulns: fetch kernel.org CNA info
cve-check: fix debug message
kernel: add support to extract compiled files
cve-check: move message outsite check_cves and sort
spdx: add option to include only compiled kernel files
cve-check: optionally allow to force update
cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE
reporting
cve-exclusions: correct CVE_STATUS

 meta/classes-recipe/kernel.bbclass          |  37 ++++
 meta/classes/create-spdx-2.2.bbclass        |   8 +
 meta/classes/cve-check.bbclass              |  51 +++--
 meta/classes/spdx-common.bbclass            |   4 +
 meta/classes/vex.bbclass                    |  11 +
 meta/conf/distro/include/maintainers.inc    |   1 +
 meta/lib/oe/cve_check.py                    | 211 +++++++++++++++++++-
 meta/lib/oe/spdx30_tasks.py                 |   8 +
 meta/recipes-core/meta/linux-vulns_git.bb   |  76 +++++++
 meta/recipes-kernel/linux/cve-exclusion.inc |  31 +++
 10 files changed, 424 insertions(+), 14 deletions(-)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb
#1 lore raw

PATCH v3 1/8 linux-vulns: fetch kernel.org CNA info

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb
meta/conf/distro/include/maintainers.inc +1 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <[email protected]>"
+RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]>"
meta/recipes-core/meta/linux-vulns_git.bb new file +76 -0

76 lines not on this page · raw message

#2 lore raw

Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Quoted 11 lines · Daniel Turull via lists.openembedded.org

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

Quoted 7 lines

---
 meta/conf/distro/include/maintainers.inc  |  1 + meta/recipes-core/meta/linux-vulns_git.bb | 76 +++++++++++++++++++++++

 2 files changed, 77 insertions(+)

 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb

If this is a real git repo, why can't we use a standard SRC_URI ?

That would avoid having to invent new mirror variables and so on?

Cheers,

Richard

#3 lore raw

RE: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi,

On the original patch I had it as normal SRC_URI, but I changed to the variable not to interfere with the fetcher. Now I tested and I see that SRC_URI just works fine.
I'll send a new patch with the change.

After the comment from Peter, I decided to skip the git fetcher since we need to use the latest version and AUTOREV is not working with offline builds.

The variable needs to be overridden in case we need to use a mirror. Or is it a way to use existing premirrors without the fetcher?

Thanks
Daniel

-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: Tuesday, 29 April 2025 16:43
To: Daniel Turull <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Quoted 11 lines · Daniel Turull via lists.openembedded.org

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

Quoted 8 lines

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb | 76
+++++++++++++++++++++++

 2 files changed, 77 insertions(+)

 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb

If this is a real git repo, why can't we use a standard SRC_URI ?

That would avoid having to invent new mirror variables and so on?

Cheers,

Richard

#4 lore raw

Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Quoted 7 lines · Daniel Turull

Hi,

On the original patch I had it as normal SRC_URI, but I changed to the variable not to interfere with the fetcher.
Now I tested and I see that SRC_URI just works fine. I'll send a new patch with the change.

Quoted 6 lines

After the comment from Peter, I decided to skip the git fetcher since we need to use the latest version and AUTOREV is not working with offline builds.

The variable needs to be overridden in case we need to use a mirror. Or is it a way to use existing premirrors without the fetcher?

Sounds good thanks.

It is true that we don't want our default install fetching floating revisions from git repos. I think we can do this by defaulting to a revision we update periodically and then have the classes/conf files set AUTOREV as/where needed so users opt into it.

I'd much rather do that and use the fetcher than trying to reinvent AUTOREV, mirroring and other things. We can improve the fetcher if needed too.

Cheers,

Richard

#5 lore raw

Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

In reply to [email protected]

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,
Marta

Quoted 139 lines · Daniel Turull via lists.openembedded.org

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb
meta/conf/distro/include/maintainers.inc +0 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <

[email protected]>"
RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <
[email protected]>" +RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned < [email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <
[email protected]>"

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
new file mode 100644
index 0000000000..fc48558eb8
@@ -0,0 +1,76 @@
+SUMMARY = "CVE information from kernel.org"
+DESCRIPTION = "Repo for tracking and maintaining the CVE identifiers

reserved \

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
+and assigned to the Linux kernel project."
+HOMEPAGE = "

https://git.kernel.org/pub/scm/linux/security/vulns.git/about/"

meta/recipes-core/meta/linux-vulns_git.bb new file +12 -0
+LICENSE = "GPL-2.0-only & cve-tou"
+SECTION = "base"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+inherit native
+inherit nopackages
+
+VULNS_URL ?= "https://git.kernel.org/pub/scm/linux/security/vulns"
+CVE_CHECK_KERNEL_DB_DIR ??= "${DL_DIR}/CVE_CHECK/vulns"
+
+# Use same intervals as cve-update-db-native. By default: once a day

(24*60*60).

meta/recipes-core/meta/linux-vulns_git.bb new file +38 -0
+# Use 0 to force the update
+# Use a negative value to skip the update
+
+CVE_DB_UPDATE_INTERVAL ??= "86400"
+
+python do_fetch(){
+    import os
+    import bb.utils
+
+    bb.utils.export_proxies(d)
+    db_file = d.getVar("CVE_CHECK_KERNEL_DB_DIR")
+    repo_url = d.getVar("VULNS_URL")
+
+    try:
+        import time
+        update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL"))
+
+        if update_interval < 0:
+            bb.note("Kernel CVE database update skipped")
+            return
+        if time.time() - os.path.getmtime(db_file) < update_interval:
+            bb.debug(2,"Kernel CVE database, recently updated, skipping")
+            return
+
+    except OSError:
+        pass
+
+    bb.utils.mkdirhier(os.path.dirname(db_file))
+    # Configure cmd
+    if not os.path.exists(db_file):
+        cmd = f"git clone {repo_url} {db_file}"
+    else:
+        cmd = f"git -C {db_file} pull"
+    try:
+        bb.fetch2.runfetchcmd(cmd, d)
+    except bb.fetch2.FetchError as e:
+        bb.warn(f"Kernel vulns repo url not accessible. {repo_url}")
+        bb.warn("Set VULNS_URL in local.conf to point to a local copy or

mirror")

meta/recipes-core/meta/linux-vulns_git.bb new file +22 -1
+}
+
+do_clean() {
+    rm -rf ${CVE_CHECK_KERNEL_DB_DIR}
+}
+
+deltask do_patch
+deltask do_unpack
+deltask do_configure
+deltask do_compile
+deltask do_install
+deltask do_populate_sysroot
+deltask do_runtime_spdx
+deltask do_create_spdx
+deltask do_populate_lic
+deltask do_cve_check
+
+do_fetch[nostamp] = "1"
+do_fetch[file-checksums] = ""
+do_fetch[vardeps] = ""
+
+EXCLUDE_FROM_WORLD = "1"
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group. View/Reply Online (#215667):
https://lists.openembedded.org/g/openembedded-core/message/215667
Mute This Topic: https://lists.openembedded.org/mt/112521333/5827677
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

RE: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi Marta,
The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,
Daniel

From: Marta Rybczynska <[email protected]>
Sent: Tuesday, 29 April 2025 16:48
To: Daniel Turull <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,
Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/> <[email protected]<mailto:[email protected]>> wrote:
From: Daniel Turull <[email protected]<mailto:[email protected]>>

Add CVE data source for kernel.org<http://kernel.org/>.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/>
meta/conf/distro/include/maintainers.inc +1 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
+RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> new file +76 -0

76 lines not on this page · raw message

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#215667): https://lists.openembedded.org/g/openembedded-core/message/215667
Mute This Topic: https://lists.openembedded.org/mt/112521333/5827677
Group Owner: [email protected]<mailto:openembedded-core%[email protected]>
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]<mailto:[email protected]>]
-=-=-=-=-=-=-=-=-=-=-=-

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

RE: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi again Marta,

I really appreciate your comments. You are doing a great job in this space.

With the post-processing do you mean another task after the do_cve_check or outside the build, maybe in a script in openembedded-core/scripts?

I see benefits in both (in the build and outside). If we keep it in the build we have more accurate data at the time of the build, while outside can be easily updated with new information. We also include missing information and add resilience having multiple sources.

Before sending another round of patches, I’ll like to reach some consensus how we should implement this, and your comments together with Peter’s and Richard’s will be very appreciated.

New proposal:

* Keep as option to extract the compiled file, and store them in spdx as well. Basically:
* kernel: add support to extract compiled files
* store the file in log/cve/ with a unique name
* spdx: add option to include only compiled kernel files

  *   Add option to have multiple sources of cve, in cve-check, using vulns or cvelistv5
  *   Keep the bug fixes, though probably I could send them independently from this series.
  *   And then we have 3 options:
     *   Keep the existing cve-check, vex, spdx: use metadata from linux-vulns
     *   Create a new a post-processing script in openembedded-core/scripts that triages CVEs with files that are not compiled that matches a CVEs, with similar functionality as the one proposed in cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting. But then in cveinfo in the SPDX won’t be accurate, since now I was adding the fixes in the get_patched_cves. On the other hand, this also get outdated, and for the not applicable with already have the CVE_STATUS.
     *   Have both 1 and 2, since they are not mutually exclusive. Now probably I’m lining more to this option.

For the new script, the first version of the script will take as input the output from the kernel gen_compile_commands.py, a directory to vulns or cvelistv5, and the cve-summary.json and generate a new cve-summary with updated information. This potentially could be integrated on the scripts that Marta has on vex or use as input. For example:

               ./improve_kernel_cve_reporting.py --sources compile_commands.json --cve-data <dir to vulns or cvelistv5> --old-cve-report cve-summary.json –new-cve-report cve-summary-enhance.json

How does it sound? Or do you have a better proposal?

And for the question comparing with using only the NVD database, I’m getting less CVEs, since some do not have their cpe, due to their big backlog.

I have modified slightly the patches and I can fetch the cvelistv5 repo, but it is slower since it contains much more files. But then I guess it could be used as a source for the cve_check as alternative source. CVE files as today:
Vulns: 5941
Cvelistv5: 291484

When comparing using data from cvelistv5 vs vulns, the functionally to exclude based on compiled files has the same results, except that with the former the script find more vulnerable CVEs, which later are corrected by the data from NVD.

Only NVD 14
linux-yocto-6.12.23+git-r0 do_cve_check: Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57995 CVE-2025-21751 CVE-2025-21833 CVE-2025-21949 CVE-2025-37838)

vulns: 33 vulnerable + 32 not applicable
CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

cvelistv5: 36 vulnerable + 32 not applicable
Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2021-28711 CVE-2021-28712 CVE-2021-28713 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

Best regards,
Daniel

From: [email protected] <[email protected]> On Behalf Of Daniel Turull via lists.openembedded.org
Sent: Tuesday, 29 April 2025 17:29
To: Marta Rybczynska <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi Marta,
The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,
Daniel

From: Marta Rybczynska <[email protected]<mailto:[email protected]>>
Sent: Tuesday, 29 April 2025 16:48
To: Daniel Turull <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,
Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/> <[email protected]<mailto:[email protected]>> wrote:
From: Daniel Turull <[email protected]<mailto:[email protected]>>

Add CVE data source for kernel.org<http://kernel.org/>.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/>
meta/conf/distro/include/maintainers.inc +1 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
+RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> new file +76 -0

76 lines not on this page · raw message

#9 lore raw

Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hell Daniel,
Thanks for the work. I plan to take some time in the next day to have a look and provide a viewpoint of what makes sense to do next.

BTW This code is shorter than I expect this work to be (and yes, there are multiple people working on the same), and this is good news. It makes a review way easier than I expected!

Kind regards,
Marta

Quoted 341 lines · Daniel Turull

Hi again Marta,

I really appreciate your comments. You are doing a great job in this space.

With the post-processing do you mean another task after the do_cve_check or outside the build, maybe in a script in openembedded-core/scripts?

I see benefits in both (in the build and outside). If we keep it in the build we have more accurate data at the time of the build, while outside can be easily updated with new information.

We also include missing information and add resilience having multiple sources.

Before sending another round of patches, I’ll like to reach some consensus how we should implement this, and your comments together with Peter’s and Richard’s will be very appreciated.

New proposal:

- Keep as option to extract the compiled file, and store them in spdx as well. Basically:
1. kernel: add support to extract compiled files
- store the file in log/cve/ with a unique name
2. spdx: add option to include only compiled kernel files
- Add option to have multiple sources of cve, in cve-check, using vulns or cvelistv5
- Keep the bug fixes, though probably I could send them independently from this series.
- And then we have 3 options:
1. Keep the existing cve-check, vex, spdx: use metadata from linux-vulns
2. Create a new a post-processing script in openembedded-core/scripts that triages CVEs with files that are not compiled that matches a CVEs, with similar functionality as the one proposed in cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting. But then in cveinfo in the SPDX won’t be accurate, since now I was adding the fixes in the get_patched_cves. On the other hand, this also get outdated, and for the not applicable with already have the CVE_STATUS.
3. Have both 1 and 2, since they are not mutually exclusive. Now probably I’m lining more to this option.

For the new script, the first version of the script will take as input the output from the kernel gen_compile_commands.py, a directory to vulns or cvelistv5, and the cve-summary.json and generate a new cve-summary with updated information. This potentially could be integrated on the scripts that Marta has on vex or use as input. For example:

               ./improve_kernel_cve_reporting.py --sources

compile_commands.json --cve-data <dir to vulns or cvelistv5> --old-cve-report cve-summary.json –new-cve-report cve-summary-enhance.json

How does it sound? Or do you have a better proposal?

And for the question comparing with using only the NVD database, I’m getting less CVEs, since some do not have their cpe, due to their big backlog.

I have modified slightly the patches and I can fetch the cvelistv5 repo, but it is slower since it contains much more files. But then I guess it could be used as a source for the cve_check as alternative source.

CVE files as today:

Vulns: 5941

Cvelistv5: 291484

When comparing using data from cvelistv5 vs vulns, the functionally to exclude based on compiled files has the same results, except that with the former the script find more vulnerable CVEs, which later are corrected by the data from NVD.

Only NVD 14

linux-yocto-6.12.23+git-r0 do_cve_check: Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57995 CVE-2025-21751 CVE-2025-21833 CVE-2025-21949 CVE-2025-37838)

vulns: 33 vulnerable + 32 not applicable

CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

cvelistv5: 36 vulnerable + 32 not applicable

Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2021-28711 CVE-2021-28712 CVE-2021-28713 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

Best regards,

Daniel

*From:* [email protected] < [email protected]> *On Behalf Of *Daniel Turull via lists.openembedded.org
*Sent:* Tuesday, 29 April 2025 17:29
*To:* Marta Rybczynska <[email protected]>
*Cc:* [email protected]; [email protected] *Subject:* Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi Marta,

The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,

Daniel

*From:* Marta Rybczynska <[email protected]>
*Sent:* Tuesday, 29 April 2025 16:48
*To:* Daniel Turull <[email protected]>
*Cc:* [email protected]; [email protected] *Subject:* Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,

Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org <[email protected]> wrote:

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb
meta/conf/distro/include/maintainers.inc +0 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <

[email protected]>"
RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <
[email protected]>" +RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned < [email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <
[email protected]>"

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
new file mode 100644
index 0000000000..fc48558eb8
@@ -0,0 +1,76 @@
+SUMMARY = "CVE information from kernel.org"
+DESCRIPTION = "Repo for tracking and maintaining the CVE identifiers

reserved \

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
+and assigned to the Linux kernel project."
+HOMEPAGE = "

https://git.kernel.org/pub/scm/linux/security/vulns.git/about/"

meta/recipes-core/meta/linux-vulns_git.bb new file +12 -0
+LICENSE = "GPL-2.0-only & cve-tou"
+SECTION = "base"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+inherit native
+inherit nopackages
+
+VULNS_URL ?= "https://git.kernel.org/pub/scm/linux/security/vulns"
+CVE_CHECK_KERNEL_DB_DIR ??= "${DL_DIR}/CVE_CHECK/vulns"
+
+# Use same intervals as cve-update-db-native. By default: once a day

(24*60*60).

meta/recipes-core/meta/linux-vulns_git.bb new file +38 -0
+# Use 0 to force the update
+# Use a negative value to skip the update
+
+CVE_DB_UPDATE_INTERVAL ??= "86400"
+
+python do_fetch(){
+    import os
+    import bb.utils
+
+    bb.utils.export_proxies(d)
+    db_file = d.getVar("CVE_CHECK_KERNEL_DB_DIR")
+    repo_url = d.getVar("VULNS_URL")
+
+    try:
+        import time
+        update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL"))
+
+        if update_interval < 0:
+            bb.note("Kernel CVE database update skipped")
+            return
+        if time.time() - os.path.getmtime(db_file) < update_interval:
+            bb.debug(2,"Kernel CVE database, recently updated, skipping")
+            return
+
+    except OSError:
+        pass
+
+    bb.utils.mkdirhier(os.path.dirname(db_file))
+    # Configure cmd
+    if not os.path.exists(db_file):
+        cmd = f"git clone {repo_url} {db_file}"
+    else:
+        cmd = f"git -C {db_file} pull"
+    try:
+        bb.fetch2.runfetchcmd(cmd, d)
+    except bb.fetch2.FetchError as e:
+        bb.warn(f"Kernel vulns repo url not accessible. {repo_url}")
+        bb.warn("Set VULNS_URL in local.conf to point to a local copy or

mirror")

meta/recipes-core/meta/linux-vulns_git.bb new file +22 -0
+}
+
+do_clean() {
+    rm -rf ${CVE_CHECK_KERNEL_DB_DIR}
+}
+
+deltask do_patch
+deltask do_unpack
+deltask do_configure
+deltask do_compile
+deltask do_install
+deltask do_populate_sysroot
+deltask do_runtime_spdx
+deltask do_create_spdx
+deltask do_populate_lic
+deltask do_cve_check
+
+do_fetch[nostamp] = "1"
+do_fetch[file-checksums] = ""
+do_fetch[vardeps] = ""
+
+EXCLUDE_FROM_WORLD = "1"
#10 lore raw

RE: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hello Marta,
Did you had time to look at it and how to continue the work?

Will it make sense that for know I reduce the scope and only add the option to extract the compiled files in a “log” file and into the spdx sources? And have the processing in a script in the script/contrib folder. Then the logic can be used to have the independent tool. We already have part of the logic in meta/recipes-kernel/linux/generate-cve-exclusions.py

Thanks

Daniel

From: [email protected] <[email protected]> On Behalf Of Marta Rybczynska via lists.openembedded.org
Sent: Wednesday, 30 April 2025 17:04
To: Daniel Turull <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hell Daniel,
Thanks for the work. I plan to take some time in the next day to have a look and provide a viewpoint of what makes sense to do next.

BTW This code is shorter than I expect this work to be (and yes, there are multiple people working on the same), and this is good news. It makes a review way easier than I expected!

Kind regards,
Marta

On Wed, Apr 30, 2025 at 10:32 AM Daniel Turull <[email protected]<mailto:[email protected]>> wrote:
Hi again Marta,

I really appreciate your comments. You are doing a great job in this space.

With the post-processing do you mean another task after the do_cve_check or outside the build, maybe in a script in openembedded-core/scripts?

I see benefits in both (in the build and outside). If we keep it in the build we have more accurate data at the time of the build, while outside can be easily updated with new information. We also include missing information and add resilience having multiple sources.

Before sending another round of patches, I’ll like to reach some consensus how we should implement this, and your comments together with Peter’s and Richard’s will be very appreciated.

New proposal:

* Keep as option to extract the compiled file, and store them in spdx as well. Basically:

* kernel: add support to extract compiled files

* store the file in log/cve/ with a unique name

* spdx: add option to include only compiled kernel files

  *   Add option to have multiple sources of cve, in cve-check, using vulns or cvelistv5
  *   Keep the bug fixes, though probably I could send them independently from this series.
  *   And then we have 3 options:
     *   Keep the existing cve-check, vex, spdx: use metadata from linux-vulns
     *   Create a new a post-processing script in openembedded-core/scripts that triages CVEs with files that are not compiled that matches a CVEs, with similar functionality as the one proposed in cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting. But then in cveinfo in the SPDX won’t be accurate, since now I was adding the fixes in the get_patched_cves. On the other hand, this also get outdated, and for the not applicable with already have the CVE_STATUS.
     *   Have both 1 and 2, since they are not mutually exclusive. Now probably I’m lining more to this option.

For the new script, the first version of the script will take as input the output from the kernel gen_compile_commands.py, a directory to vulns or cvelistv5, and the cve-summary.json and generate a new cve-summary with updated information. This potentially could be integrated on the scripts that Marta has on vex or use as input. For example:

               ./improve_kernel_cve_reporting.py --sources compile_commands.json --cve-data <dir to vulns or cvelistv5> --old-cve-report cve-summary.json –new-cve-report cve-summary-enhance.json

How does it sound? Or do you have a better proposal?

And for the question comparing with using only the NVD database, I’m getting less CVEs, since some do not have their cpe, due to their big backlog.

I have modified slightly the patches and I can fetch the cvelistv5 repo, but it is slower since it contains much more files. But then I guess it could be used as a source for the cve_check as alternative source. CVE files as today:
Vulns: 5941
Cvelistv5: 291484

When comparing using data from cvelistv5 vs vulns, the functionally to exclude based on compiled files has the same results, except that with the former the script find more vulnerable CVEs, which later are corrected by the data from NVD.

Only NVD 14
linux-yocto-6.12.23+git-r0 do_cve_check: Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57995 CVE-2025-21751 CVE-2025-21833 CVE-2025-21949 CVE-2025-37838)

vulns: 33 vulnerable + 32 not applicable
CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

cvelistv5: 36 vulnerable + 32 not applicable
Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2021-28711 CVE-2021-28712 CVE-2021-28713 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

Best regards,
Daniel

From: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> On Behalf Of Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/>
Sent: Tuesday, 29 April 2025 17:29
To: Marta Rybczynska <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org<http://kernel.org/> CNA info

Hi Marta,
The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,
Daniel

From: Marta Rybczynska <[email protected]<mailto:[email protected]>>
Sent: Tuesday, 29 April 2025 16:48
To: Daniel Turull <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org<http://kernel.org/> CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,
Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/> <[email protected]<mailto:[email protected]>> wrote:
From: Daniel Turull <[email protected]<mailto:[email protected]>>

Add CVE data source for kernel.org<http://kernel.org/>.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/>
meta/conf/distro/include/maintainers.inc +1 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
+RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> new file +76 -0

76 lines not on this page · raw message

#11 lore raw

Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hello Daniel,
I have had a look and I think that a post-processing tool is the right way to go. If you have the file list in SPDX, you can do checks, and possibly with other metadata (the kernel CVE database does not list affected kernel options, and that would be a really valuable information source for such a kind of a check). It will also be code way easier to maintain, as version checks are complex to perform and debug.

Where we're at this: there will be a need to add information about what kind of CVE filtering has been done (the default, filtering by files etc). This might be necessary for maintenance reasons and when you will be comparing check results between firmware versions et al. A kind of "used_tools" kind of a field will be necessary.

Kind regards,
Marta

Quoted 408 lines · Daniel Turull

Hello Marta,

Did you had time to look at it and how to continue the work?

Will it make sense that for know I reduce the scope and only add the option to extract the compiled files in a “log” file and into the spdx sources? And have the processing in a script in the script/contrib folder.

Then the logic can be used to have the independent tool. We already have part of the logic in meta/recipes-kernel/linux/generate-cve-exclusions.py

Thanks

Daniel

*From:* [email protected] < [email protected]> *On Behalf Of *Marta Rybczynska via lists.openembedded.org
*Sent:* Wednesday, 30 April 2025 17:04
*To:* Daniel Turull <[email protected]>
*Cc:* [email protected]; [email protected]; [email protected]
*Subject:* Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hell Daniel,

Thanks for the work. I plan to take some time in the next day to have a look and provide a viewpoint of what makes sense to do next.

BTW This code is shorter than I expect this work to be (and yes, there are multiple people working on the same), and this is good news. It makes a review way easier than I expected!

Kind regards,

Marta

On Wed, Apr 30, 2025 at 10:32 AM Daniel Turull <[email protected]> wrote:

Hi again Marta,

I really appreciate your comments. You are doing a great job in this space.

With the post-processing do you mean another task after the do_cve_check or outside the build, maybe in a script in openembedded-core/scripts?

I see benefits in both (in the build and outside). If we keep it in the build we have more accurate data at the time of the build, while outside can be easily updated with new information.

We also include missing information and add resilience having multiple sources.

Before sending another round of patches, I’ll like to reach some consensus how we should implement this, and your comments together with Peter’s and Richard’s will be very appreciated.

New proposal:

- Keep as option to extract the compiled file, and store them in spdx as well. Basically:

1. kernel: add support to extract compiled files

- store the file in log/cve/ with a unique name

2. spdx: add option to include only compiled kernel files

- Add option to have multiple sources of cve, in cve-check, using vulns or cvelistv5
- Keep the bug fixes, though probably I could send them independently from this series.
- And then we have 3 options:

1. Keep the existing cve-check, vex, spdx: use metadata from linux-vulns
2. Create a new a post-processing script in openembedded-core/scripts that triages CVEs with files that are not compiled that matches a CVEs, with similar functionality as the one proposed in cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting. But then in cveinfo in the SPDX won’t be accurate, since now I was adding the fixes in the get_patched_cves. On the other hand, this also get outdated, and for the not applicable with already have the CVE_STATUS.
3. Have both 1 and 2, since they are not mutually exclusive. Now probably I’m lining more to this option.

For the new script, the first version of the script will take as input the output from the kernel gen_compile_commands.py, a directory to vulns or cvelistv5, and the cve-summary.json and generate a new cve-summary with updated information. This potentially could be integrated on the scripts that Marta has on vex or use as input. For example:

               ./improve_kernel_cve_reporting.py --sources

compile_commands.json --cve-data <dir to vulns or cvelistv5> --old-cve-report cve-summary.json –new-cve-report cve-summary-enhance.json

How does it sound? Or do you have a better proposal?

And for the question comparing with using only the NVD database, I’m getting less CVEs, since some do not have their cpe, due to their big backlog.

I have modified slightly the patches and I can fetch the cvelistv5 repo, but it is slower since it contains much more files. But then I guess it could be used as a source for the cve_check as alternative source.

CVE files as today:

Vulns: 5941

Cvelistv5: 291484

When comparing using data from cvelistv5 vs vulns, the functionally to exclude based on compiled files has the same results, except that with the former the script find more vulnerable CVEs, which later are corrected by the data from NVD.

Only NVD 14

linux-yocto-6.12.23+git-r0 do_cve_check: Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57995 CVE-2025-21751 CVE-2025-21833 CVE-2025-21949 CVE-2025-37838)

vulns: 33 vulnerable + 32 not applicable

CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

cvelistv5: 36 vulnerable + 32 not applicable

Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2021-28711 CVE-2021-28712 CVE-2021-28713 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

Best regards,

Daniel

*From:* [email protected] < [email protected]> *On Behalf Of *Daniel Turull via lists.openembedded.org
*Sent:* Tuesday, 29 April 2025 17:29
*To:* Marta Rybczynska <[email protected]>
*Cc:* [email protected]; [email protected] *Subject:* Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hi Marta,

The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,

Daniel

*From:* Marta Rybczynska <[email protected]>
*Sent:* Tuesday, 29 April 2025 16:48
*To:* Daniel Turull <[email protected]>
*Cc:* [email protected]; [email protected] *Subject:* Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,

Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org <[email protected]> wrote:

From: Daniel Turull <[email protected]>

Add CVE data source for kernel.org.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb
meta/conf/distro/include/maintainers.inc +0 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <

[email protected]>"
RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <
[email protected]>" +RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned < [email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <
[email protected]>"
RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <
[email protected]>"

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
new file mode 100644
index 0000000000..fc48558eb8
@@ -0,0 +1,76 @@
+SUMMARY = "CVE information from kernel.org"
+DESCRIPTION = "Repo for tracking and maintaining the CVE identifiers

reserved \

meta/recipes-core/meta/linux-vulns_git.bb new file +2 -0
+and assigned to the Linux kernel project."
+HOMEPAGE = "

https://git.kernel.org/pub/scm/linux/security/vulns.git/about/"

meta/recipes-core/meta/linux-vulns_git.bb new file +12 -0
+LICENSE = "GPL-2.0-only & cve-tou"
+SECTION = "base"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+inherit native
+inherit nopackages
+
+VULNS_URL ?= "https://git.kernel.org/pub/scm/linux/security/vulns"
+CVE_CHECK_KERNEL_DB_DIR ??= "${DL_DIR}/CVE_CHECK/vulns"
+
+# Use same intervals as cve-update-db-native. By default: once a day

(24*60*60).

meta/recipes-core/meta/linux-vulns_git.bb new file +38 -0
+# Use 0 to force the update
+# Use a negative value to skip the update
+
+CVE_DB_UPDATE_INTERVAL ??= "86400"
+
+python do_fetch(){
+    import os
+    import bb.utils
+
+    bb.utils.export_proxies(d)
+    db_file = d.getVar("CVE_CHECK_KERNEL_DB_DIR")
+    repo_url = d.getVar("VULNS_URL")
+
+    try:
+        import time
+        update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL"))
+
+        if update_interval < 0:
+            bb.note("Kernel CVE database update skipped")
+            return
+        if time.time() - os.path.getmtime(db_file) < update_interval:
+            bb.debug(2,"Kernel CVE database, recently updated, skipping")
+            return
+
+    except OSError:
+        pass
+
+    bb.utils.mkdirhier(os.path.dirname(db_file))
+    # Configure cmd
+    if not os.path.exists(db_file):
+        cmd = f"git clone {repo_url} {db_file}"
+    else:
+        cmd = f"git -C {db_file} pull"
+    try:
+        bb.fetch2.runfetchcmd(cmd, d)
+    except bb.fetch2.FetchError as e:
+        bb.warn(f"Kernel vulns repo url not accessible. {repo_url}")
+        bb.warn("Set VULNS_URL in local.conf to point to a local copy or

mirror")

meta/recipes-core/meta/linux-vulns_git.bb new file +22 -0
+}
+
+do_clean() {
+    rm -rf ${CVE_CHECK_KERNEL_DB_DIR}
+}
+
+deltask do_patch
+deltask do_unpack
+deltask do_configure
+deltask do_compile
+deltask do_install
+deltask do_populate_sysroot
+deltask do_runtime_spdx
+deltask do_create_spdx
+deltask do_populate_lic
+deltask do_cve_check
+
+do_fetch[nostamp] = "1"
+do_fetch[file-checksums] = ""
+do_fetch[vardeps] = ""
+
+EXCLUDE_FROM_WORLD = "1"
#12 lore raw

RE: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Thank you Marta for the feedback. After a bit more though I reach the same conclusion.

I’ve been working a bit in parallel and I’ll send some patches going into that direction. I’ll send a new revision of my series later this week, with an independent post-processing script in scripts/contrib.

I’ll have the list a simpler text file with the list of compiled files as well as included as spdx. For now the script will take the simpler list, since it requires less processing.

Best regards,
Daniel

From: Marta Rybczynska <[email protected]>
Sent: Tuesday, 13 May 2025 15:33
To: Daniel Turull <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org CNA info

Hello Daniel,
I have had a look and I think that a post-processing tool is the right way to go. If you have the file list in SPDX, you can do checks, and possibly with other metadata (the kernel CVE database does not list affected kernel options, and that would be a really valuable information source for such a kind of a check). It will also be code way easier to maintain, as version checks are complex to perform and debug.

Where we're at this: there will be a need to add information about what kind of CVE filtering has been done (the default, filtering by files etc). This might be necessary for maintenance reasons and when you will be comparing check results between firmware versions et al. A kind of "used_tools" kind of a field will be necessary.

Kind regards,
Marta

On Wed, May 7, 2025 at 10:05 AM Daniel Turull <[email protected]<mailto:[email protected]>> wrote:
Hello Marta,
Did you had time to look at it and how to continue the work?

Will it make sense that for know I reduce the scope and only add the option to extract the compiled files in a “log” file and into the spdx sources? And have the processing in a script in the script/contrib folder. Then the logic can be used to have the independent tool. We already have part of the logic in meta/recipes-kernel/linux/generate-cve-exclusions.py

Thanks

Daniel

From: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> On Behalf Of Marta Rybczynska via lists.openembedded.org<http://lists.openembedded.org/>
Sent: Wednesday, 30 April 2025 17:04
To: Daniel Turull <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org<http://kernel.org/> CNA info

Hell Daniel,
Thanks for the work. I plan to take some time in the next day to have a look and provide a viewpoint of what makes sense to do next.

BTW This code is shorter than I expect this work to be (and yes, there are multiple people working on the same), and this is good news. It makes a review way easier than I expected!

Kind regards,
Marta

On Wed, Apr 30, 2025 at 10:32 AM Daniel Turull <[email protected]<mailto:[email protected]>> wrote:
Hi again Marta,

I really appreciate your comments. You are doing a great job in this space.

With the post-processing do you mean another task after the do_cve_check or outside the build, maybe in a script in openembedded-core/scripts?

I see benefits in both (in the build and outside). If we keep it in the build we have more accurate data at the time of the build, while outside can be easily updated with new information. We also include missing information and add resilience having multiple sources.

Before sending another round of patches, I’ll like to reach some consensus how we should implement this, and your comments together with Peter’s and Richard’s will be very appreciated.

New proposal:

* Keep as option to extract the compiled file, and store them in spdx as well. Basically:

* kernel: add support to extract compiled files

* store the file in log/cve/ with a unique name

* spdx: add option to include only compiled kernel files

  *   Add option to have multiple sources of cve, in cve-check, using vulns or cvelistv5
  *   Keep the bug fixes, though probably I could send them independently from this series.
  *   And then we have 3 options:
     *   Keep the existing cve-check, vex, spdx: use metadata from linux-vulns
     *   Create a new a post-processing script in openembedded-core/scripts that triages CVEs with files that are not compiled that matches a CVEs, with similar functionality as the one proposed in cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting. But then in cveinfo in the SPDX won’t be accurate, since now I was adding the fixes in the get_patched_cves. On the other hand, this also get outdated, and for the not applicable with already have the CVE_STATUS.
     *   Have both 1 and 2, since they are not mutually exclusive. Now probably I’m lining more to this option.

For the new script, the first version of the script will take as input the output from the kernel gen_compile_commands.py, a directory to vulns or cvelistv5, and the cve-summary.json and generate a new cve-summary with updated information. This potentially could be integrated on the scripts that Marta has on vex or use as input. For example:

               ./improve_kernel_cve_reporting.py --sources compile_commands.json --cve-data <dir to vulns or cvelistv5> --old-cve-report cve-summary.json –new-cve-report cve-summary-enhance.json

How does it sound? Or do you have a better proposal?

And for the question comparing with using only the NVD database, I’m getting less CVEs, since some do not have their cpe, due to their big backlog.

I have modified slightly the patches and I can fetch the cvelistv5 repo, but it is slower since it contains much more files. But then I guess it could be used as a source for the cve_check as alternative source. CVE files as today:
Vulns: 5941
Cvelistv5: 291484

When comparing using data from cvelistv5 vs vulns, the functionally to exclude based on compiled files has the same results, except that with the former the script find more vulnerable CVEs, which later are corrected by the data from NVD.

Only NVD 14
linux-yocto-6.12.23+git-r0 do_cve_check: Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57995 CVE-2025-21751 CVE-2025-21833 CVE-2025-21949 CVE-2025-37838)

vulns: 33 vulnerable + 32 not applicable
CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

cvelistv5: 36 vulnerable + 32 not applicable
Found unpatched CVE (CVE-1999-0524 CVE-2008-4609 CVE-2010-4563 CVE-2021-28711 CVE-2021-28712 CVE-2021-28713 CVE-2022-0400 CVE-2022-38096 CVE-2022-4543 CVE-2023-3397 CVE-2023-4010 CVE-2023-6240 CVE-2024-57976 CVE-2024-58074 CVE-2024-58093 CVE-2025-21709 CVE-2025-21752 CVE-2025-21807 CVE-2025-21817 CVE-2025-21833 CVE-2025-21837 CVE-2025-21884 CVE-2025-22026 CVE-2025-22105 CVE-2025-22108 CVE-2025-22111 CVE-2025-22113 CVE-2025-22115 CVE-2025-22121 CVE-2025-22122 CVE-2025-22124 CVE-2025-22125 CVE-2025-22126 CVE-2025-23137 CVE-2025-37838 CVE-2025-40325)

Best regards,
Daniel

From: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> On Behalf Of Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/>
Sent: Tuesday, 29 April 2025 17:29
To: Marta Rybczynska <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org<http://kernel.org/> CNA info

Hi Marta,
The CVE database from NVD doesn’t have all the metadata, specially the files affected.

I’ll test it with https://github.com/CVEProject/cvelistV5, since the data from the kernel should be the same. But the repository is much bigger.

No, I haven’t tested with world builds. I’ll give it a try. Probably the file that I’m generating with should be specific for a config, so we don’t override it.

Best regards,
Daniel

From: Marta Rybczynska <[email protected]<mailto:[email protected]>>
Sent: Tuesday, 29 April 2025 16:48
To: Daniel Turull <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>
Subject: Re: [OE-core] [PATCH v3 1/8] linux-vulns: fetch kernel.org<http://kernel.org/> CNA info

Thank you for providing this work Daniel.

Are you able to obtain the same result with the raw CVE database? This patchset works for the Linux kernel only.

Also, have you tested if it works with the world build for multiple kernel images (i.e. different configs) from the same source tree?

I would be rather going for a post-processing with a given config after generating the json files instead of modifying the processing.

My 0.02.

Kind regards,
Marta

On Tue, Apr 29, 2025 at 4:39 PM Daniel Turull via lists.openembedded.org<http://lists.openembedded.org/> <[email protected]<mailto:[email protected]>> wrote:
From: Daniel Turull <[email protected]<mailto:[email protected]>>

Add CVE data source for kernel.org<http://kernel.org/>.

It includes more information than the one provided by NVD. Use similar mechanism and same variables as cve-check to define when to update.

To use without internet access, change variable VULNS_URL to a local copy or mirror.

---
 meta/conf/distro/include/maintainers.inc  |  1 +
 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> | 76 +++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/>
meta/conf/distro/include/maintainers.inc +1 -0
index 8065287c17..ec427fe6a4 100644
@@ -468,6 +468,7 @@ RECIPE_MAINTAINER:pn-lighttpd = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-dummy = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-firmware = "Otavio Salvador <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-libc-headers = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
+RECIPE_MAINTAINER:pn-linux-vulns = "Unassigned <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]<mailto:[email protected]>>"
meta/recipes-core/meta/linux-vulns_git.bb<http://linux-vulns_git.bb/> new file +76 -0

76 lines not on this page · raw message

#13 lore raw

PATCH v3 2/8 cve-check: fix debug message

In reply to [email protected]

From: Daniel Turull <[email protected]>

Debug level was not added as a parameter, causing a warning.

---
 meta/classes/cve-check.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/classes/cve-check.bbclass +4 -4
index 1aef00d297..c63ebd56e1 100644
@@ -277,7 +277,7 @@ def cve_update(d, cve_data, cve, entry):
         cve_data[cve] = entry
         return
     # If we are updating, there might be change in the status
-    bb.debug("Trying CVE entry update for %s from %s to %s" % (cve, cve_data[cve]['abbrev-status'], entry['abbrev-status']))
+    bb.debug(1, "Trying CVE entry update for %s from %s to %s" % (cve, cve_data[cve]['abbrev-status'], entry['abbrev-status']))
     if cve_data[cve]['abbrev-status'] == "Unknown":
         cve_data[cve] = entry
         return
@@ -288,16 +288,16 @@ def cve_update(d, cve_data, cve, entry):
         if entry['status'] == "version-in-range" and cve_data[cve]['status'] == "version-not-in-range":
             # New result from the scan, vulnerable
             cve_data[cve] = entry
-            bb.debug("CVE entry %s update from Patched to Unpatched from the scan result" % cve)
+            bb.debug(1, "CVE entry %s update from Patched to Unpatched from the scan result" % cve)
             return
     if entry['abbrev-status'] == "Patched" and cve_data[cve]['abbrev-status'] == "Unpatched":
         if entry['status'] == "version-not-in-range" and cve_data[cve]['status'] == "version-in-range":
             # Range does not match the scan, but we already have a vulnerable match, ignore
-            bb.debug("CVE entry %s update from Patched to Unpatched from the scan result - not applying" % cve)
+            bb.debug(1, "CVE entry %s update from Patched to Unpatched from the scan result - not applying" % cve)
             return
     # If we have an "Ignored", it has a priority
     if cve_data[cve]['abbrev-status'] == "Ignored":
-        bb.debug("CVE %s not updating because Ignored" % cve)
+        bb.debug(1, "CVE %s not updating because Ignored" % cve)
         return
     bb.warn("Unhandled CVE entry update for %s from %s to %s" % (cve, cve_data[cve], entry))
 
#14 lore raw

PATCH v3 3/8 kernel: add support to extract compiled files

In reply to [email protected]

From: Daniel Turull <[email protected]>

Use gen_compile_commands.py to extract files used during compilation for the used kernel configuration.

CC Bruce Ashfield <[email protected]>
CC Peter Marko <[email protected]>
---
 meta/classes-recipe/kernel.bbclass | 37 ++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
meta/classes-recipe/kernel.bbclass +37 -0
index 36ce659762..e321f6e228 100644
@@ -159,6 +159,8 @@ set -e
     image_task = d.getVar('INITRAMFS_TASK')
     if image_task:
         d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
+    if d.getVar('CVE_CHECK_KERNEL_CONFIG') == '1':
+         bb.build.addtask('do_save_compiled_files', None, 'do_compile do_compile_kernelmodules', d)
 }
 
 # Here we pull in all various kernel image types which we support.
@@ -867,3 +869,38 @@ EXPORT_FUNCTIONS do_deploy
 
 # Add using Device Tree support
 inherit kernel-devicetree
+
+KERNEL_FILES_DIR ?= "${LOG_DIR}/cve/kernel_files"
+KERNEL_SRC_FILES ?= "${KERNEL_FILES_DIR}/compile_commands.json"
+
+do_save_compiled_files() {
+    bbdebug 1 "Saving compiled files in ${KERNEL_SRC_FILES}"
+    mkdir -p ${KERNEL_FILES_DIR}
+    ${S}/scripts/clang-tools/gen_compile_commands.py -o ${KERNEL_SRC_FILES} -d ${B}
+}
+
+# Helper functions for spdx and cve-check
+# Check if the file, is a kernel compiled file
+def is_compiled_source(d, filename, kernel_sources):
+    import os
+
+    _, extension = os.path.splitext(filename)
+    # Special case, that we need to ignore, since this is not a source file
+    # We filter .c files
+    if filename.rfind(".mod.c") > 0 or extension != ".c":
+        return True
+    # Check that the c file is in the list
+    if filename in kernel_sources:
+        return True
+    return False
+
+# Get results from the save_compiled files and include also header files, extracting path
+def get_compiled_sources(d):
+    import json
+    import os
+    kfiles = []
+    with open(d.getVar('KERNEL_SRC_FILES'), 'r') as f:
+        for item in json.load(f):
+            kfile = os.path.basename(item['file'])
+            kfiles.append(kfile)
+    return kfiles
#15 lore raw

PATCH v3 4/8 cve-check: move message outsite check_cves and sort

In reply to [email protected]

From: Daniel Turull <[email protected]>

When adding corrections from multiple sources of CVEs, the message showing standing CVES should be at the end. Also sort them.

---
 meta/classes/cve-check.bbclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/classes/cve-check.bbclass +6 -4
index c63ebd56e1..cce10c70ee 100644
@@ -173,6 +173,12 @@ python do_cve_check () {
             if len(cve_data) or (d.getVar("CVE_CHECK_COVERAGE") == "1" and status):
                 get_cve_info(d, cve_data)
                 cve_write_data(d, cve_data, status)
+
+            if d.getVar("CVE_CHECK_SHOW_WARNINGS") == "1":
+                unpatched_cves = [cve for cve in cve_data if cve_data[cve]["abbrev-status"] == "Unpatched"]
+                if unpatched_cves:
+                    bb.warn("Found unpatched CVE (%s)" % " ".join(sorted(unpatched_cves)))
+
         else:
             bb.note("No CVE database found, skipping CVE check")
 
@@ -422,10 +428,6 @@ def check_cves(d, cve_data):
     if not cves_in_recipe:
         bb.note("No CVE records for products in recipe %s" % (pn))
 
-    if d.getVar("CVE_CHECK_SHOW_WARNINGS") == "1":
-        unpatched_cves = [cve for cve in cve_data if cve_data[cve]["abbrev-status"] == "Unpatched"]
-        if unpatched_cves:
-            bb.warn("Found unpatched CVE (%s)" % " ".join(unpatched_cves))
 
     return (cve_data, cves_status)
 
#16 lore raw

PATCH v3 5/8 spdx: add option to include only compiled kernel files

In reply to [email protected]

From: Daniel Turull <[email protected]>

When CVE_CHECK_KERNEL_CONFIG is enabled, only include the source code (.c, .h) files that are used during compilation.

This enables an external tool to use the SPDX information to disregard vulnerabilities that are not compiled.

CC Joshua Watt <[email protected]>
CC Peter Marko <[email protected]>
---
 meta/classes/create-spdx-2.2.bbclass | 8 ++++++++
 meta/classes/spdx-common.bbclass     | 1 +
 meta/lib/oe/spdx30_tasks.py          | 8 ++++++++
 3 files changed, 17 insertions(+)
meta/classes/create-spdx-2.2.bbclass +8 -0
index 7e8f8b9ff5..5009ebf5f1 100644
@@ -137,6 +137,10 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
     spdx_files = []
 
     file_counter = 1
+
+    check_compiled_sources = d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1"
+    if check_compiled_sources:
+        compiled_sources = bb.build.exec_func('get_compiled_sources', d)
     for subdir, dirs, files in os.walk(topdir):
         dirs[:] = [d for d in dirs if d not in ignore_dirs]
         if subdir == str(topdir):
@@ -147,6 +151,10 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
             filename = str(filepath.relative_to(topdir))
 
             if not filepath.is_symlink() and filepath.is_file():
+                # Check if file is compiled
+                if check_compiled_sources:
+                     if not bb.build.exec_func('is_compiled_source', d, file, kernel_sources):
+                          break
                 spdx_file = oe.spdx.SPDXFile()
                 spdx_file.SPDXID = get_spdxid(file_counter)
                 for t in get_types(filepath):
meta/classes/spdx-common.bbclass +1 -0
index 713a7fc651..1e3249cbd3 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
+SPDX_INCLUDE_COMPILED_SOURCES ??= "0"
 
 SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org"
 SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs"
meta/lib/oe/spdx30_tasks.py +8 -0
index ba965821f8..9fe75e76e1 100644
@@ -156,6 +156,10 @@ def add_package_files(
         bb.note(f"Skip {topdir}")
         return spdx_files
 
+    check_compiled_sources = d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1"
+    if check_compiled_sources:
+        compiled_sources = bb.build.exec_func('get_compiled_sources', d)
+
     for subdir, dirs, files in os.walk(topdir, onerror=walk_error):
         dirs[:] = [d for d in dirs if d not in ignore_dirs]
         if subdir == str(topdir):
@@ -167,6 +171,10 @@ def add_package_files(
             filepath = Path(subdir) / file
             if filepath.is_symlink() or not filepath.is_file():
                 continue
+            # Check if file is compiled
+            if check_compiled_sources:
+                 if not bb.build.exec_func('is_compiled_source', d, file, kernel_sources):
+                      break
 
             filename = str(filepath.relative_to(topdir))
             file_purposes = get_purposes(filepath)
#17 lore raw

PATCH v3 6/8 cve-check: optionally allow to force update

In reply to [email protected]

From: Daniel Turull <[email protected]>

When introducing multiple sources of CVE potentially it could be the case that the answers are different due to data quality.

Allow to override CVE information from the scan from Unpatched to patched

---
 meta/classes/cve-check.bbclass | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
meta/classes/cve-check.bbclass +7 -3
index cce10c70ee..81512c255d 100644
@@ -277,7 +277,7 @@ def cve_is_patched(d, cve_data, cve):
         return True
     return False
 
-def cve_update(d, cve_data, cve, entry):
+def cve_update(d, cve_data, cve, entry, force_update=False):
     # If no entry, just add it
     if cve not in cve_data:
         cve_data[cve] = entry
@@ -297,7 +297,11 @@ def cve_update(d, cve_data, cve, entry):
             bb.debug(1, "CVE entry %s update from Patched to Unpatched from the scan result" % cve)
             return
     if entry['abbrev-status'] == "Patched" and cve_data[cve]['abbrev-status'] == "Unpatched":
-        if entry['status'] == "version-not-in-range" and cve_data[cve]['status'] == "version-in-range":
+        if force_update:
+            cve_data[cve] = entry
+            bb.debug(1, "CVE entry %s forced to update from Patched to Unpatched from the scan result" % cve)
+            return
+        elif entry['status'] == "version-not-in-range" and cve_data[cve]['status'] == "version-in-range":
             # Range does not match the scan, but we already have a vulnerable match, ignore
             bb.debug(1, "CVE entry %s update from Patched to Unpatched from the scan result - not applying" % cve)
             return
@@ -416,7 +420,7 @@ def check_cves(d, cve_data):
 
             if not vulnerable:
                 bb.note("%s-%s is not vulnerable to %s" % (pn, real_pv, cve))
-                cve_update(d, cve_data, cve, {"abbrev-status": "Patched", "status": "version-not-in-range"})
+                cve_update(d, cve_data, cve, {"abbrev-status": "Patched", "status": "version-not-in-range"}, force_update=True)
         cve_cursor.close()
 
         if not cves_in_product:
#18 lore raw

PATCH v3 7/8 cve-check, vex, spdx: use metadata from linux-vulns to enhance CVE reporting

In reply to [email protected]

From: Daniel Turull <[email protected]>

Introducing two new options to check kernel CVEs using linux-vulns.

- CVE_CHECK_KERNEL = "1"
To add linux-vulns metadata on cve-report for cve_check, vex and spdx. This will check for kernel CVEs, and use the metadata to resolve them. Enabled by default

- CVE_CHECK_KERNEL_CONFIG = "1"
CVE Check using kernel compiled files, disabled by default since it requires a compiled kernel and it will increase cve-check times.
Metadata in the CVE information includes the affected files, and using the compiled files by the kernel we can ignore some of the cves.

The above variables are defined in cve_check.bbclass, vex.bbclass and spdx.bbclass in case not all classes are used at the same time. The ones in cve_check has priority.

Example of output with CVE_CHECK_KERNEL_CONFIG when using cve-check:

{
"id": "CVE-2024-26710",
"status": "Ignored",
"link": "https://nvd.nist.gov/vuln/detail/CVE-2024-26710",
"summary": "In the Linux kernel, the following vulnerability [...]",
"scorev2": "0.0",
"scorev3": "5.5",
"scorev4": "0.0",
"modified": "2025-03-17T15:36:11.620",
"vector": "LOCAL",
"vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
"detail": "not-applicable-config",
"description": "Source code not compiled by config. ['arch/powerpc/include/asm/thread_info.h']"
},

And same with vex:
{
"id": "CVE-2024-26710",
"status": "Ignored",
"link": "https://nvd.nist.gov/vuln/detail/CVE-2024-26710",
"detail": "not-applicable-config",
"description": "Source code not compiled by config. ['arch/powerpc/include/asm/thread_info.h']"
},

And new information for the Unpatched showing where the fix (if any) is available:
Tested with 6.12.22 kernel
{
"id": "CVE-2025-39728",
"status": "Unpatched",
"link": "https://nvd.nist.gov/vuln/detail/CVE-2025-39728", "summary": "In the Linux kernel, the following vulnerability has been [...], "scorev2": "0.0",
"scorev3": "0.0",
"scorev4": "0.0",
"modified": "2025-04-21T14:23:45.950",
"vector": "UNKNOWN",
"vectorString": "UNKNOWN",
"detail": "version-in-range",
"description": "Needs backporting (fixed from 6.12.23)"
},

Tested with cve-check, create-spdx2.2, create-spdx3.0, vex

---
 meta/classes/cve-check.bbclass   |  23 +++-
 meta/classes/spdx-common.bbclass |   3 +
 meta/classes/vex.bbclass         |  11 ++
 meta/lib/oe/cve_check.py         | 211 ++++++++++++++++++++++++++++++-
 4 files changed, 245 insertions(+), 3 deletions(-)
meta/classes/cve-check.bbclass +21 -2
index 81512c255d..da396747f2 100644
@@ -34,6 +34,13 @@ CVE_VERSION ??= "${PV}"
 # Possible database sources: NVD1, NVD2, FKIE
 NVD_DB_VERSION ?= "FKIE"
 
+# CVE Check using kernel CNA and compiled files
+CVE_CHECK_KERNEL ?= "1"
+# CVE Check using kernel compiled files
+CVE_CHECK_KERNEL_CONFIG ?= "0"
+# Location of the linux-vulns data
+CVE_CHECK_KERNEL_DB_DIR ?= "${DL_DIR}/CVE_CHECK/vulns"
+
 # Use different file names for each database source, as they synchronize at different moments, so may be slightly different
 CVE_CHECK_DB_FILENAME ?= "${@'nvdcve_2-2.db' if d.getVar('NVD_DB_VERSION') == 'NVD2' else 'nvdcve_1-3.db' if d.getVar('NVD_DB_VERSION') == 'NVD1' else 'nvdfkie_1-1.db'}"
 CVE_CHECK_DB_FETCHER ?= "${@'cve-update-nvd2-native' if d.getVar('NVD_DB_VERSION') == 'NVD2' else 'cve-update-db-native'}"
@@ -111,6 +118,9 @@ python () {
     if nvd_database_type not in ("NVD1", "NVD2", "FKIE"):
         bb.erroronce("Malformed NVD_DB_VERSION, must be one of: NVD1, NVD2, FKIE. Defaulting to NVD2")
         d.setVar("NVD_DB_VERSION", "NVD2")
+
+    from oe.cve_check import extend_cve_kernel_config
+    extend_cve_kernel_config(d, "do_cve_check")
 }
 
 def generate_json_report(d, out_path, link_path):
@@ -161,15 +171,24 @@ python do_cve_check () {
     """
     Check recipe for patched and unpatched CVEs
     """
-    from oe.cve_check import get_patched_cves
+    from oe.cve_check import get_patched_cves, get_kernel_cves
 
     with bb.utils.fileslocked([d.getVar("CVE_CHECK_DB_FILE_LOCK")], shared=True):
+        cve_data = {}
+        # Add all reported CVES from linux-vulns
+        cve_check_kernel = d.getVar("CVE_CHECK_KERNEL")
+        if "linux_kernel" in d.getVar("CVE_PRODUCT") and cve_check_kernel == "1":
+            kernel_unpatched_cves, kernel_patched_cves = get_kernel_cves(d)
+            cve_data.update(kernel_patched_cves)
+            cve_data.update(kernel_unpatched_cves)
         if os.path.exists(d.getVar("CVE_CHECK_DB_FILE")):
             try:
                 patched_cves = get_patched_cves(d)
+                # Update cve_data, this will cover the manually reported with CVE_STATUS
+                cve_data.update(patched_cves)
             except FileNotFoundError:
                 bb.fatal("Failure in searching patches")
-            cve_data, status = check_cves(d, patched_cves)
+            cve_data, status = check_cves(d, cve_data)
             if len(cve_data) or (d.getVar("CVE_CHECK_COVERAGE") == "1" and status):
                 get_cve_info(d, cve_data)
                 cve_write_data(d, cve_data, status)
meta/classes/spdx-common.bbclass +3 -0
index 1e3249cbd3..83d35d0e3f 100644
@@ -41,6 +41,9 @@ SPDX_MULTILIB_SSTATE_ARCHS ??= "${SSTATE_ARCHS}"
 python () {
     from oe.cve_check import extend_cve_status
     extend_cve_status(d)
+
+    from oe.cve_check import extend_cve_kernel_config
+    extend_cve_kernel_config(d, "do_create_spdx")
 }
 
 def create_spdx_source_deps(d):
meta/classes/vex.bbclass +11 -0
index 905d67b47d..3d49b1ad0e 100644
@@ -26,6 +26,14 @@
 CVE_PRODUCT ??= "${BPN}"
 CVE_VERSION ??= "${PV}"
 
+CVE_CHECK_KERNEL_DB_DIR ?= "${DL_DIR}/CVE_CHECK/vulns"
+# CVE Check using kernel CNA and compiled files
+CVE_CHECK_KERNEL ?= "1"
+# CVE Check using kernel compiled files
+CVE_CHECK_KERNEL_CONFIG ?= "0"
+# Location of the linux-vulns data
+CVE_CHECK_KERNEL_DB_DIR ?= "${DL_DIR}/CVE_CHECK/vulns"
+
 CVE_CHECK_SUMMARY_DIR ?= "${LOG_DIR}/cve"
 
 CVE_CHECK_SUMMARY_FILE_NAME_JSON = "cve-summary.json"
@@ -78,6 +86,9 @@ python () {
 
     from oe.cve_check import extend_cve_status
     extend_cve_status(d)
+
+    from oe.cve_check import extend_cve_kernel_config
+    extend_cve_kernel_config(d, "do_generate_vex")
 }
 
 def generate_json_report(d, out_path, link_path):
meta/lib/oe/cve_check.py +210 -1

233 lines not on this page · raw message

#19 lore raw

PATCH v3 8/8 cve-exclusions: correct CVE_STATUS

In reply to [email protected]

From: Daniel Turull <[email protected]>

Some old CVEs do not have proper metadata to be able to resolve them or at wrongly assigned to the linux kernel.

The new kernel cve handling fails to report not vulnerable for a few CVEs that were introduced in LTS branch.

---
 meta/recipes-kernel/linux/cve-exclusion.inc | 31 +++++++++++++++++++++
 1 file changed, 31 insertions(+)
meta/recipes-kernel/linux/cve-exclusion.inc +31 -0
index f1b7db44b6..a80588ddeb 100644
@@ -155,3 +155,34 @@ CVE_STATUS[CVE-2023-7042] = "fixed-version: Fixed from 6.9rc1"
 
 #Fix https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7315dc1e122c85ffdfc8defffbb8f8b616c2eb1a
 CVE_STATUS[CVE-2024-0193] = "fixed-version: Fixed from 6.7"
+
+#Fix https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6c54b7bc8a31ce0f7cc7f8deef05067df414f1d8
+CVE_STATUS[CVE-2023-53012] = "fixed-version: Fixed from 6.2rc5"
+
+#Fix https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2f10d4a51bbcd938f1f02f16c304ad1d54717b96
+CVE_STATUS[CVE-2024-35788] = "fixed-version: Fixed from 6.9rc2"
+
+#Fix: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c8243def299793ac6c85fdc1086089c800c1051a
+CVE_STATUS[CVE-2024-57920] = "cpe-stable-backport: Backported in 6.12.10"
+
+#Fix: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=62b9ad7e52d4777f7e775ee1f0ad2452f6041024
+CVE_STATUS[CVE-2025-21988] = "cpe-stable-backport: Backported in 6.12.20"
+
+# Vulnerable code only in lts branches until 6.1.129 and 6.6.78
+CVE_STATUS[CVE-2025-40364] = "fixed-version: Fixed from 6.7"
+
+CVE_STATUS[CVE-2019-14899] = "cpe-incorrect: related to opevpn"
+
+CVE_STATUS[CVE-2021-3714] = "not-applicable-platform: specific to RHEL with securelevel patches"
+
+CVE_STATUS[CVE-2021-3864] = "not-applicable-platform: specific to RHEL with securelevel patches"
+
+CVE_STATUS[CVE-2023-3079] = "cpe-incorrect: not Linux but chrome"
+
+CVE_STATUS[CVE-2022-1247] = "not-applicable-platform: specific to RHEL with securelevel patches"
+
+CVE_STATUS[CVE-2023-3640] = "not-applicable-platform: specific to RHEL with securelevel patches"
+
+CVE_STATUS[CVE-2023-6238] = "not-applicable-platform: specific to RHEL with securelevel patches"
+
+CVE_STATUS[CVE-2023-6535] = "not-applicable-platform: specific to RHEL with securelevel patches"