Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch
@ 2026-07-03  8:31 Titouan Christophe via buildroot
  2026-07-03  8:31 ` [Buildroot] [PATCH v2 2/2] package/{binutils, gpsd, micropython, net-tools, util-linux, x11vnc}: fix newly implemented MissingCVEPatch Titouan Christophe via buildroot
  2026-09-10 19:41 ` [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 3+ messages in thread
From: Titouan Christophe via buildroot @ 2026-07-03  8:31 UTC (permalink / raw)
  To: buildroot
  Cc: Bernd Kuhls, Chris Packham, Giulio Benetti, Ricardo Martincoski,
	Romain Naour, Yann E . MORIN, thomas.perale

To indicate that a patch fixes a vulnerability in Buildroot, the convention is:
1. In the patch file, add a tag 'CVE: <cve id>'
2. In <pkg>.mk, and an entry to <PKG>_IGNORE_CVES, and add a comment above
   that new entry to reference the patch file(s)

However, as packages get bumped and their patches are added, removed or
rebased; it happens that IGNORE_CVES get outdated. One important issue is
marking a CVE as ignored, while the corresponding patch is not in Buildroot.

To detect such cases, add a new checker to checkpackagelib that finds
occurences of:

    # 000x-some-patch.patch
    PKG_IGNORE_CVES += CVE-XXXX-YYYY

For each one of them, ensure that the mentioned patch files actually exist
and contain the `CVE: ...` tag.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
---
Changes v1->v2:
- Support multiple patch files for a single <PKG>_IGNORE_CVES line
- Add check for `CVE:` tag present in patch file
---
 utils/checkpackagelib/lib_mk.py      | 42 ++++++++++++++++++++
 utils/checkpackagelib/test_lib_mk.py | 57 ++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)

diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index 5d48e8929c..eb5fbf474c 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -6,6 +6,7 @@
 
 import os
 import re
+from pathlib import Path
 
 from checkpackagelib.base import _CheckFunction
 from checkpackagelib.lib import ConsecutiveEmptyLines  # noqa: F401
@@ -117,6 +118,47 @@ class Indent(_CheckFunction):
                         text]
 
 
+class MissingCVEPatch(_CheckFunction):
+    PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
+    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
+    CVE_TAG_IN_PATCH = re.compile(r"^CVE: *CVE-\d+-\d+$")
+
+    def before(self):
+        self.pending_patches = []
+        self.package_dir = Path(self.filename).parent
+
+    def check_patch_files(self):
+        for patch_lineno, patch_name, patch_text in self.pending_patches:
+            patch_file = self.package_dir / patch_name
+            self.pending_patch = None
+
+            if not patch_file.is_file():
+                return ["{}:{}: patch file '{}' mentioned for ignored CVEs is missing"
+                        .format(self.filename, patch_lineno, patch_name),
+                        patch_text]
+
+            if not any(map(self.CVE_TAG_IN_PATCH.match, patch_file.open())):
+                return ["{}: patch file '{}' is missing 'CVE:' tag"
+                        .format(self.filename, patch_name),
+                        patch_text]
+
+    def check_line(self, lineno, text):
+        m = self.PATCH_COMMENT.match(text.rstrip())
+        if m:
+            self.pending_patches.append((lineno, m.group(1), text))
+            return
+
+        # other comments do not break the association between the patch
+        # comment and the following _IGNORE_CVES assignment
+        if text.lstrip().startswith("#"):
+            return
+
+        if self.IGNORE_CVES.search(text):
+            return self.check_patch_files()
+
+        self.pending_patches = []
+
+
 class OverriddenVariable(_CheckFunction):
     CONCATENATING = re.compile(r"^([A-Z0-9_]+)\s*(\+|:|)=\s*\$\(\1\)")
     END_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(end_conditional)))
diff --git a/utils/checkpackagelib/test_lib_mk.py b/utils/checkpackagelib/test_lib_mk.py
index 3f97c25b2d..21effa9489 100644
--- a/utils/checkpackagelib/test_lib_mk.py
+++ b/utils/checkpackagelib/test_lib_mk.py
@@ -197,6 +197,63 @@ def test_Indent(testname, filename, string, expected):
     assert warnings == expected
 
 
+MissingCVEPatch = [
+    ('patches present',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234', '0002-other-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     []),
+    ('patch missing',
+     {'0002-other-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     [['{}:1: patch file \'0001-some-fix.patch\' mentioned for ignored CVEs is missing',
+       '# 0001-some-fix.patch\n']]),
+    ('CVE tag missing',
+     {'0001-some-fix.patch': ''},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' is missing \'CVE:\' tag',
+       '# 0001-some-fix.patch\n']]),
+    ('patch in version subdir',
+     {'1.0/0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 1.0/0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     []),
+    ('comments between patch and ignore',
+     {},
+     '# 0001-some-fix.patch\n'
+     '# this entry is not stale\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     [['{}:1: patch file \'0001-some-fix.patch\' mentioned for ignored CVEs is missing',
+       '# 0001-some-fix.patch\n']]),
+    ('comment not followed by ignore',
+     {},
+     '# 0001-some-fix.patch\n'
+     'FOO_DEPENDENCIES = host-foo\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     []),
+    ('ignore without patch comment',
+     {},
+     'FOO_IGNORE_CVES += CVE-2000-1234\n',
+     []),
+    ]
+
+
+@pytest.mark.parametrize('testname,patches,string,expected', MissingCVEPatch)
+def test_MissingCVEPatch(testname, patches, string, expected, tmp_path):
+    filename = str(tmp_path / 'foo.mk')
+    for patch_name, content in patches.items():
+        patch_path = tmp_path / patch_name
+        patch_path.parent.mkdir(parents=True, exist_ok=True)
+        patch_path.write_text(content)
+    warnings = util.check_file(m.MissingCVEPatch, filename, string)
+    expected = [[w[0].format(filename)] + w[1:] for w in expected]
+    assert warnings == expected
+
+
 OverriddenVariable = [
     ('simple assignment',
      'any.mk',
-- 
2.54.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH v2 2/2]  package/{binutils, gpsd, micropython, net-tools, util-linux, x11vnc}: fix newly implemented MissingCVEPatch
  2026-07-03  8:31 [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Titouan Christophe via buildroot
@ 2026-07-03  8:31 ` Titouan Christophe via buildroot
  2026-09-10 19:41 ` [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Thomas Petazzoni via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Titouan Christophe via buildroot @ 2026-07-03  8:31 UTC (permalink / raw)
  To: buildroot
  Cc: Bernd Kuhls, Chris Packham, Giulio Benetti, Ricardo Martincoski,
	Romain Naour, Yann E . MORIN, thomas.perale

- In the case of binutils, add a missing prefix to the specific version
  to which this patch applies
- For x11vnc, fix a typo in the patch name
- For gpsd the patches were dropped in [1] as they are included in the
  version bump
- Similarly for micropython, the patches were dropped in [2] along with
  the version bump
- For util-linux, strip the prefix "package/util-linux/", so that the patch
  is relative to the .mk file and can be found by the new check
- Add missing 'CVE:' tag to net-tools patch 0001

[1] 37ef4f862f package/gpsd: bump version to 3.27.2
[2] 28eeca9a98 package/micropython: bump to version 1.28.0

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
---
Changes v1-v2:
- Improve commit message to explain why entries are removed from gpsd
- Add fixes for issues in micropython & util-linux that were introduced in
  master since v1 of this series
- Add fix for net-tools discovered with the added support for multiple patch
  files for a single <PKG>_IGNORE_CVES line
---
 package/binutils/binutils.mk                                | 2 +-
 package/gpsd/gpsd.mk                                        | 6 ------
 package/micropython/micropython.mk                          | 3 ---
 ...E-2025-46836-interface.c-Stack-based-Buffer-Overfl.patch | 1 +
 package/util-linux/util-linux.mk                            | 2 +-
 package/x11vnc/x11vnc.mk                                    | 2 +-
 6 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/package/binutils/binutils.mk b/package/binutils/binutils.mk
index f772c9cf9a..f89adbe966 100644
--- a/package/binutils/binutils.mk
+++ b/package/binutils/binutils.mk
@@ -31,7 +31,7 @@ BINUTILS_LICENSE = GPL-3.0+, libiberty LGPL-2.1+
 BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
 BINUTILS_CPE_ID_VENDOR = gnu
 
-# 0003-objdump-memleak.patch
+# 2.44/0003-objdump-memleak.patch
 BINUTILS_IGNORE_CVES += CVE-2025-3198
 
 ifeq ($(BINUTILS_FROM_GIT),y)
diff --git a/package/gpsd/gpsd.mk b/package/gpsd/gpsd.mk
index 27a02c1754..7fd8cec8ab 100644
--- a/package/gpsd/gpsd.mk
+++ b/package/gpsd/gpsd.mk
@@ -14,12 +14,6 @@ GPSD_INSTALL_STAGING = YES
 
 GPSD_DEPENDENCIES = host-scons host-pkgconf
 
-# 0005-drivers-driver_nmea2000.c-Fix-issue-356-skyview-buff.patch
-GPSD_IGNORE_CVES += CVE-2025-67268
-
-# 0006-gpsd-packet.c-Fix-integer-underflow-is-malicious-Nav.patch
-GPSD_IGNORE_CVES += CVE-2025-67269
-
 GPSD_LDFLAGS = $(TARGET_LDFLAGS)
 GPSD_CFLAGS = $(TARGET_CFLAGS)
 GPSD_CXXFLAGS = $(TARGET_CXXFLAGS)
diff --git a/package/micropython/micropython.mk b/package/micropython/micropython.mk
index 044714451c..e260b9fde8 100644
--- a/package/micropython/micropython.mk
+++ b/package/micropython/micropython.mk
@@ -15,9 +15,6 @@ MICROPYTHON_LICENSE_FILES = LICENSE
 MICROPYTHON_DEPENDENCIES = host-python3
 MICROPYTHON_CPE_ID_VENDOR = micropython
 
-# 0004-py-objarray-fix-use-after-free-if-extending-a-bytearray-from-itself.patch
-MICROPYTHON_IGNORE_CVES += CVE-2024-8947
-
 # Use fallback implementation for exception handling on architectures that don't
 # have explicit support.
 ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb),)
diff --git a/package/net-tools/0001-CVE-2025-46836-interface.c-Stack-based-Buffer-Overfl.patch b/package/net-tools/0001-CVE-2025-46836-interface.c-Stack-based-Buffer-Overfl.patch
index 0a02785f38..1405b5c9e9 100644
--- a/package/net-tools/0001-CVE-2025-46836-interface.c-Stack-based-Buffer-Overfl.patch
+++ b/package/net-tools/0001-CVE-2025-46836-interface.c-Stack-based-Buffer-Overfl.patch
@@ -6,6 +6,7 @@ Subject: [PATCH] CVE-2025-46836: interface.c: Stack-based Buffer Overflow in
 
 Coordinated as GHSA-pfwf-h6m3-63wf
 
+CVE: CVE-2025-46836
 Upstream: https://github.com/ecki/net-tools/commit/7a8f42fb20013a1493d8cae1c43436f85e656f2d
 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
 ---
diff --git a/package/util-linux/util-linux.mk b/package/util-linux/util-linux.mk
index cfcd738bb5..b4175024c4 100644
--- a/package/util-linux/util-linux.mk
+++ b/package/util-linux/util-linux.mk
@@ -37,7 +37,7 @@ UTIL_LINUX_LICENSE_FILES = README.licensing \
 
 UTIL_LINUX_CPE_ID_VENDOR = kernel
 
-# package/util-linux/0003-loopdev-use-openat2-RESOLVE_NO_SYMLINKS-for-backing-.patch
+# 0003-loopdev-use-openat2-RESOLVE_NO_SYMLINKS-for-backing-.patch
 UTIL_LINUX_IGNORE_CVES += CVE-2026-27456
 
 # 0002-autotools-optionally-add-libpthread-to-uuid.pc.patch
diff --git a/package/x11vnc/x11vnc.mk b/package/x11vnc/x11vnc.mk
index 645ef40643..4ec1813430 100644
--- a/package/x11vnc/x11vnc.mk
+++ b/package/x11vnc/x11vnc.mk
@@ -10,7 +10,7 @@ X11VNC_DEPENDENCIES = xlib_libXt xlib_libXext xlib_libXtst libvncserver
 X11VNC_LICENSE = GPL-2.0+
 X11VNC_LICENSE_FILES = COPYING
 X11VNC_CPE_ID_VALID = YES
-# 0002-scan-limit-access-to-shared-memory-segments-to-current-user.patch
+# 0002-scan-limit-access-to-shared-memory-segments-to-curre.patch
 X11VNC_IGNORE_CVES += CVE-2020-29074
 
 # Source coming from github, no configure included
-- 
2.54.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch
  2026-07-03  8:31 [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Titouan Christophe via buildroot
  2026-07-03  8:31 ` [Buildroot] [PATCH v2 2/2] package/{binutils, gpsd, micropython, net-tools, util-linux, x11vnc}: fix newly implemented MissingCVEPatch Titouan Christophe via buildroot
@ 2026-09-10 19:41 ` Thomas Petazzoni via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-10 19:41 UTC (permalink / raw)
  To: Titouan Christophe
  Cc: buildroot, Bernd Kuhls, Chris Packham, Giulio Benetti,
	Ricardo Martincoski, Romain Naour, Yann E . MORIN, thomas.perale

Hello Titouan,

On Fri, Jul 03, 2026 at 10:31:36AM +0200, Titouan Christophe via buildroot wrote:
> To indicate that a patch fixes a vulnerability in Buildroot, the convention is:
> 1. In the patch file, add a tag 'CVE: <cve id>'
> 2. In <pkg>.mk, and an entry to <PKG>_IGNORE_CVES, and add a comment above
>    that new entry to reference the patch file(s)
> 
> However, as packages get bumped and their patches are added, removed or
> rebased; it happens that IGNORE_CVES get outdated. One important issue is
> marking a CVE as ignored, while the corresponding patch is not in Buildroot.
> 
> To detect such cases, add a new checker to checkpackagelib that finds
> occurences of:
> 
>     # 000x-some-patch.patch
>     PKG_IGNORE_CVES += CVE-XXXX-YYYY
> 
> For each one of them, ensure that the mentioned patch files actually exist
> and contain the `CVE: ...` tag.
> 
> Assisted-by: Claude:claude-opus-4.8
> Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>

Thanks, series applied!

I have applied PATCH 2/2 as the first patch, because it fixes the
issues, before introducing the check that was your PATCH 1/2.

In your PATCH 2/2, I have adjust the binutils fixup: the
BINUTILS_IGNORE_CVES entry was no longer relevant, as only binutils up
to 2.44 was vulnerable, but we only support 2.45+ now (and so the
patch referenced by this IGNORE_CVES annotation was no longer there).

One additional thing that could be done is verify that the CVE: tag in
the patch references a CVE number that actually matches the one in the
<pkg>_IGNORE_CVES entry. But oh well, you proposal is already
improving the situation a lot!

Thanks!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-10 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03  8:31 [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Titouan Christophe via buildroot
2026-07-03  8:31 ` [Buildroot] [PATCH v2 2/2] package/{binutils, gpsd, micropython, net-tools, util-linux, x11vnc}: fix newly implemented MissingCVEPatch Titouan Christophe via buildroot
2026-09-10 19:41 ` [Buildroot] [PATCH v2 1/2] utils/checkpackagelib: add new check MissingCVEPatch Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox