Re: [PATCH net v2] net/sched: Fix UAF when resolving a clash
From: Paolo Abeni
Date: Tue Jul 09 2024 - 06:40:44 EST
On Mon, 2024-07-08 at 17:39 +0800, Chengen Du wrote:
> On Mon, Jul 8, 2024 at 4:33 PM Michal Kubiak <michal.kubiak@xxxxxxxxx> wrote:
> > For example, if "nf_conntrack_confirm()" returns NF_ACCEPT, (even after
> > the clash resolving), I would not expect calling "goto drop".
> > That is why I suggested a less invasive solution which is just blocking
> > calling "tcf_ct_flow_table_process_conn()" where there is a risk of UAF.
> > So, I asked if such solution would work in case of this function.
>
> Thank you for expressing your concerns in detail.
>
> In my humble opinion, skipping the addition of an entry in the flow
> table is controlled by other logic and may not be suitable to mix with
> error handling. If nf_conntrack_confirm returns NF_ACCEPT, I believe
> there is no reason for nf_ct_get to fail. The nf_ct_get function
> simply converts skb->_nfct into a struct nf_conn type. The only
> instance it might fail is when CONFIG_NF_CONNTRACK is disabled. The
> CONFIG_NET_ACT_CT depends on this configuration and determines whether
> act_ct.c needs to be compiled. Actually, the "goto drop" logic is
> included for completeness and might only be relevant if the memory is
> corrupted. Perhaps we could wrap the judgment with "unlikely" to
> emphasize this point?
I agree with Michal, I think it should be better to just skip
tcf_ct_flow_table_process_conn() in case of clash to avoid potential
behavior changes.
Thanks,
Paolo