diff mbox

IB/uverbs: Fix validating mandatory attributes

Message ID 20180424081520.128598-1-matanb@mellanox.com (mailing list archive)
State Accepted
Headers show

Commit Message

Matan Barak April 24, 2018, 8:15 a.m. UTC
Previously, if a method contained mandatory attributes in a namespace
that wasn't given by the user, these attributes weren't validated.
Fixing this by iterating over all specification namespaces.

Fixes: fac9658cabb9 ("IB/core: Add new ioctl interface")
Signed-off-by: Matan Barak <matanb@mellanox.com>
---
Hi Doug and Jason,

This patch fixes an issue where a method could be called even though
not all its mandatory attributes were given.

Regards,
Matan

 drivers/infiniband/core/uverbs_ioctl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Doug Ledford April 27, 2018, 5:54 p.m. UTC | #1
On Tue, 2018-04-24 at 08:15 +0000, Matan Barak wrote:
> Previously, if a method contained mandatory attributes in a namespace
> that wasn't given by the user, these attributes weren't validated.
> Fixing this by iterating over all specification namespaces.
> 
> Fixes: fac9658cabb9 ("IB/core: Add new ioctl interface")
> Signed-off-by: Matan Barak <matanb@mellanox.com>

Thanks, applied to for-rc.
diff mbox

Patch

diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c
index 28b7719302f6..08939a6b155a 100644
--- a/drivers/infiniband/core/uverbs_ioctl.c
+++ b/drivers/infiniband/core/uverbs_ioctl.c
@@ -235,6 +235,15 @@  static int uverbs_validate_kernel_mandatory(const struct uverbs_method_spec *met
 			return -EINVAL;
 	}
 
+	for (; i < method_spec->num_buckets; i++) {
+		struct uverbs_attr_spec_hash *attr_spec_bucket =
+			method_spec->attr_buckets[i];
+
+		if (!bitmap_empty(attr_spec_bucket->mandatory_attrs_bitmask,
+				  attr_spec_bucket->num_attrs))
+			return -EINVAL;
+	}
+
 	return 0;
 }