* [PATCH] src: fix deref of null.ret in rule.c
@ 2025-03-02 19:44 Anton Moryakov
2025-03-03 1:45 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Anton Moryakov @ 2025-03-02 19:44 UTC (permalink / raw)
To: netfilter-devel; +Cc: Anton Moryakov
Fix potential null pointer dereference in `do_list_flowtable`.
The pointer `table` is initialized to NULL and passed to `do_list_flowtable`,
where it may be dereferenced. This can lead to a crash if `table` remains NULL.
Changes:
- Added a NULL check for the `table` pointer before calling `do_list_flowtable`.
- Return an error code (-1) if `table` is NULL to handle the case where the table is not found.
Triggers found by static analyzer Svace.
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
---
src/rule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rule.c b/src/rule.c
index f7582914..59d3f3ac 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1556,7 +1556,7 @@ static int do_delete_setelems(struct netlink_ctx *ctx, struct cmd *cmd)
const struct set *set = cmd->elem.set;
struct expr *expr = cmd->elem.expr;
- if (set_is_non_concat_range(set) &&
+ if (set && set_is_non_concat_range(set) &&
set_to_intervals(set, expr, false) < 0)
return -1;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] src: fix deref of null.ret in rule.c
2025-03-02 19:44 [PATCH] src: fix deref of null.ret in rule.c Anton Moryakov
@ 2025-03-03 1:45 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2025-03-03 1:45 UTC (permalink / raw)
To: Anton Moryakov; +Cc: netfilter-devel
Anton Moryakov <ant.v.moryakov@gmail.com> wrote:
> Fix potential null pointer dereference in `do_list_flowtable`.
>
> The pointer `table` is initialized to NULL and passed to `do_list_flowtable`,
> where it may be dereferenced. This can lead to a crash if `table` remains NULL.
>
> Changes:
> - Added a NULL check for the `table` pointer before calling `do_list_flowtable`.
> - Return an error code (-1) if `table` is NULL to handle the case where the table is not found.
This changelog doesn't match the patch.
> index f7582914..59d3f3ac 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -1556,7 +1556,7 @@ static int do_delete_setelems(struct netlink_ctx *ctx, struct cmd *cmd)
> const struct set *set = cmd->elem.set;
> struct expr *expr = cmd->elem.expr;
>
> - if (set_is_non_concat_range(set) &&
> + if (set && set_is_non_concat_range(set) &&
> set_to_intervals(set, expr, false) < 0)
> return -1;
You need to explain how "set" can be NULL here.
This gets allocated in nft_cmd_expand, where set was
already dereferenced.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-03 1:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02 19:44 [PATCH] src: fix deref of null.ret in rule.c Anton Moryakov
2025-03-03 1:45 ` Florian Westphal
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.