From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
oss-drivers@netronome.com, borisp@mellanox.com,
aviadye@mellanox.com, daniel@iogearbox.net,
syzbot+f8495bff23a879a6d0bd@syzkaller.appspotmail.com,
syzbot+6f50c99e8f6194bf363f@syzkaller.appspotmail.com,
Eric Biggers <ebiggers@kernel.org>,
herbert@gondor.apana.org.au, glider@google.com,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH net] net/tls: fix sk_msg trim on fallback to copy mode
Date: Mon, 4 Nov 2019 11:34:07 -0800 [thread overview]
Message-ID: <20191104113407.7da3ed44@cakuba.netronome.com> (raw)
In-Reply-To: <5dc074744c05c_47f72aeaf1bf65c456@john-XPS-13-9370.notmuch>
On Mon, 04 Nov 2019 10:56:52 -0800, John Fastabend wrote:
> Jakub Kicinski wrote:
> > diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> > index cf390e0aa73d..f87fde3a846c 100644
> > --- a/net/core/skmsg.c
> > +++ b/net/core/skmsg.c
> > @@ -270,18 +270,28 @@ void sk_msg_trim(struct sock *sk, struct sk_msg *msg, int len)
> >
> > msg->sg.data[i].length -= trim;
> > sk_mem_uncharge(sk, trim);
> > + /* Adjust copybreak if it falls into the trimmed part of last buf */
> > + if (msg->sg.curr == i && msg->sg.copybreak > msg->sg.data[i].length)
> > + msg->sg.copybreak = msg->sg.data[i].length;
> > out:
> > - /* If we trim data before curr pointer update copybreak and current
> > - * so that any future copy operations start at new copy location.
> > + sk_msg_iter_var_next(i);
> > + msg->sg.end = i;
> > +
> > + /* If we trim data a full sg elem before curr pointer update
> > + * copybreak and current so that any future copy operations
> > + * start at new copy location.
> > * However trimed data that has not yet been used in a copy op
> > * does not require an update.
> > */
> > - if (msg->sg.curr >= i) {
> > + if (!msg->sg.size) {
> > + msg->sg.curr = msg->sg.start;
> > + msg->sg.copybreak = 0;
> > + } else if (sk_msg_iter_dist(msg->sg.start, msg->sg.curr) >
> > + sk_msg_iter_dist(msg->sg.end, msg->sg.curr)) {
>
> I'm not seeing how this can work. Taking simple case with start < end
> so normal geometry without wrapping. Let,
>
> start = 1
> curr = 3
> end = 4
>
> We could trim an index to get,
>
> start = 1
> curr = 3
> i = 3
> end = 4
IOW like this?
test_one(/* start */ 1, /* curr */ 3, /* copybreak */ 150,
/* trim */ 500,
/* curr */ 3, /* copybreak */ 100, /* end */ 4,
/* data */ 200, 200, 200);
test #13 start:1 curr:3 end:4 cb:150 size: 600 0 200 200 200 0 OKAY
> Then after out: label this would push end up one,
>
> start = 1
> curr = 3
> i = 3
> end = 4
I moved the assignment to end before the curr adjustment, so 'i' is
equivalent to 'end' at this point.
> But dist(start,curr) = 2 and dist(end, curr) = 1 and we would set curr
> to '3' but clear the copybreak?
I don't think we'd fall into this condition ever, unless we moved end.
And in your example AFAIU we don't move end.
> I think a better comparison would be,
>
> if (sk_msg_iter_dist(msg->sg.start, i) <
> sk_msg_iter_dist(msg->sg.start, msg->sg.curr)
>
> To check if 'i' walked past curr so we can reset curr/copybreak?
Ack, this does read better!
Should we use <= here? If we dropped a full segment, should curr point
at the end of the last remaining segment or should it point at 0 in end?
next prev parent reply other threads:[~2019-11-04 19:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 16:05 [PATCH net] net/tls: fix sk_msg trim on fallback to copy mode Jakub Kicinski
2019-10-31 21:16 ` Jakub Kicinski
2019-10-31 22:05 ` John Fastabend
2019-10-31 22:08 ` John Fastabend
2019-10-31 22:24 ` Jakub Kicinski
2019-11-01 1:41 ` Jakub Kicinski
2019-11-01 4:44 ` John Fastabend
2019-11-01 4:54 ` Jakub Kicinski
2019-11-01 15:01 ` John Fastabend
2019-11-01 17:22 ` [oss-drivers] " Jakub Kicinski
2019-11-01 19:51 ` Jakub Kicinski
2019-11-04 18:56 ` John Fastabend
2019-11-04 19:34 ` Jakub Kicinski [this message]
2019-11-04 22:58 ` John Fastabend
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=20191104113407.7da3ed44@cakuba.netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=aviadye@mellanox.com \
--cc=borisp@mellanox.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=glider@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=john.fastabend@gmail.com \
--cc=linux-crypto@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=syzbot+6f50c99e8f6194bf363f@syzkaller.appspotmail.com \
--cc=syzbot+f8495bff23a879a6d0bd@syzkaller.appspotmail.com \
/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