RDMA/uverbs: Zero the QP attrs in ib_uverbs_query_qp
PATCH 1/1 RDMA/uverbs: Zero the QP attrs in ib_uverbs_query_qp
ib_uverbs_query_qp() allocates qp_attr and qp_init_attr without zeroing and copies fields such as alt_ah_attr, path_mig_state and sq_draining to userspace. Drivers are not required to set every field in their query_qp() callback, so uninitialized kernel heap memory can leak.
Allocate both structures zeroed.
--- drivers/infiniband/core/uverbs_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +2 -2
@@ -1668,8 +1668,8 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs)if (ret)return ret; - attr =kmalloc_obj (*attr); - init_attr =kmalloc_obj (*init_attr); + attr =kzalloc_obj (*attr); + init_attr =kzalloc_obj (*init_attr);if (!attr || !init_attr) { ret = -ENOMEM ; goto out;
Signature · 1 line
2.39.3
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 9 lines
ib_uverbs_query_qp()allocatesqp_attrandqp_init_attrwithout zeroing and copies fields such asalt_ah_attr,path_mig_stateandsq_drainingto userspace. Drivers are not required to set every field in theirquery_qp()callback, so uninitialized kernel heap memory can leak.Allocate both structures zeroed.
Fixes 7ccc9a24e012 ("IB/uverbs: Support for query QP from userspace")Signed-off-by Selvin Xavier <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Leon Romanovsky
AppliedQuoted 8 lines · Selvin Xavier
ib_uverbs_query_qp()allocatesqp_attrandqp_init_attrwithout zeroing and copies fields such asalt_ah_attr,path_mig_stateandsq_drainingto userspace. Drivers are not required to set every field in theirquery_qp()callback, so uninitialized kernel heap memory can leak.Allocate both structures zeroed.
[...]
Applied, thanks!
[1/1] RDMA/uverbs: Zero the QP attrs in ib_uverbs_query_qp
https://git.kernel.org/rdma/rdma/c/997ca6555b9fc3
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>