]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/mana: Validate rx_hash_key_len
authorJason Gunthorpe <jgg@nvidia.com>
Mon, 18 May 2026 03:28:24 +0000 (23:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 May 2026 11:03:34 +0000 (13:03 +0200)
[ Upstream commit 6dd2d4ad9c8429523b1c220c5132bd551c006425 ]

Sashiko points out that rx_hash_key_len comes from a uAPI structure and is
blindly passed to memcpy, allowing the userspace to trash kernel
memory. Bounds check it so the memcpy cannot overflow.

Cc: stable@vger.kernel.org
Fixes: 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter")
Link: https://sashiko.dev/#/patchset/0-v2-1c49eeb88c48%2B91-rdma_udata_rep_jgg%40nvidia.com?part=1
Link: https://patch.msgid.link/r/4-v1-41f3135e5565+9d2-rdma_ai_fixes1_jgg@nvidia.com
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
[ kept the stable branch's existing `req_buf_size` calculation instead of upstream's `struct_size(req, indir_tab, ...)` form ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mana/qp.c

index 8009a339bf9ca7b9fa914ff5f53602b06a8c6b47..3f5d088ebe407ac89dd828b471a3ca026f6f6e6e 100644 (file)
@@ -24,6 +24,9 @@ static int mana_ib_cfg_vport_steering(struct mana_ib_dev *dev,
        mdev = dev->gdma_dev;
        gc = mdev->gdma_context;
 
+       if (rx_hash_key_len > sizeof(req->hashkey))
+               return -EINVAL;
+
        req_buf_size =
                sizeof(*req) + sizeof(mana_handle_t) * MANA_INDIRECT_TABLE_SIZE;
        req = kzalloc(req_buf_size, GFP_KERNEL);