Re: [PATCH net v2] net/sched: Fix UAF when resolving a clash
From: Chengen Du
Date: Wed Jul 10 2024 - 01:16:09 EST
On Tue, Jul 9, 2024 at 6:40 PM Paolo Abeni <pabeni@xxxxxxxxxx> wrote:
>
> 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.
Based on your suggestions, I took a deeper look at the code and found
that the drop logic simply adds a count to qstats->drops. It did not
work as I expected in terms of dropping the packet. I apologize for
any confusion this may have caused in our discussion. I will send a v3
to modify the error handling. Thank you for your advice.
>
> Thanks,
>
> Paolo
>