netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>, davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	borisp@mellanox.com, aviadye@mellanox.com,
	john.fastabend@gmail.com, daniel@iogearbox.net,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	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 v2] net/tls: fix sk_msg trim on fallback to copy mode
Date: Tue, 05 Nov 2019 06:48:05 -0800	[thread overview]
Message-ID: <5dc18ba56aec_48332abec96485b835@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20191104233657.21054-1-jakub.kicinski@netronome.com>

Jakub Kicinski wrote:
> sk_msg_trim() tries to only update curr pointer if it falls into
> the trimmed region. The logic, however, does not take into the
> account pointer wrapping that sk_msg_iter_var_prev() does nor
> (as John points out) the fact that msg->sg is a ring buffer.
> 
> This means that when the message was trimmed completely, the new
> curr pointer would have the value of MAX_MSG_FRAGS - 1, which is
> neither smaller than any other value, nor would it actually be
> correct.
> 
> Special case the trimming to 0 length a little bit and rework
> the comparison between curr and end to take into account wrapping.
> 
> This bug caused the TLS code to not copy all of the message, if
> zero copy filled in fewer sg entries than memcopy would need.
> 
> Big thanks to Alexander Potapenko for the non-KMSAN reproducer.
> 
> v2:
>  - take into account that msg->sg is a ring buffer (John).
> 
> Link: https://lore.kernel.org/netdev/20191030160542.30295-1-jakub.kicinski@netronome.com/ (v1)
> 
> Fixes: d829e9c4112b ("tls: convert to generic sk_msg interface")
> Reported-by: syzbot+f8495bff23a879a6d0bd@syzkaller.appspotmail.com
> Reported-by: syzbot+6f50c99e8f6194bf363f@syzkaller.appspotmail.com
> Co-developed-by: John Fastabend <john.fastabend@gmail.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> ---
> CC: Eric Biggers <ebiggers@kernel.org>
> CC: herbert@gondor.apana.org.au
> CC: glider@google.com
> CC: linux-crypto@vger.kernel.org
> ---

I'll run it through our CI here when I get a chance but LGTM
thanks for sending this and tracking it down. Per process.rst
I guess we add Signed-off-by lines instead of acks from
co-developers. News to me.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>

  reply	other threads:[~2019-11-05 14:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 23:36 [PATCH net v2] net/tls: fix sk_msg trim on fallback to copy mode Jakub Kicinski
2019-11-05 14:48 ` John Fastabend [this message]
2019-11-06  2:08 ` David Miller

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=5dc18ba56aec_48332abec96485b835@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.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=jakub.kicinski@netronome.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;
as well as URLs for NNTP newsgroup(s).