public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][kirkstone 04/24] classes: cve-check: Get shared database lock
Date: Wed,  7 Sep 2022 04:20:05 -1000	[thread overview]
Message-ID: <655bc5acdebdee9b4dfd3c964104a84b6845b2d4.1662559557.git.steve@sakoman.com> (raw)
In-Reply-To: <cover.1662559557.git.steve@sakoman.com>

From: Joshua Watt <JPEWhacker@gmail.com>

The CVE check database needs to have a shared lock acquired on it before
it is accessed. This to prevent cve-update-db-native from deleting the
database file out from underneath it.

[YOCTO #14899]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 20a9911b73df62a0d0d1884e57085f13ac5016dd)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 meta/classes/cve-check.bbclass | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass
index da7f93371c..b751c986ef 100644
--- a/meta/classes/cve-check.bbclass
+++ b/meta/classes/cve-check.bbclass
@@ -139,17 +139,18 @@ python do_cve_check () {
     """
     from oe.cve_check import get_patched_cves
 
-    if os.path.exists(d.getVar("CVE_CHECK_DB_FILE")):
-        try:
-            patched_cves = get_patched_cves(d)
-        except FileNotFoundError:
-            bb.fatal("Failure in searching patches")
-        ignored, patched, unpatched, status = check_cves(d, patched_cves)
-        if patched or unpatched or (d.getVar("CVE_CHECK_COVERAGE") == "1" and status):
-            cve_data = get_cve_info(d, patched + unpatched + ignored)
-            cve_write_data(d, patched, unpatched, ignored, cve_data, status)
-    else:
-        bb.note("No CVE database found, skipping CVE check")
+    with bb.utils.fileslocked([d.getVar("CVE_CHECK_DB_FILE_LOCK")], shared=True):
+        if os.path.exists(d.getVar("CVE_CHECK_DB_FILE")):
+            try:
+                patched_cves = get_patched_cves(d)
+            except FileNotFoundError:
+                bb.fatal("Failure in searching patches")
+            ignored, patched, unpatched, status = check_cves(d, patched_cves)
+            if patched or unpatched or (d.getVar("CVE_CHECK_COVERAGE") == "1" and status):
+                cve_data = get_cve_info(d, patched + unpatched + ignored)
+                cve_write_data(d, patched, unpatched, ignored, cve_data, status)
+        else:
+            bb.note("No CVE database found, skipping CVE check")
 
 }
 
-- 
2.25.1



  parent reply	other threads:[~2022-09-07 14:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 14:20 [OE-core][kirkstone 00/24] Patch review Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 01/24] sqlite: add CVE-2022-35737 patch to SRC_URI Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 02/24] curl: Backport patch for CVE-2022-35252 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 03/24] binutils : CVE-2022-38533 Steve Sakoman
2022-09-07 14:20 ` Steve Sakoman [this message]
2022-09-07 14:20 ` [OE-core][kirkstone 05/24] cve-check: close cursors as soon as possible Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 06/24] vim: Upgrade 9.0.0242 -> 9.0.0341 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 07/24] libtasn1: upgrade 4.18.0 -> 4.19.0 Steve Sakoman
2022-09-14  0:37   ` Randy MacLeod
2022-09-14  2:19     ` Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 08/24] liburcu: upgrade 0.13.1 -> 0.13.2 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 09/24] libwpe: upgrade 1.12.2 -> 1.12.3 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 10/24] libatomic-ops: upgrade 7.6.12 -> 7.6.14 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 11/24] lz4: upgrade 1.9.3 -> 1.9.4 Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 12/24] insane.bbclass: Skip patches not in oe-core by full path Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 13/24] maintainers: update opkg maintainer Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 14/24] apr: Cache configure tests which use AC_TRY_RUN Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 15/24] bitbake.conf: set BB_DEFAULT_UMASK using ??= Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 16/24] pseudo: Update to include recent upstream minor fixes Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 17/24] scripts/runqemu.README: fix typos and trailing whitespaces Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 18/24] meta: introduce UBOOT_MKIMAGE_KERNEL_TYPE Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 19/24] kernel-fitimage.bbclass: add padding algorithm property in config nodes Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 20/24] npm: replace 'npm pack' call by 'tar czf' Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 21/24] npm: return content of 'package.json' in 'npm_pack' Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 22/24] npm: take 'version' directly from 'package.json' Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 23/24] lib:npm_registry: initial checkin Steve Sakoman
2022-09-07 14:20 ` [OE-core][kirkstone 24/24] npm: use npm_registry to cache package Steve Sakoman
2022-09-13 15:40   ` Martin Jansa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=655bc5acdebdee9b4dfd3c964104a84b6845b2d4.1662559557.git.steve@sakoman.com \
    --to=steve@sakoman.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox