Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2225121imm; Thu, 18 Oct 2018 11:00:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aOa0xPpNCBLQnneM8lbojjJz4KAFYVnOlbJBWF3tjKlSimHf+i0ylzy5lHQFTwY4773JO X-Received: by 2002:a17:902:9a04:: with SMTP id v4-v6mr30475307plp.247.1539885609808; Thu, 18 Oct 2018 11:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539885609; cv=none; d=google.com; s=arc-20160816; b=fs9PRnxQk1bBby7yH4+jRN70v9akeSJ7FGDexLKxrMPPk2m9RY8Oog6TBBRC/o5E7Q lnh5gnRY+nOQPfFMAyRJRjoDzAP5s3jxTBgCPrbGsDS5RLQIeA0mGgZqp4ATCYo/1+Cl kiqnbTAnnQ5udkdoRn9oIqrKbbqaQ9+hAV+R3Rvu0w6e/B9FWlWhHcc8hCdXwhiyxTN9 sINavWtVyxMnVeN+mzy51dc8M3+AM+3Vv+fY/5CY/l301SYiQ9OpleraxQ9mW3c76XzG ADuzXtVyP1iIswLr8wlognUwt86pQ74Gzmiy60FaDMZHG0+h9p0+h+uUpo9IE3n5juQ0 M8yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=seSYYwTC61yICTQUG1Nrk7yY1NnpnpGUsqONa3HO0kw=; b=Itwb0mEPR4dh6GcJ9f7zzSOSapWzZSdJNT2/YahDOM6SCWXUMvOMljbhLlLCPgPw8n qivnInrWK+E2UHMHp1ko/FbOTmTvm2T6/xry4NwvFbKki37OQUxvE+tRQr9zm/gMEZi+ x/ghrsv7ckkcLuYcM0HvBP9aXy1xygb3CC3sSOaiU5EgIYCPoq/iGls84jWLX2B2XHzs E8H0xC87f/bgky/JVX9du4bMy00ZAJG2qQNtwlY/sKktEMZtgJySAaBhiRHVaQi1WD6N A2UPldl5rsRcokFdgPAGKhfGv8HPob5w1qNVG5Zf/NfIP52I3FgvK29s143MHNiR/LfF n0Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KurtyGcb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l136-v6si23735789pfd.132.2018.10.18.10.59.54; Thu, 18 Oct 2018 11:00:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KurtyGcb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbeJSB7s (ORCPT + 99 others); Thu, 18 Oct 2018 21:59:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:47448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbeJSB7s (ORCPT ); Thu, 18 Oct 2018 21:59:48 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 551BF21473; Thu, 18 Oct 2018 17:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885462; bh=Wq+tcVeq0WWjMCmCgQ/ynKNfS+9YUAe3PXg7P8wpVQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KurtyGcbPrirXNiJt42WNc4x/cGb+hz8/IMznXh9uxoxhdWiQ9jBhbHtGDzyFbQYC SozlLel9GYOHN4esXV/wxDfnF7JuhjZOuRkf9HfVu2UfFlmw7LZGK73w+ZmMgMqsLT oT3QryWMm/Q8Qnxub3lvOmIUlqRUDAcvUZYYP/gA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Majd Dibbiny , Jack Morgenstein , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.18 31/53] RDMA/uverbs: Fix validity check for modify QP Date: Thu, 18 Oct 2018 19:54:24 +0200 Message-Id: <20181018175422.258900545@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.561567978@linuxfoundation.org> References: <20181018175416.561567978@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Majd Dibbiny [ Upstream commit 4eeed3686981ff887bbdd7254139e2eca276534c ] Uverbs shouldn't enforce QP state in the command unless the user set the QP state bit in the attribute mask. In addition, only copy qp attr fields which have the corresponding bit set in the attribute mask over to the internal attr structure. Fixes: 88de869bbe4f ("RDMA/uverbs: Ensure validity of current QP state value") Fixes: bc38a6abdd5a ("[PATCH] IB uverbs: core implementation") Signed-off-by: Majd Dibbiny Signed-off-by: Jack Morgenstein Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/uverbs_cmd.c | 68 +++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 23 deletions(-) --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -2048,33 +2048,55 @@ static int modify_qp(struct ib_uverbs_fi if ((cmd->base.attr_mask & IB_QP_CUR_STATE && cmd->base.cur_qp_state > IB_QPS_ERR) || - cmd->base.qp_state > IB_QPS_ERR) { + (cmd->base.attr_mask & IB_QP_STATE && + cmd->base.qp_state > IB_QPS_ERR)) { ret = -EINVAL; goto release_qp; } - attr->qp_state = cmd->base.qp_state; - attr->cur_qp_state = cmd->base.cur_qp_state; - attr->path_mtu = cmd->base.path_mtu; - attr->path_mig_state = cmd->base.path_mig_state; - attr->qkey = cmd->base.qkey; - attr->rq_psn = cmd->base.rq_psn; - attr->sq_psn = cmd->base.sq_psn; - attr->dest_qp_num = cmd->base.dest_qp_num; - attr->qp_access_flags = cmd->base.qp_access_flags; - attr->pkey_index = cmd->base.pkey_index; - attr->alt_pkey_index = cmd->base.alt_pkey_index; - attr->en_sqd_async_notify = cmd->base.en_sqd_async_notify; - attr->max_rd_atomic = cmd->base.max_rd_atomic; - attr->max_dest_rd_atomic = cmd->base.max_dest_rd_atomic; - attr->min_rnr_timer = cmd->base.min_rnr_timer; - attr->port_num = cmd->base.port_num; - attr->timeout = cmd->base.timeout; - attr->retry_cnt = cmd->base.retry_cnt; - attr->rnr_retry = cmd->base.rnr_retry; - attr->alt_port_num = cmd->base.alt_port_num; - attr->alt_timeout = cmd->base.alt_timeout; - attr->rate_limit = cmd->rate_limit; + if (cmd->base.attr_mask & IB_QP_STATE) + attr->qp_state = cmd->base.qp_state; + if (cmd->base.attr_mask & IB_QP_CUR_STATE) + attr->cur_qp_state = cmd->base.cur_qp_state; + if (cmd->base.attr_mask & IB_QP_PATH_MTU) + attr->path_mtu = cmd->base.path_mtu; + if (cmd->base.attr_mask & IB_QP_PATH_MIG_STATE) + attr->path_mig_state = cmd->base.path_mig_state; + if (cmd->base.attr_mask & IB_QP_QKEY) + attr->qkey = cmd->base.qkey; + if (cmd->base.attr_mask & IB_QP_RQ_PSN) + attr->rq_psn = cmd->base.rq_psn; + if (cmd->base.attr_mask & IB_QP_SQ_PSN) + attr->sq_psn = cmd->base.sq_psn; + if (cmd->base.attr_mask & IB_QP_DEST_QPN) + attr->dest_qp_num = cmd->base.dest_qp_num; + if (cmd->base.attr_mask & IB_QP_ACCESS_FLAGS) + attr->qp_access_flags = cmd->base.qp_access_flags; + if (cmd->base.attr_mask & IB_QP_PKEY_INDEX) + attr->pkey_index = cmd->base.pkey_index; + if (cmd->base.attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) + attr->en_sqd_async_notify = cmd->base.en_sqd_async_notify; + if (cmd->base.attr_mask & IB_QP_MAX_QP_RD_ATOMIC) + attr->max_rd_atomic = cmd->base.max_rd_atomic; + if (cmd->base.attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) + attr->max_dest_rd_atomic = cmd->base.max_dest_rd_atomic; + if (cmd->base.attr_mask & IB_QP_MIN_RNR_TIMER) + attr->min_rnr_timer = cmd->base.min_rnr_timer; + if (cmd->base.attr_mask & IB_QP_PORT) + attr->port_num = cmd->base.port_num; + if (cmd->base.attr_mask & IB_QP_TIMEOUT) + attr->timeout = cmd->base.timeout; + if (cmd->base.attr_mask & IB_QP_RETRY_CNT) + attr->retry_cnt = cmd->base.retry_cnt; + if (cmd->base.attr_mask & IB_QP_RNR_RETRY) + attr->rnr_retry = cmd->base.rnr_retry; + if (cmd->base.attr_mask & IB_QP_ALT_PATH) { + attr->alt_port_num = cmd->base.alt_port_num; + attr->alt_timeout = cmd->base.alt_timeout; + attr->alt_pkey_index = cmd->base.alt_pkey_index; + } + if (cmd->base.attr_mask & IB_QP_RATE_LIMIT) + attr->rate_limit = cmd->rate_limit; if (cmd->base.attr_mask & IB_QP_AV) copy_ah_attr_from_uverbs(qp->device, &attr->ah_attr,