Thread (73 messages) flat view 73 messages, 4 authors, 2021-07-09

Re: [PATCH] net: tun: fix tun_xdp_one() for IFF_TUN mode

From: David Woodhouse <dwmw2@infradead.org>
Date: 2021-06-22 08:29:22

On Tue, 2021-06-22 at 16:00 +0800, Jason Wang wrote:
quoted
I'm tempted to add a new feature for that 1:1 access, with no ->umem or
->iotlb at all. And then I can use it as a key to know that the XDP
bugs are fixed too :)

This means we need validate the userspace address each time before vhost 
tries to use that. This will de-gradate the performance. So we still 
need to figure out the legal userspace address range which might not be 
easy.
Easier from the kernel than from userspace though :)

But I don't know that we need it. Isn't a call to access_ok() going to
be faster than what translate_desc() does to look things up anyway?

In the 1:1 mode, the access_ok() is all that's needed since there's no
translation.
@@ -2038,6 +2065,14 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
        u64 s = 0;
        int ret = 0;
 
+       if (vhost_has_feature(vq, VHOST_F_IDENTITY_MAPPING)) {
+               if (!access_ok((void __user *)addr, len))
+                       return -EFAULT;
+
+               iov[0].iov_len = len;
+               iov[0].iov_base = (void __user *)addr;
+               return 1;
+       }
        while ((u64)len > s) {
                u64 size;
                if (unlikely(ret >= iov_size)) {

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help