Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andraprs@amazon.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Andra Paraschiv and committed by
Jakub Kicinski
cada7ccd caaf95e0

+3 -1
+3 -1
net/vmw_vsock/vsock_addr.c
··· 22 22 23 23 int vsock_addr_validate(const struct sockaddr_vm *addr) 24 24 { 25 + __u8 svm_valid_flags = VMADDR_FLAG_TO_HOST; 26 + 25 27 if (!addr) 26 28 return -EFAULT; 27 29 28 30 if (addr->svm_family != AF_VSOCK) 29 31 return -EAFNOSUPPORT; 30 32 31 - if (addr->svm_zero[0] != 0) 33 + if (addr->svm_flags & ~svm_valid_flags) 32 34 return -EINVAL; 33 35 34 36 return 0;