[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC net-next 04/18] tuntap: check tun_msg_ctl type at necessary places
From: |
Prashant Bhole |
Subject: |
[RFC net-next 04/18] tuntap: check tun_msg_ctl type at necessary places |
Date: |
Tue, 26 Nov 2019 19:07:30 +0900 |
tun_msg_ctl is used by vhost_net to communicate with tuntap. We will
introduce another type in soon. As a preparation this patch adds
conditions to check tun_msg_ctl type at necessary places.
Signed-off-by: Prashant Bhole <address@hidden>
---
drivers/net/tap.c | 7 +++++--
drivers/net/tun.c | 6 +++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 3ae70c7e6860..4df7bf00af66 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -1213,6 +1213,7 @@ static int tap_sendmsg(struct socket *sock, struct msghdr
*m,
struct tap_queue *q = container_of(sock, struct tap_queue, sock);
struct tun_msg_ctl *ctl = m->msg_control;
struct xdp_buff *xdp;
+ void *ptr = NULL;
int i;
if (ctl && (ctl->type == TUN_MSG_PTR)) {
@@ -1223,8 +1224,10 @@ static int tap_sendmsg(struct socket *sock, struct
msghdr *m,
return 0;
}
- return tap_get_user(q, ctl ? ctl->ptr : NULL, &m->msg_iter,
- m->msg_flags & MSG_DONTWAIT);
+ if (ctl && ctl->type == TUN_MSG_UBUF)
+ ptr = ctl->ptr;
+
+ return tap_get_user(q, ptr, &m->msg_iter, m->msg_flags & MSG_DONTWAIT);
}
static int tap_recvmsg(struct socket *sock, struct msghdr *m,
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 683d371e6e82..1e436d9ec4e1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2529,6 +2529,7 @@ static int tun_sendmsg(struct socket *sock, struct msghdr
*m, size_t total_len)
struct tun_struct *tun = tun_get(tfile);
struct tun_msg_ctl *ctl = m->msg_control;
struct xdp_buff *xdp;
+ void *ptr = NULL;
if (!tun)
return -EBADFD;
@@ -2560,7 +2561,10 @@ static int tun_sendmsg(struct socket *sock, struct
msghdr *m, size_t total_len)
goto out;
}
- ret = tun_get_user(tun, tfile, ctl ? ctl->ptr : NULL, &m->msg_iter,
+ if (ctl && ctl->type == TUN_MSG_UBUF)
+ ptr = ctl->ptr;
+
+ ret = tun_get_user(tun, tfile, ptr, &m->msg_iter,
m->msg_flags & MSG_DONTWAIT,
m->msg_flags & MSG_MORE);
out:
--
2.20.1
- [RFC net-next 00/18] virtio_net XDP offload, Prashant Bhole, 2019/11/26
- [RFC net-next 04/18] tuntap: check tun_msg_ctl type at necessary places,
Prashant Bhole <=
- [RFC net-next 16/18] bpf: export function __bpf_map_get, Prashant Bhole, 2019/11/26
- [RFC net-next 18/18] virtio_net: restrict bpf helper calls from offloaded program, Prashant Bhole, 2019/11/26
- [RFC net-next 14/18] virtio_net: add XDP prog offload infrastructure, Prashant Bhole, 2019/11/26
- [RFC net-next 12/18] virtio-net: store xdp_prog in device, Prashant Bhole, 2019/11/26
- [RFC net-next 17/18] virtio_net: implment XDP map offload functionality, Prashant Bhole, 2019/11/26
- [RFC net-next 15/18] virtio_net: implement XDP prog offload functionality, Prashant Bhole, 2019/11/26
- [RFC net-next 10/18] tun: handle XDP_TX action of offloaded program, Prashant Bhole, 2019/11/26
- [RFC net-next 09/18] tun: add a way to inject Tx path packet into Rx path, Prashant Bhole, 2019/11/26