From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796002410; b=YjaahssuYrX+bEaL33WjruTFEpnmZJkFDU1AnyeCmPixhNgA9cY6upNinl4oDRMNYnXG MhLoCyjkshu2njuVVUu0GhXHMg1tseVKtpvHNJKYRHvWzc780Dih8Bcs7fvPhMBS5GIB1 Ybqb/uaXhMFyub+lmhO9G8DE9Oj/UyptohEBjVS0BooZrqLShV87gTNnrD+lz6qx5Xc6r FXX53RDgHQHiQUNgCKqa1fLSOLds5J2DwqHHwtOSv2SLh058msFVh9xwMvvm+mDtd1SYH FRjhlA97Bdf+PtPRElCsH2padCPKOi5hX+tRHXkBzwYAAq0ivFhTtdWb5syWQ7zCgnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796002410; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=yRXD8e01Z6jvOsgfMSJhxeo/yawBjEjzHTXs2IeGaE8=; b=F+g8QY6xLhPQa9EGCBhHUlKOzCIUh4q0+Rb29CIDSIHw2uZiRH3WCP3sHNvNXJAECq/X HbsDEU1+/w8FnPFHyox9YpzOEOmIkj+VUNWfscRStjHiwHvluuKEllWHOUkEQ8pjArFGl omq8/kXc1u/s0HOC/rVohrcucBp5dfDBbDF269rfkztD6VAwe6PfYJyLlshfkQ9bP5S8b GUmr7EVEVZiKBn5p1qYHa6jjXxoc5C6+aNhI86OIUXOfYJ5JXFkH+TDDE1Q68ff4gTHTX m6S+CDb2lEX1gwKhtAUVvDYjoCo/db77VqszBgM5eN/AHEN26cNMarwP5MQ5RS2qyFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jmoroni.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="l/EFN8Zr"; arc=none smtp.remote-ip=209.85.219.72 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 530DB606A31C for ; Mon, 30 Nov 2026 01:33:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 530DB606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jmoroni.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=l/EFN8Zr Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-9210ad74fdeso164598016d6.0 for ; Sun, 29 Nov 2026 17:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796002409; x=1796607209; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yRXD8e01Z6jvOsgfMSJhxeo/yawBjEjzHTXs2IeGaE8=; b=l/EFN8ZrFKzv8U0wqxDN0/ejFLrSXNW2OKGCVIxVUNGy3GRMQc0mR1qUEdDSxypI46 SeQceXRFbx422QTH5mJTLRc/nqwbrjF/Q5QUbxpcu3oi6gUNeXC17uvOoVLEM4HQa8cR JjYcwSH8F94b3fwOnG1gQZc43IJMSiVT7lJfQG7u0+YhBAzvzzy1I64JNuN+YhbMmtPH ZnQdA8sfWfNQmaNgxjTnEqSix7ZhzK3NguU+wDJQOVJXodRCXY0SKo5Tua+UBJTo0bvw wilhsn2wv2KquROgbT39B0uVAmsV7fs1w0ghP943gpxNlXyqrtzW6cWGt9x9mL+3OYZE Iggg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796002409; x=1796607209; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yRXD8e01Z6jvOsgfMSJhxeo/yawBjEjzHTXs2IeGaE8=; b=Uj3SRXyjfgrt1Px1gu1Mjt7FxisCqf4F4noXs3UQQ1JBkdiQ2tcOP4pBfovIXisvKk rznZep4/78Sd8RIB9ZQPGgknlCsM+qElq7HPc3pN0tju/NXfiiwfMNhmFYpPwCS2KlWX VuYWnMBebyojoLcpwfJrVQr9gfkPT9myy25X5AeF6I2xVpl50YnGZjkmQSraGMQvKmDo 5ZXE3/y4UZOynTfZ2EhJWXiYVz/YG3NUWGFnzyc1QFs2q9tg21agObkgFF6u6FLoo4Cn pEUlPvlzg99lAYe45cfEKP87LAdpVCC6HE3Ue5Hf3jp0wfSve4i5WjB/La1ZFVwsa5Z7 Mocw== X-Gm-Message-State: APuU4Z8n9uXV5yF9X0hYJYT0c7AOWXVcPJa621wUpy+/+5fN152vYc+J rDfPylsFogyysc+6p24bpzE2FZAxEwd5zxK0ReaWpc0c5WlThZ416B7cyX2MPiajgvWdUxizUCq biEP0XO+rFA== X-Received: from qvbne1.prod.google.com ([2002:a05:6214:4241:b0:921:1d17:172e]) (user=jmoroni job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:496:b0:921:425e:ce17 with SMTP id 6a1803df08f44-921425ece58mr525899626d6.53.1796002408957; Sun, 29 Nov 2026 17:33:28 -0800 (PST) Date: Mon, 30 Nov 2026 01:33:03 +0000 In-Reply-To: <20261130013307.2848330-1-jmoroni@google.com> X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261130013307.2848330-1-jmoroni@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130013307.2848330-5-jmoroni@google.com> Subject: [PATCH rdma-next 4/8] RDMA/irdma: Validate legacy user QP sizes From: Jacob Moroni To: tatyana.e.nikolova@intel.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, jdz@google.com, Jacob Moroni Content-Type: text/plain; charset="UTF-8" A user context without IRDMA_ALLOC_UCTX_USE_RAW_ATTR passes SQ and RQ sizes in units of WQEs, which the kernel then multiplies by the WQE size to get the actual ring sizes. Only the values from user space are checked against the HW limits and there is no lower bound enforced. An SQ size of zero gives an empty ring, which causes a divide by zero in the various ring macros. The resulting ring sizes (post multiplication) can also exceed the HW limits. Fix this by rejecting an empty SQ and ring sizes above max_hw_wq_quanta and max_hw_rq_quanta, similar to how it's done for the current ABI. Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs") Signed-off-by: Jacob Moroni --- drivers/infiniband/hw/irdma/verbs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c index 93328b0abcbd..de727270ab87 100644 --- a/drivers/infiniband/hw/irdma/verbs.c +++ b/drivers/infiniband/hw/irdma/verbs.c @@ -677,6 +677,7 @@ static int irdma_setup_umode_qp(struct irdma_ucontext *ucontext, struct uverbs_attr_bundle *attrs) { struct irdma_qp_uk_init_info *ukinfo = &info->qp_uk_init_info; + u32 sq_quanta, rq_quanta; unsigned long flags; int ret; @@ -696,6 +697,12 @@ static int irdma_setup_umode_qp(struct irdma_ucontext *ucontext, ukinfo->rq_size = init_attr->cap.max_recv_wr; irdma_uk_calc_shift_wq(ukinfo, &ukinfo->sq_shift, &ukinfo->rq_shift); + sq_quanta = ukinfo->sq_size << ukinfo->sq_shift; + rq_quanta = ukinfo->rq_size << ukinfo->rq_shift; + if (!sq_quanta || + sq_quanta > ukinfo->uk_attrs->max_hw_wq_quanta || + rq_quanta > ukinfo->uk_attrs->max_hw_rq_quanta) + return -EINVAL; } else { ret = irdma_uk_calc_depth_shift_sq(ukinfo, &ukinfo->sq_depth, &ukinfo->sq_shift); -- 2.56.1.839.g22a8290db9-goog