lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 4 Feb 2022 22:42:13 +0800
From:   Menglong Dong <menglong8.dong@...il.com>
To:     David Ahern <dsahern@...il.com>
Cc:     David Ahern <dsahern@...nel.org>, Jakub Kicinski <kuba@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>, mingo@...hat.com,
        David Miller <davem@...emloft.net>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        pablo@...filter.org, kadlec@...filter.org,
        Florian Westphal <fw@...len.de>,
        Menglong Dong <imagedong@...cent.com>,
        Eric Dumazet <edumazet@...gle.com>, alobakin@...me,
        paulb@...dia.com, Kees Cook <keescook@...omium.org>,
        talalahmad@...gle.com, haokexin@...il.com, memxor@...il.com,
        LKML <linux-kernel@...r.kernel.org>,
        netdev <netdev@...r.kernel.org>, netfilter-devel@...r.kernel.org,
        coreteam@...filter.org, Cong Wang <cong.wang@...edance.com>,
        Mengen Sun <mengensun@...cent.com>
Subject: Re: [PATCH v3 net-next 3/7] net: ipv4: use kfree_skb_reason() in ip_rcv_core()

On Tue, Feb 1, 2022 at 2:06 AM David Ahern <dsahern@...il.com> wrote:
>
> On 1/28/22 12:33 AM, menglong8.dong@...il.com wrote:
> \> diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
> > index 3a025c011971..627fad437593 100644
> > --- a/net/ipv4/ip_input.c
> > +++ b/net/ipv4/ip_input.c
> > @@ -436,13 +436,18 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
> >  static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)
> >  {
> >       const struct iphdr *iph;
> > +     int drop_reason;
> >       u32 len;
> >
> > +     drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
>
> move this line down, right before:
>
>         if (!pskb_may_pull(skb, sizeof(struct iphdr)))
>                 goto inhdr_error;
>
> > +
> >       /* When the interface is in promisc. mode, drop all the crap
> >        * that it receives, do not try to analyse it.
> >        */
> > -     if (skb->pkt_type == PACKET_OTHERHOST)
> > +     if (skb->pkt_type == PACKET_OTHERHOST) {
> > +             drop_reason = SKB_DROP_REASON_OTHERHOST;
> >               goto drop;
> > +     }
> >
> >       __IP_UPD_PO_STATS(net, IPSTATS_MIB_IN, skb->len);
> >
> > @@ -488,6 +493,7 @@ static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)
> >
> >       len = ntohs(iph->tot_len);
> >       if (skb->len < len) {
> > +             drop_reason = SKB_DROP_REASON_PKT_TOO_SMALL;
> >               __IP_INC_STATS(net, IPSTATS_MIB_INTRUNCATEDPKTS);
> >               goto drop;
> >       } else if (len < (iph->ihl*4))
> > @@ -516,11 +522,13 @@ static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)
> >       return skb;
> >
> >  csum_error:
> > +     drop_reason = SKB_DROP_REASON_IP_CSUM;
> >       __IP_INC_STATS(net, IPSTATS_MIB_CSUMERRORS);
> >  inhdr_error:
> > +     drop_reason = drop_reason ?: SKB_DROP_REASON_IP_INHDR;
>
> That makes assumptions about the value of SKB_DROP_REASON_NOT_SPECIFIED.
> Make that line:
>         if (drop_reason != SKB_DROP_REASON_NOT_SPECIFIED)
>                 drop_reason = SKB_DROP_REASON_IP_INHDR;
>

You are right, the assumptions here are unsuitable. But I guess it
should be this?

         if (drop_reason == SKB_DROP_REASON_NOT_SPECIFIED)
                 drop_reason = SKB_DROP_REASON_IP_INHDR;

> >       __IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
> >  drop:
> > -     kfree_skb(skb);
> > +     kfree_skb_reason(skb, drop_reason);
> >  out:
> >       return NULL;
> >  }
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ