netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dominique Martinet <asmadeus@codewreck.org>
To: Tom Herbert <tom@quantonium.net>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: KCM - recvmsg() mangles packets?
Date: Fri, 10 Aug 2018 00:06:46 +0200	[thread overview]
Message-ID: <20180809220646.GA15470@nautica> (raw)
In-Reply-To: <CAPDqMeptLoLZ2RU+T-d7YwkO2AeKV+nfow4C-LqqeZd9mo-vMg@mail.gmail.com>

Tom Herbert wrote on Thu, Aug 09, 2018:
> > diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
> > index 625acb27efcc..348ff5945591 100644
> > --- a/net/strparser/strparser.c
> > +++ b/net/strparser/strparser.c
> > @@ -222,6 +222,16 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
> >                 if (!stm->strp.full_len) {
> >                         ssize_t len;
> >
> > +                       /* Can only parse if there is no offset */
> > +                       if (unlikely(stm->strp.offset)) {
> > +                               if (!pskb_pull(skb, stm->strp.offset)) {
> > +                                       STRP_STATS_INCR(strp->stats.mem_fail);
> > +                                       strp_parser_err(strp, -ENOMEM, desc);
> > +                                       break;
> > +                               }
> > +                               stm->strp.offset = 0;
> > +                       }
> > +
> 
> Seems okay to me for a fix.

Hmm, if you say so, I'll send this as a patch for broader comments right
away.

> Looks like strp.offset is only set in one place and read in one
> place. With this pull maybe that just can go away?

Good point, when strp.offset is set the full_len is also being init'd so
we will necessarily do the pull next...

But the way tls uses strparser is also kind of weird, since they modify
the strp_msg's offset and full_len, I wouldn't want to assume we can't
have full_len == 0 *again* later with a non zero offset...
On the other hand they do handle non-zero offset in their parse function
so they'd be ok with that... Ultimately it's probably closer to a design
choice than anything else.


I'll still send a v0 of the patch as is, because I feel it's easier to
understand that we pull because the existing parse_msg functions do not
handle it properly, and will write a note that I intend to move it up a
few lines as a comment.


Thanks,
-- 
Dominique Martinet

      reply	other threads:[~2018-08-10  0:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 18:28 KCM - recvmsg() mangles packets? Dominique Martinet
2018-08-03 22:46 ` Tom Herbert
2018-08-03 23:20   ` Dominique Martinet
2018-08-04  1:18     ` Tom Herbert
2018-08-04  1:41       ` Dominique Martinet
2018-08-04  2:08         ` Dominique Martinet
2018-08-05  6:44           ` Dominique Martinet
2018-08-05 14:12             ` Dominique Martinet
2018-08-05 23:39               ` Dominique Martinet
2018-08-09 20:58                 ` Tom Herbert
2018-08-09 22:06                   ` Dominique Martinet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180809220646.GA15470@nautica \
    --to=asmadeus@codewreck.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom@quantonium.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).