All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andra Paraschiv <andraprs@amazon.com>
To: netdev <netdev@vger.kernel.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	David Duncan <davdunc@amazon.com>,
	Dexuan Cui <decui@microsoft.com>, Alexander Graf <graf@amazon.de>,
	Jorgen Hansen <jhansen@vmware.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Andra Paraschiv <andraprs@amazon.com>
Subject: [PATCH net-next v4 3/5] vsock_addr: Check for supported flag values
Date: Mon, 14 Dec 2020 18:11:20 +0200	[thread overview]
Message-ID: <20201214161122.37717-4-andraprs@amazon.com> (raw)
In-Reply-To: <20201214161122.37717-1-andraprs@amazon.com>

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>
---
 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 909de26cb0e70..223b9660a759f 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.20.1 (Apple Git-117)




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


  parent reply	other threads:[~2020-12-14 16:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 16:11 [PATCH net-next v4 0/5] vsock: Add flags field in the vsock address Andra Paraschiv
2020-12-14 16:11 ` [PATCH net-next v4 1/5] vm_sockets: Add flags field in the vsock address data structure Andra Paraschiv
2020-12-14 16:11 ` [PATCH net-next v4 2/5] vm_sockets: Add VMADDR_FLAG_TO_HOST vsock flag Andra Paraschiv
2020-12-14 16:11 ` Andra Paraschiv [this message]
2020-12-14 17:07   ` [PATCH net-next v4 3/5] vsock_addr: Check for supported flag values Stefano Garzarella
2020-12-14 16:11 ` [PATCH net-next v4 4/5] af_vsock: Set VMADDR_FLAG_TO_HOST flag on the receive path Andra Paraschiv
2020-12-14 16:11 ` [PATCH net-next v4 5/5] af_vsock: Assign the vsock transport considering the vsock address flags Andra Paraschiv
2020-12-14 17:09 ` [PATCH net-next v4 0/5] vsock: Add flags field in the vsock address Stefano Garzarella
2020-12-14 18:19   ` Paraschiv, Andra-Irina
2020-12-15  3:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201214161122.37717-4-andraprs@amazon.com \
    --to=andraprs@amazon.com \
    --cc=davdunc@amazon.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=graf@amazon.de \
    --cc=jhansen@vmware.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.