nasm: fix CVE-2026-6067
PATCH 1/2 nasm: fix CVE-2026-6067
When using obj output format, specifying more than 256 segments in the GROUP directive of the .asm file causes a heap-buffer-overflow.
This patch applies the upstream fix given by the commit in [1] to address the issue in [2].
[1] https://github.com/netwide-assembler/nasm/commit/8890d723d0aa9ed1a790e2ce1c55eee8dfa0cf94
[2] https://github.com/netwide-assembler/nasm/issues/203
[3] https://nvd.nist.gov/vuln/detail/cve-2026-6067
--- .../nasm/nasm/CVE-2026-6067.patch | 36 +++++++++++++++++++ meta/recipes-devtools/nasm/nasm_2.16.03.bb | 1 + 2 files changed, 37 insertions(+) create mode 100644 meta/recipes-devtools/nasm/nasm/CVE-2026-6067.patch
meta/recipes-devtools/nasm/nasm/CVE-2026-6067.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 8bc3400afa0a3e46c890f8887d2f9bb5acc14024 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Mon, 29 Jun 2026 13:53:14 -0700 +Subject: [PATCH] outobj: fix buffer overflow when too many segments in a group + +The number of entries in a group was hard-coded, but not enforced. + +CVE: CVE-2026-6067 +Upstream-Status: Backport [https://github.com/netwide-assembler/nasm/commit/8890d723d0aa9ed1a790e2ce1c55eee8dfa0cf94] + +Reported-by: <[email protected]> +Fixes: https://github.com/netwide-assembler/nasm/issues/203 +Signed-off-by: H. Peter Anvin (Intel) <[email protected]> +Signed-off-by: Kris Gavvala <[email protected]> +--- + output/outobj.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/output/outobj.c b/output/outobj.c +index fc336c194..ad4adb373 100644 +--- a/output/outobj.c ++++ b/output/outobj.c +@@ -1641,6 +1641,10 @@ obj_directive(enum directive directive, char *value) + /* + * Now p contains a segment name. Find it. + */ ++ if (grp->nentries >= GROUP_MAX) { ++ nasm_nonfatal("too many segments in a group"); ++ return DIRR_ERROR; ++ } + for (seg = seghead; seg; seg = seg->next) + if (!strcmp(seg->name, p)) + break; +-- +2.43.0 +
meta/recipes-devtools/nasm/nasm_2.16.03.bb +1 -0
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=90904486f8fbf1861cf42752e1a39efe" SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \ file://0001-stdlib-Add-strlcat.patch \ file://0002-Add-debug-prefix-map-option.patch \ + file://CVE-2026-6067.patch \ " SRC_URI[sha256sum] = "bef3de159bcd61adf98bb7cc87ee9046e944644ad76b7633f18ab063edb29e57"
Signature · 1 line
2.43.0
PATCH 2/2 nasm: fix CVE-2026-6068
- CVE-2026-6068-1.patch applies the upstream fix in [2], addressing the issue in [1].
- CVE-2026-6068-2.patch applies [3],
adding helper functions used in [2].
- CVE-2026-6068-3.patch applies [4],
which prevents the compilation warning:
assignment discards 'const' qualifier
[1] https://github.com/netwide-assembler/nasm/issues/222
[2] https://github.com/netwide-assembler/nasm/commit/7bc82e7daf4cceb6a8af7ad2876485c9b4b01a56
[3] https://github.com/netwide-assembler/nasm/commit/44245e4684be1fac6c2fb7ac67dce8a55a574956
[4] https://github.com/netwide-assembler/nasm/commit/7b4e77dae29156a283d31fe707939ce21bf3eb3e
--- .../nasm/nasm/CVE-2026-6068-1.patch | 98 +++++++++++++++++++ .../nasm/nasm/CVE-2026-6068-2.patch | 80 +++++++++++++++ .../nasm/nasm/CVE-2026-6068-3.patch | 51 ++++++++++ meta/recipes-devtools/nasm/nasm_2.16.03.bb | 3 + 4 files changed, 232 insertions(+) create mode 100644 meta/recipes-devtools/nasm/nasm/CVE-2026-6068-1.patch create mode 100644 meta/recipes-devtools/nasm/nasm/CVE-2026-6068-2.patch create mode 100644 meta/recipes-devtools/nasm/nasm/CVE-2026-6068-3.patch
meta/recipes-devtools/nasm/nasm/CVE-2026-6068-1.patch new file +98 -0
@@ -0,0 +1,98 @@ +From e3a3fb40d21edb638f8191465574aaaaaacb336d Mon Sep 17 00:00:00 2001 +From: "H. Peter Anvin (Intel)" <[email protected]> +Date: Fri, 26 Jun 2026 17:27:47 -0700 +Subject: [PATCH 2/3] asm/nasm.c: fix use-after-free for -M* options in -@ + files + +-M* options in response files would hold on to a pointer to the new +value, but in response files that is not a persistent buffer. Make +sure to make a copy instead. + +This uses the new nasm_str[dup]to() helpers. + +(Note that calling nasm_free() on a NULL pointer is guaranteed safe.) + +CVE: CVE-2026-6068 +Upstream-Status: Backport [https://github.com/netwide-assembler/nasm/commit/7bc82e7daf4cceb6a8af7ad2876485c9b4b01a56] + +Reported-by: <[email protected]> +Fixes: https://github.com/netwide-assembler/nasm/issues/222 +Fixes: CVE-2026-6068 +Signed-off-by: H. Peter Anvin (Intel) <[email protected]> +Signed-off-by: Kris Gavvala <[email protected]> +--- + asm/nasm.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/asm/nasm.c b/asm/nasm.c +index 49fa00eb7..98bde83cb 100644 +--- a/asm/nasm.c ++++ b/asm/nasm.c +@@ -121,8 +121,8 @@ static unsigned int operating_mode; + /* Dependency flags */ + static bool depend_emit_phony = false; + static bool depend_missing_ok = false; +-static const char *depend_target = NULL; +-static const char *depend_file = NULL; ++static char *depend_target = NULL; ++static char *depend_file = NULL; + struct strlist *depend_list; + + static bool want_usage; +@@ -709,6 +709,8 @@ int main(int argc, char **argv) + stdscan_cleanup(); + src_free(); + strlist_free(&include_path); ++ nasm_free(depend_file); ++ nasm_free(depend_target); + + return terminate_after_phase; + } +@@ -750,7 +752,8 @@ static void copy_filename(const char **dst, const char *src, const char *what) + } + + /* +- * Convert a string to a POSIX make-safe form ++ * Convert a string to a POSIX make-safe form; returns a newly allocated ++ * string. + */ + static char *quote_for_pmake(const char *str) + { +@@ -830,7 +833,8 @@ static char *quote_for_pmake(const char *str) + } + + /* +- * Convert a string to a Watcom make-safe form ++ * Convert a string to a Watcom make-safe form; returns a newly allocated ++ * string. + */ + static char *quote_for_wmake(const char *str) + { +@@ -1188,20 +1192,20 @@ static bool process_arg(char *p, char *q, int pass) + case 'D': + operating_mode |= OP_DEPEND; + if (q && (q[0] != '-' || q[1] == '\0')) { +- depend_file = q; ++ nasm_strdupto(&depend_file, q); + advance = true; + } + break; + case 'F': +- depend_file = q; ++ nasm_strdupto(&depend_file, q); + advance = true; + break; + case 'T': +- depend_target = q; ++ nasm_strdupto(&depend_target, q); + advance = true; + break; + case 'Q': +- depend_target = quote_for_make(q); ++ nasm_strto(&depend_target, quote_for_make(q)); + advance = true; + break; + case 'W': +-- +2.43.0 +
meta/recipes-devtools/nasm/nasm/CVE-2026-6068-2.patch new file +80 -0
80 lines not on this page · raw message
meta/recipes-devtools/nasm/nasm/CVE-2026-6068-3.patch new file +51 -0
51 lines not on this page · raw message
meta/recipes-devtools/nasm/nasm_2.16.03.bb +3 -0
@@ -9,6 +9,9 @@ SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \ file://0001-stdlib-Add-strlcat.patch \ file://0002-Add-debug-prefix-map-option.patch \ file://CVE-2026-6067.patch \ + file://CVE-2026-6068-1.patch \ + file://CVE-2026-6068-2.patch \ + file://CVE-2026-6068-3.patch \ " SRC_URI[sha256sum] = "bef3de159bcd61adf98bb7cc87ee9046e944644ad76b7633f18ab063edb29e57"
Signature · 1 line
2.43.0