evaluate: error out if concat expression becomes too large
Florian Westphal
maintainerPATCH 1/1 evaluate: error out if concat expression becomes too large
Before:
BUG: nld buffer overflow: want to copy 132, max 64
After:
Error: Concatenation of size 544 exceeds maximum size of 512
udp length . @th,0,512 . @th,512,512 { 47-63 . 0xe373135363130 . 0x33131303735353203 }
^^^^^^^^^
Signed-off-by Florian Westphal <[email protected]>
---
Pablo, I can merge this with
"[nft] parser_bison: reject large raw payload expressions" if you prefer.
src/evaluate.c | 4 ++++ .../bogons/nft-f/stack_overflow_via_large_concat_expr | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 tests/shell/testcases/bogons/nft-f/stack_overflow_via_large_concat_expr
src/evaluate.c +4 -0
@@ -1591,6 +1591,10 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr) } ctx->inner_desc =NULL ; + +if (size >NFT_REG32_COUNT *sizeof (uint32_t ) *BITS_PER_BYTE ) +return expr_error (ctx->msgs, i,"Concatenation of size %u exceeds maximum size of %u" , + size,NFT_REG32_COUNT *sizeof (uint32_t ) *BITS_PER_BYTE ); } (*expr)->flags |= flags;
tests/shell/testcases/bogons/nft-f/stack_overflow_via_large_concat_expr new file +5 -0
@@ -0,0 +1,5 @@ +table t { + chain c { + udp length . @th,0,512 . @th,512,512 { 47-63 . 0xe373135363130 . 0x33131303735353203 } + } +}
Signature · 1 line
2.41.0