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] [day] [month] [year] [list]
Message-ID: <CA+FuTSfJLdGj07p-B-sUfovrvj5xdt96Y=aCsu1_Bia+h5aYHg@mail.gmail.com>
Date:   Wed, 3 Feb 2021 09:05:53 -0500
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Loic Poulain <loic.poulain@...aro.org>
Cc:     Willem de Bruijn <willemdebruijn.kernel@...il.com>,
        Jakub Kicinski <kuba@...nel.org>,
        David Miller <davem@...emloft.net>,
        Network Development <netdev@...r.kernel.org>,
        Sean Tranchetti <stranche@...eaurora.org>,
        Subash Abhinov Kasiviswanathan <subashab@...eaurora.org>
Subject: Re: [PATCH net-next v2 1/2] net: mhi-net: Add de-aggeration support

>
> [...]
> > >  static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
> > >                                 struct mhi_result *mhi_res)
> > >  {
> > > @@ -142,19 +175,42 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
> > >         free_desc_count = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE);
> > >
> > >         if (unlikely(mhi_res->transaction_status)) {
> > > -               dev_kfree_skb_any(skb);
> > > -
> > > -               /* MHI layer stopping/resetting the DL channel */
> > > -               if (mhi_res->transaction_status == -ENOTCONN)
> > > +               switch (mhi_res->transaction_status) {
> > > +               case -EOVERFLOW:
> > > +                       /* Packet can not fit in one MHI buffer and has been
> > > +                        * split over multiple MHI transfers, do re-aggregation.
> > > +                        * That usually means the device side MTU is larger than
> > > +                        * the host side MTU/MRU. Since this is not optimal,
> > > +                        * print a warning (once).
> > > +                        */
> > > +                       netdev_warn_once(mhi_netdev->ndev,
> > > +                                        "Fragmented packets received, fix MTU?\n");
> > > +                       skb_put(skb, mhi_res->bytes_xferd);
> > > +                       mhi_net_skb_agg(mhi_netdev, skb);
> > > +                       break;
> > > +               case -ENOTCONN:
> > > +                       /* MHI layer stopping/resetting the DL channel */
> > > +                       dev_kfree_skb_any(skb);
> > >                         return;
> > > -
> > > -               u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
> > > -               u64_stats_inc(&mhi_netdev->stats.rx_errors);
> > > -               u64_stats_update_end(&mhi_netdev->stats.rx_syncp);
> > > +               default:
> > > +                       /* Unknown error, simply drop */
> > > +                       dev_kfree_skb_any(skb);
> > > +                       u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
> > > +                       u64_stats_inc(&mhi_netdev->stats.rx_errors);
> > > +                       u64_stats_update_end(&mhi_netdev->stats.rx_syncp);
> > > +               }
> > >         } else {
> > > +               skb_put(skb, mhi_res->bytes_xferd);
> > > +
> > > +               if (mhi_netdev->skbagg_head) {
> > > +                       /* Aggregate the final fragment */
> > > +                       skb = mhi_net_skb_agg(mhi_netdev, skb);
> > > +                       mhi_netdev->skbagg_head = NULL;
> > > +               }
> > > +
> > >                 u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
> > >                 u64_stats_inc(&mhi_netdev->stats.rx_packets);
> > > -               u64_stats_add(&mhi_netdev->stats.rx_bytes, mhi_res->bytes_xferd);
> > > +               u64_stats_add(&mhi_netdev->stats.rx_bytes, skb->len);
> >
> > might this change stats? it will if skb->len != 0 before skb_put. Even
> > if so, perhaps it doesn't matter.
>
> Don't get that point, skb is the received MHI buffer, we simply set
> its size because MHI core don't (skb->len is always 0 before put).
> Then if it is part of a fragmented transfer we just do the extra
> 'skb = skb_agg+ skb', so skb->len should always be right here,
> whether it's a standalone/linear packet or a multi-frag packet.

Great. I did not know that skb->len is 0 before put for this codepath.
It isn't for other protocols, and then any protocol headers would have
been counted.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ