Skip to contentSkip to conversation

parser_bison: fix UaF when reporting table parse error

PATCH In review Florian Westphal 2 participants 2 messages Jan 7, 2025 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 parser_bison: fix UaF when reporting table parse error

It passed already-freed memory to erec function. Found with afl++ and asan.

Fixes 4955ae1a81b7 ("Add support for table's persist flag")
---
 src/parser_bison.y | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/parser_bison.y +3 -1
index 6e6f3cf8335d..7ab15244be52 100644
@@ -1943,12 +1943,14 @@ table_flags		:	table_flag
 table_flag		:	STRING
 			{
 				$$ = parse_table_flag($1);
-				free_const($1);
 				if ($$ == 0) {
 					erec_queue(error(&@1, "unknown table option %s", $1),
 						   state->msgs);
+					free_const($1);
 					YYERROR;
 				}
+
+				free_const($1);
 			}
 			;
 
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Florian Westphal

It passed already-freed memory to erec function. Found with afl++ and asan.

Fixes 4955ae1a81b7 ("Add support for table's persist flag")
Quoted 28 lines
---
 src/parser_bison.y | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/parser_bison.y +3 -1
index 6e6f3cf8335d..7ab15244be52 100644
@@ -1943,12 +1943,14 @@ table_flags		:	table_flag
 table_flag		:	STRING
 			{
 				$$ = parse_table_flag($1);
-				free_const($1);
 				if ($$ == 0) {
 					erec_queue(error(&@1, "unknown table option %s", $1),
 						   state->msgs);
+					free_const($1);
 					YYERROR;
 				}
+
+				free_const($1);
 			}
 			;
 
Signature · 1 line
2.45.2