Re: [PATCH net v2] net: sched: ematch: reject invalid data

Cong Wang
2022-12-17T21:37:25Z

On Thu, Dec 15, 2022 at 01:50:43PM +0100, Paolo Abeni wrote:
> On Wed, 2022-12-14 at 10:20 +0800, Jun Nie wrote:
> > ---
> > net/sched/em_cmp.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c
> > index f17b049ea530..0284394be53f 100644
> > --- a/net/sched/em_cmp.c
> > +++ b/net/sched/em_cmp.c
> > @@ -22,9 +22,14 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
> > struct tcf_pkt_info *info)
> > {
> > struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
> > - unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
> > + unsigned char *ptr;
> > u32 val = 0;
> >
> > + if (!cmp)
> > + return 0;
>
> It feels like this is papering over the real issue. Why em->data is
> NULL here? why other ematches are not afflicted by this issue?
>
> is em->data really NULL or some small value instead? KASAN seams to
> tell it's a small value, not 0, so this patch should not avoid the
> oops. Have you tested it vs the reproducer?

Right. I think I have found the root cause, let me test my patch to see
if it makes syzbot happy.

Thanks.