# \[PATCH v1 2/5\] IB/uverbs: ex\_query\_device: check request's comp\_mask

- Subsystems: INFINIBAND SUBSYSTEM, THE REST
- Maintainers: Jason Gunthorpe, Leon Romanovsky, Linus Torvalds
- List: linux-api
- 1 message, 1 author
- Page: https://ratatoskr.run/linux-api/2015/01/13329039/t

## \[PATCH v1 2/5\] IB/uverbs: ex\_query\_device: check request's comp\_mask

- From: Yann Droneaud \<hidden\>
- Date: 2015-01-29 17:59:59 
- Message: https://ratatoskr.run/linux-api/2015/01/13329039.md

```text
This patch ensures the extended QUERY_DEVICE uverbs request's
comp_mask has only known and supported bits (currently none).

If userspace set unknown features bits, -EINVAL will be returned,
ensuring current programs are not allowed to set random feature
bits: such bits could enable new extended features in future kernel
versions and those features can trigger a behavior not unsupported
by the older programs or make the newer kernels return an error
for a request which was valid on older kernels.

Additionally, returning an error for unsupported feature would
allow userspace to probe/discover which extended features are
currently supported by a kernel.

Link: http://mid.gmane.org/cover.1422553023.git.ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org
Cc: Sagi Grimberg <redacted>
Cc: Shachar Raindel <redacted>
Cc: Eli Cohen <redacted>
Cc: Haggai Eran <redacted>
Signed-off-by: Yann Droneaud <redacted>
---
 drivers/infiniband/core/uverbs_cmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 6ef06a9b4362..fbcc54b86795 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -3312,6 +3312,9 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
 	if (err)
 		return err;
 
+	if (cmd.comp_mask)
+		return -EINVAL;
+
 	if (cmd.reserved)
 		return -EINVAL;
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
```
