From cada7ccd9dc75fc73de9342ae1dd0374e8fb1056 Mon Sep 17 00:00:00 2001 From: Andra Paraschiv Date: Mon, 14 Dec 2020 18:11:20 +0200 Subject: [PATCH] vsock_addr: Check for supported flag values Check if the provided flags value from the vsock address data structure includes the supported flags in the corresponding kernel version. The first byte of the "svm_zero" field is used as "svm_flags", so add the flags check instead. Changelog v3 -> v4 * New patch in v4. Signed-off-by: Andra Paraschiv Reviewed-by: Stefano Garzarella Signed-off-by: Jakub Kicinski --- net/vmw_vsock/vsock_addr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/vsock_addr.c b/net/vmw_vsock/vsock_addr.c index 909de26..223b966 100644 --- a/net/vmw_vsock/vsock_addr.c +++ b/net/vmw_vsock/vsock_addr.c @@ -22,13 +22,15 @@ EXPORT_SYMBOL_GPL(vsock_addr_init); int vsock_addr_validate(const struct sockaddr_vm *addr) { + __u8 svm_valid_flags = VMADDR_FLAG_TO_HOST; + if (!addr) return -EFAULT; if (addr->svm_family != AF_VSOCK) return -EAFNOSUPPORT; - if (addr->svm_zero[0] != 0) + if (addr->svm_flags & ~svm_valid_flags) return -EINVAL; return 0; -- 2.7.4