Skip to contentSkip to conversation

improve_kernel_cve_report: do not override backported-patch

PATCH New [email protected] 1 participant 2 messages Jul 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 improve_kernel_cve_report: do not override backported-patch

From: Daniel Turull <[email protected]>

If the user has a CVE_STATUS for their own backported patch, the backport takes priority over upstream vulnerable versions.

---
 scripts/contrib/improve_kernel_cve_report.py | 4 ++++
 1 file changed, 4 insertions(+)
scripts/contrib/improve_kernel_cve_report.py +4 -0
index 829cc4cd30..a81aa0ff94 100755
@@ -340,6 +340,10 @@ def cve_update(cve_data, cve, entry):
     if cve_data[cve]['status'] == entry['status']:
         return
     if entry['status'] == "Unpatched" and cve_data[cve]['status'] == "Patched":
+        # Backported-patch (e.g. vendor kernel repo with cherry-picked CVE patch)
+        # has priority over unpatch from CNA
+        if cve_data[cve]['detail'] == "backported-patch":
+            return
         logging.warning("CVE entry %s update from Patched to Unpatched from the scan result", cve)
         cve_data[cve] = copy_data(cve_data[cve], entry)
         return
#1 lore raw

PATCH 2/2 improve_kernel_cve_report: do not use custom version

From: Daniel Turull <[email protected]>

When using the version specified in cve-summary.json, we need to remove the suffix containing the custom version to match the versions from the CVEs.

This patch truncates the version from cve-summary.json to use only the base version of the kernel.

This is only applicable for kernels where the user has added their own version.

---
 scripts/contrib/improve_kernel_cve_report.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/contrib/improve_kernel_cve_report.py +4 -2
index a81aa0ff94..5c39df05a5 100755
@@ -445,10 +445,12 @@ def main():
                 is_kernel=True
         if not is_kernel:
             continue
-
+        # We remove custom versions after -
+        upstream_version = Version(pkg["version"].split("-")[0])
+        logging.info("Checking kernel %s", upstream_version)
         kernel_cves = get_kernel_cves(args.datadir,
                                       compiled_files,
-                                      Version(pkg["version"]))
+                                      upstream_version)
         logging.info("Total kernel cves from kernel CNA: %s", len(kernel_cves))
         cves = {issue["id"]: issue for issue in pkg["issue"]}
         logging.info("Total kernel before processing cves: %s", len(cves))