netfilter: flowtable: Make sure dst_cache is valid before using it
Subsystems (3)
PATCH 1/1 netfilter: flowtable: Make sure dst_cache is valid before using it
It could be dst_cache was not set so check it's not null before using it.
--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_flow_table_core.c +2 -0
@@ -410,6 +410,8 @@ static bool flow_offload_stale_dst(struct flow_offload_tuple *tuple)if (tuple->xmit_type ==FLOW_OFFLOAD_XMIT_NEIGH || tuple->xmit_type ==FLOW_OFFLOAD_XMIT_XFRM ) { dst = tuple->dst_cache; +if (!dst) +return false;if (!dst_check (dst, tuple->dst_cookie))return true; }
Signature · 1 line
2.26.2
Pablo Neira Ayuso
maintainerHi Roi,
Quoted 2 lines · Roi Dayan
It could be
dst_cachewas not set so check it's not null before using it.
Could you give a try to this fix?
net/sched/act_ct.c leaves the xmit_type as FLOW_OFFLOAD_XMIT_UNSPEC since it does not cache a route.
Thanks.
Quoted 22 lines
Fixes 8b9229d15877 ("netfilter: flowtable: dst_check() from garbage collector path")Signed-off-by Roi Dayan <[email protected]>--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)net/netfilter/nf_flow_table_core.c +2
-0@@ -410,6 +410,8 @@ static bool flow_offload_stale_dst(struct flow_offload_tuple *tuple)if (tuple->xmit_type ==FLOW_OFFLOAD_XMIT_NEIGH || tuple->xmit_type ==FLOW_OFFLOAD_XMIT_XFRM ) { dst = tuple->dst_cache; +if (!dst) +return false;if (!dst_check (dst, tuple->dst_cookie))return true; }Signature · 1 line
2.26.2
include/net/netfilter/nf_flow_table.h +2 -1
@@ -90,7 +90,8 @@ enum flow_offload_tuple_dir {#define FLOW_OFFLOAD_DIR_MAX IP_CT_DIR_MAXenum flow_offload_xmit_type { -FLOW_OFFLOAD_XMIT_NEIGH =0 , +FLOW_OFFLOAD_XMIT_UNSPEC =0 , +FLOW_OFFLOAD_XMIT_NEIGH ,FLOW_OFFLOAD_XMIT_XFRM ,FLOW_OFFLOAD_XMIT_DIRECT , };
net/netfilter/nf_flow_table_core.c +3 -0
@@ -130,6 +130,9 @@ static int flow_offload_fill_route(struct flow_offload *flow, flow_tuple->dst_cache = dst; flow_tuple->dst_cookie =flow_offload_dst_cookie (flow_tuple);break ; +case FLOW_OFFLOAD_XMIT_UNSPEC : +WARN_ON_ONCE (1 ); +break ; } flow_tuple->xmit_type = route->tuple[dir].xmit_type;
Quoted 6 lines · Pablo Neira Ayuso
Hi Roi,
Quoted 2 lines · Roi Dayan
It could be
dst_cachewas not set so check it's not null before using it.
Quoted 7 lines
Could you give a try to this fix?
net/sched/act_ct.cleaves thexmit_typeasFLOW_OFFLOAD_XMIT_UNSPECsince it does not cache a route.Thanks.
what do you mean? FLOW_OFFLOAD_XMIT_UNSPEC doesn't exists so default 0 is set.
do you suggest adding that enum option as 0?
this is the current xmit_type enum
enum flow_offload_xmit_type {
FLOW_OFFLOAD_XMIT_NEIGH = 0,
FLOW_OFFLOAD_XMIT_XFRM,
FLOW_OFFLOAD_XMIT_DIRECT,
};
Quoted 22 lines
Quoted 22 lines
Fixes 8b9229d15877 ("netfilter: flowtable: dst_check() from garbage collector path")Signed-off-by Roi Dayan <[email protected]>--- net/netfilter/nf_flow_table_core.c | 2 ++ 1 file changed, 2 insertions(+)net/netfilter/nf_flow_table_core.c +2
-0@@ -410,6 +410,8 @@ static bool flow_offload_stale_dst(struct flow_offload_tuple *tuple)if (tuple->xmit_type ==FLOW_OFFLOAD_XMIT_NEIGH || tuple->xmit_type ==FLOW_OFFLOAD_XMIT_XFRM ) { dst = tuple->dst_cache; +if (!dst) +return false;if (!dst_check (dst, tuple->dst_cookie))return true; }Signature · 1 line
2.26.2
Pablo Neira Ayuso
maintainerQuoted 14 lines · Roi Dayan
Quoted 11 lines · Pablo Neira Ayuso
Hi Roi,
Quoted 2 lines · Roi Dayan
It could be
dst_cachewas not set so check it's not null before using it.Could you give a try to this fix?
net/sched/act_ct.cleaves thexmit_typeasFLOW_OFFLOAD_XMIT_UNSPECsince it does not cache a route.
Quoted 7 lines
Quoted 2 lines
Thanks.
what do you mean?
FLOW_OFFLOAD_XMIT_UNSPECdoesn't exists so default 0 is set.do you suggest adding that enum option as 0?
Yes. This could be FLOW_OFFLOAD_XMIT_TC instead if you prefer.
enum flow_offload_xmit_type {
FLOW_OFFLOAD_XMIT_TC = 0,
FLOW_OFFLOAD_XMIT_NEIGH,
FLOW_OFFLOAD_XMIT_XFRM,
FLOW_OFFLOAD_XMIT_DIRECT,
};
so there is no need to check for no route in the FLOW_OFFLOAD_XMIT_NEIGH case (it's assumed this type always has a route).
Quoted 32 lines · Pablo Neira Ayuso
Quoted 14 lines · Roi Dayan
Quoted 11 lines · Pablo Neira Ayuso
Hi Roi,
Quoted 2 lines · Roi Dayan
It could be
dst_cachewas not set so check it's not null before using it.Could you give a try to this fix?
net/sched/act_ct.cleaves thexmit_typeasFLOW_OFFLOAD_XMIT_UNSPECsince it does not cache a route.Quoted 7 lines
Quoted 2 lines
Thanks.
what do you mean?
FLOW_OFFLOAD_XMIT_UNSPECdoesn't exists so default 0 is set.do you suggest adding that enum option as 0?
Yes. This could be
FLOW_OFFLOAD_XMIT_TCinstead if you prefer.enum
flow_offload_xmit_type{
FLOW_OFFLOAD_XMIT_TC= 0,
FLOW_OFFLOAD_XMIT_NEIGH,
FLOW_OFFLOAD_XMIT_XFRM,
FLOW_OFFLOAD_XMIT_DIRECT,
};
Quoted 4 lines
so there is no need to check for no route in the
FLOW_OFFLOAD_XMIT_NEIGHcase (it's assumed this type always has a route).
thanks Pablo. were not sure I wanted to touch the enum. I prefer unspec actually as you suggested initially. it works fine by adding the enum.
i'll submit v2 with this suggestion.