Skip to content

eBPF-based security platform

proofs: let upatch-decoders take any count a short section declares

Daniel Borkmann9b37eae3fea0
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 2669e49a..72cfb0e4 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -587,7 +587,8 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
* - ``upatch-decoders``
- ``parse_decoders()``, ``upatch_decoder_view()``,
``upatch_has_decoders()``
- - Sections of every length declaring up to 2 decoders
+ - Sections of every length declaring up to 2 decoders, and any
+ count in a section too short for 3 entries
- Names terminated, each source non-empty and inside the section
behind the entries, every kind set, nothing kept on refusal,
``-ENOENT`` past the last decoder
diff --git a/testing/proofs/cbmc/upatch-decoders.c b/testing/proofs/cbmc/upatch-decoders.c
index 962a13bb..dc7de786 100644
--- a/testing/proofs/cbmc/upatch-decoders.c
+++ b/testing/proofs/cbmc/upatch-decoders.c
@@ -3,9 +3,10 @@
* Copyright (c) 2026 Authors of shirudo
*
* The DECODERS section of a .upatch, for sections of every length that
- * declare up to NR_MAX decoders: util/upatch.c reads only the entries the
- * section holds, and every decoder it views has terminated names and a
- * source inside the section, behind the entries.
+ * declare up to NR_MAX decoders, or any count at all where the section
+ * has no room for NR_MAX + 1 entries: util/upatch.c reads only the
+ * entries the section holds, and every decoder it views has terminated
+ * names and a source inside the section, behind the entries.
*/
#include "proof.h"
@@ -49,7 +50,9 @@ void harness(void)
__u8 *bp;
bp = any_bytes(len);
- __CPROVER_assume(len < 12 || get_le32(bp + 8) <= NR_MAX);
+ __CPROVER_assume(len < 12 || get_le32(bp + 8) <= NR_MAX ||
+ len < sizeof(struct upatch_decoder_blob) +
+ (NR_MAX + 1) * sizeof(struct upatch_decoder_entry));
u.map = bp;
u.map_size = len;
if (!parse_decoders(&u, bp, len)) {