[v3,net-next,10/19] tls: Fix zerocopy_from_iter iov handling

Message ID 1531338873-18466-11-git-send-email-borisp@mellanox.com
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • TLS offload rx, netdev & mlx5
Related show

Commit Message

Boris Pismenny July 11, 2018, 7:54 p.m.
zerocopy_from_iter iterates over the message, but it doesn't revert the
updates made by the iov iteration. This patch fixes it. Now, the iov can
be used after calling zerocopy_from_iter.

Fixes: 3c4d75591 ("tls: kernel TLS support")
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
---
 net/tls/tls_sw.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Dave Watson July 12, 2018, 4:46 p.m. | #1
On 07/11/18 10:54 PM, Boris Pismenny wrote:
> zerocopy_from_iter iterates over the message, but it doesn't revert the
> updates made by the iov iteration. This patch fixes it. Now, the iov can
> be used after calling zerocopy_from_iter.

This breaks tests (which I will send up as selftests shortly).  I
believe we are depending on zerocopy_from_iter to advance the iter,
and if zerocopy_from_iter returns a failure, then we revert it.  So
you can revert it here if you want, but you'd have to advance it if we
actually used it instead.
Boris Pismenny July 12, 2018, 7:28 p.m. | #2
On 7/12/2018 12:46 PM, Dave Watson wrote:
> On 07/11/18 10:54 PM, Boris Pismenny wrote:
>> zerocopy_from_iter iterates over the message, but it doesn't revert the
>> updates made by the iov iteration. This patch fixes it. Now, the iov can
>> be used after calling zerocopy_from_iter.
> 
> This breaks tests (which I will send up as selftests shortly).  I
> believe we are depending on zerocopy_from_iter to advance the iter,
> and if zerocopy_from_iter returns a failure, then we revert it.  So
> you can revert it here if you want, but you'd have to advance it if we
> actually used it instead.
> 

Only in the send side do we depend on this semantic. On the receive 
side, we need to revert it in case we go to the fallback flow.

Patch

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 2a6ba0f..37ac220 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -318,6 +318,7 @@  static int zerocopy_from_iter(struct sock *sk, struct iov_iter *from,
 out:
 	*size_used = size;
 	*pages_used = num_elem;
+	iov_iter_revert(from, size);
 
 	return rc;
 }