Skip to content

Commit b54fd00

Browse files
committed
netfilter: nft_flow_offload: reset dst in route object after setting up flow
jira LE-1907 cve CVE-2024-27403 Rebuild_History Non-Buildable kernel-5.14.0-427.40.1.el9_4 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 9e0f043 dst is transferred to the flow object, route object does not own it anymore. Reset dst in route object, otherwise if flow_offload_add() fails, error path releases dst twice, leading to a refcount underflow. Fixes: a3c90f7 ("netfilter: nf_tables: flow offload expression") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 9e0f043) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 8543e6e commit b54fd00

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

include/net/netfilter/nf_flow_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
275275
}
276276

277277
void flow_offload_route_init(struct flow_offload *flow,
278-
const struct nf_flow_route *route);
278+
struct nf_flow_route *route);
279279

280280
int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow);
281281
void flow_offload_refresh(struct nf_flowtable *flow_table,

net/netfilter/nf_flow_table_core.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,22 @@ static u32 flow_offload_dst_cookie(struct flow_offload_tuple *flow_tuple)
8686
return 0;
8787
}
8888

89+
static struct dst_entry *nft_route_dst_fetch(struct nf_flow_route *route,
90+
enum flow_offload_tuple_dir dir)
91+
{
92+
struct dst_entry *dst = route->tuple[dir].dst;
93+
94+
route->tuple[dir].dst = NULL;
95+
96+
return dst;
97+
}
98+
8999
static int flow_offload_fill_route(struct flow_offload *flow,
90-
const struct nf_flow_route *route,
100+
struct nf_flow_route *route,
91101
enum flow_offload_tuple_dir dir)
92102
{
93103
struct flow_offload_tuple *flow_tuple = &flow->tuplehash[dir].tuple;
94-
struct dst_entry *dst = route->tuple[dir].dst;
104+
struct dst_entry *dst = nft_route_dst_fetch(route, dir);
95105
int i, j = 0;
96106

97107
switch (flow_tuple->l3proto) {
@@ -145,7 +155,7 @@ static void nft_flow_dst_release(struct flow_offload *flow,
145155
}
146156

147157
void flow_offload_route_init(struct flow_offload *flow,
148-
const struct nf_flow_route *route)
158+
struct nf_flow_route *route)
149159
{
150160
flow_offload_fill_route(flow, route, FLOW_OFFLOAD_DIR_ORIGINAL);
151161
flow_offload_fill_route(flow, route, FLOW_OFFLOAD_DIR_REPLY);

0 commit comments

Comments
 (0)