Skip to contentSkip to conversation

vhost/crypto: fix missing head correction

PATCH Applied Fan Zhang 3 participants 4 messages Apr 27, 2018

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 vhost/crypto: fix missing head correction

Fixes 473387aaae4a ("vhost/crypto: move to safe GPA translation API")

This patch fixes the missing head descriptor correction for indirect descriptors.

---
 lib/librte_vhost/vhost_crypto.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_crypto.c +1 -0
index c38eb3bb5..81fab7e94 100644
@@ -919,6 +919,7 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto,
 		if (unlikely(!desc || dlen != head->len))
 			return -1;
 		desc_idx = 0;
+		head = desc;
 	} else {
 		desc = head;
 	}
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw

Hi Fan,

Quoted 15 lines · Fan Zhang
Fixes 473387aaae4a ("vhost/crypto: move to safe GPA translation API")

This patch fixes the missing head descriptor correction for indirect descriptors.

---
  lib/librte_vhost/vhost_crypto.c | 1 +
  1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_crypto.c +0 -0
index c38eb3bb5..81fab7e94 100644

lib/librte_vhost/vhost_crypto.c vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, · line 922

Quoted 4 lines
lib/librte_vhost/vhost_crypto.c +1 -0
@@ -919,6 +919,7 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto,
  		if (unlikely(!desc || dlen != head->len))
  			return -1;
  		desc_idx = 0;
+		head = desc;

Thanks for fixing this, and sorry for having introduced the regression.

BTW, my patch is half-complete. Indeed, it ensures no out-of-bound accesses will be done, but it does not handle legit buffers that are contiguous in guest physical address space, but discontiguous in the host VA space. Such case can for example happen when having buffers larger than the huge page size.

I have implemented the handling of such buffers in virtio-net.c, for example:

fb3815cc6 vhost: handle virtually non-contiguous buffers in Rx-mrg 6727f5a73 vhost: handle virtually non-contiguous buffers in Rx 91b7b4080 vhost: handle virtually non-contiguous buffers in Tx d0c24508e vhost: add support for non-contiguous indirect descs tables

Can you try to work on such handling for next -rc release?

For this patch:

Thanks,
Maxime

Quoted 4 lines
lib/librte_vhost/vhost_crypto.c +0 -0
  	} else {
  		desc = head;
  	}
#2 lore raw

Hi Maxime,

No problem. I will work on it.

Regards,
Fan

Quoted 60 lines

-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Friday, April 27, 2018 3:19 PM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: Re: [PATCH] vhost/crypto: fix missing head correction

Hi Fan,

lib/librte_vhost/vhost_crypto.c vhost_crypto_process_one_req(struct

Quoted 15 lines · Fan Zhang
Fixes 473387aaae4a ("vhost/crypto: move to safe GPA translation API")

This patch fixes the missing head descriptor correction for indirect descriptors.

---
  lib/librte_vhost/vhost_crypto.c | 1 +
  1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/lib/librte_vhost/vhost_crypto.c index c38eb3bb5..81fab7e94 100644

lib/librte_vhost/vhost_crypto.c +0 -0
@@ -919,6 +919,7 @@ vhost_crypto_process_one_req(struct

vhost_crypto *vcrypto,

lib/librte_vhost/vhost_crypto.c vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, · line 922

Quoted 4 lines
lib/librte_vhost/vhost_crypto.c +1 -0
  		if (unlikely(!desc || dlen != head->len))
  			return -1;
  		desc_idx = 0;
+		head = desc;

Thanks for fixing this, and sorry for having introduced the regression.

BTW, my patch is half-complete. Indeed, it ensures no out-of-bound accesses will be done, but it does not handle legit buffers that are contiguous in guest physical address space, but discontiguous in the host VA space. Such case can for example happen when having buffers larger than the huge page size.

I have implemented the handling of such buffers in virtio-net.c, for example:

fb3815cc6 vhost: handle virtually non-contiguous buffers in Rx-mrg 6727f5a73 vhost: handle virtually non-contiguous buffers in Rx 91b7b4080 vhost: handle virtually non-contiguous buffers in Tx d0c24508e
vhost: add support for non-contiguous indirect descs tables

Can you try to work on such handling for next -rc release?

For this patch:

Thanks,
Maxime

Quoted 4 lines
lib/librte_vhost/vhost_crypto.c +0 -0
  	} else {
  		desc = head;
  	}
#3 lore raw
In reply to Maxime Coquelin

27/04/2018 16:19, Maxime Coquelin:

Quoted 39 lines

Hi Fan,

Quoted 15 lines · Fan Zhang
Fixes 473387aaae4a ("vhost/crypto: move to safe GPA translation API")

This patch fixes the missing head descriptor correction for indirect descriptors.

---
  lib/librte_vhost/vhost_crypto.c | 1 +
  1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_crypto.c +0 -0
index c38eb3bb5..81fab7e94 100644

lib/librte_vhost/vhost_crypto.c vhost_crypto_process_one_req(struct vhost_crypto *vcrypto, · line 922

Quoted 4 lines
lib/librte_vhost/vhost_crypto.c +1 -0
@@ -919,6 +919,7 @@ vhost_crypto_process_one_req(struct vhost_crypto *vcrypto,
  		if (unlikely(!desc || dlen != head->len))
  			return -1;
  		desc_idx = 0;
+		head = desc;

Thanks for fixing this, and sorry for having introduced the regression.

BTW, my patch is half-complete. Indeed, it ensures no out-of-bound accesses will be done, but it does not handle legit buffers that are contiguous in guest physical address space, but discontiguous in the host VA space. Such case can for example happen when having buffers larger than the huge page size.

I have implemented the handling of such buffers in virtio-net.c, for example:

fb3815cc6 vhost: handle virtually non-contiguous buffers in Rx-mrg 6727f5a73 vhost: handle virtually non-contiguous buffers in Rx 91b7b4080 vhost: handle virtually non-contiguous buffers in Tx d0c24508e vhost: add support for non-contiguous indirect descs tables

Quoted 5 lines

Can you try to work on such handling for next -rc release?

For this patch:

Applied as hot patch for RC1, thanks