All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] parser_bison: fix UaF when reporting table parse error
@ 2025-01-07 22:55 Florian Westphal
  2025-01-07 23:53 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2025-01-07 22:55 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

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

Fixes: 4955ae1a81b7 ("Add support for table's persist flag")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 src/parser_bison.y | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/parser_bison.y b/src/parser_bison.y
index 6e6f3cf8335d..7ab15244be52 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -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);
 			}
 			;
 
-- 
2.45.2


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

* Re: [PATCH nft] parser_bison: fix UaF when reporting table parse error
  2025-01-07 22:55 [PATCH nft] parser_bison: fix UaF when reporting table parse error Florian Westphal
@ 2025-01-07 23:53 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2025-01-07 23:53 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Tue, Jan 07, 2025 at 11:55:06PM +0100, Florian Westphal wrote:
> It passed already-freed memory to erec function.  Found with afl++ and asan.
> 
> Fixes: 4955ae1a81b7 ("Add support for table's persist flag")
> Signed-off-by: Florian Westphal <fw@strlen.de>

Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>

> ---
>  src/parser_bison.y | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/parser_bison.y b/src/parser_bison.y
> index 6e6f3cf8335d..7ab15244be52 100644
> --- a/src/parser_bison.y
> +++ b/src/parser_bison.y
> @@ -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);
>  			}
>  			;
>  
> -- 
> 2.45.2
> 
> 

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

end of thread, other threads:[~2025-01-07 23:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07 22:55 [PATCH nft] parser_bison: fix UaF when reporting table parse error Florian Westphal
2025-01-07 23:53 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.