Received: by 10.213.65.68 with SMTP id h4csp693408imn; Fri, 6 Apr 2018 07:23:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49FucL6HpoIfNuZwWcxmaTqo6s1Rj+nrCia7PvhoLhNda6GPgbnktnVF8THXPLKOTke07Lw X-Received: by 10.98.11.149 with SMTP id 21mr20443385pfl.64.1523024621690; Fri, 06 Apr 2018 07:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024621; cv=none; d=google.com; s=arc-20160816; b=xicwA3fdSrHhaKii5CoIn3EcyhzmScDFADZm3axMxKYZIMHiHg8UsindZCHQbSPqFR kQruOFR1WJacnLjflybdRwZXedm29/GwaesgbH22NvcxJM4BLOMguMu4vZmwyqE/mPOM 1jwWyQAelT8k8hNxI/BepF/JFHKFNVin88KyoYqKmRWplGv9NxKQ6LWTXxOgO9EvzqrF h+nO+FqRlLDsCz4JEgTX79da6ITyEBB7Siidj0eeaQBMnlCXtn9W/141DBh+/6sR3OHl IK7pbQtpPmZ8vcl9qWNSSPfLTxTVUmqfw1iYj0me7E+IPRBf6VGP50ZxpbVtEut+mslM Ahtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hbua7y/H/kIhEj94l0bHbgl13Qqxn3zRO4Ps5vnCErU=; b=KVmTsfvRvVRTKoV8Q47rHza7u6rBI0czkWi3SF7rFYV47eh2pPedgnqMQhre/In3+4 Be3Lc0D4hXsuZs8hBDTvWLjCr5oE9QJEo4r4huIiNFTsN5k3f0cIBSKAgnYDYhMnX7Dr jSYIKKS0lcOcDca3Ywht1zQHNN23LSrW6f0OqbaWBxZ7xs2442x6wZfEzhA1LoyAOsah J9/3fV/KT+q7rWuUR0YNynCMZR4JsHgxDDXSKZTE4T9iUBk1gDlKeCAS556gt5DYsVCG /owmu9NztHR0y2dMs0ELKrTNYJM5Wcx37X7sm1hyYlwRNa4laeSw7GBfoO4Re1pBOM0i X3Hg== ARC-Authentication-Results: i=1; mx.google.com; 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 u184si7166902pgc.699.2018.04.06.07.23.27; Fri, 06 Apr 2018 07:23:41 -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; 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 S932413AbeDFNiP (ORCPT + 99 others); Fri, 6 Apr 2018 09:38:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33254 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932384AbeDFNiM (ORCPT ); Fri, 6 Apr 2018 09:38:12 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1DBD9890; Fri, 6 Apr 2018 13:38:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+71655d44855ac3e76366@syzkaller.appspotmail.com, Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 4.14 24/67] RDMA/ucma: Check that device exists prior to accessing it Date: Fri, 6 Apr 2018 15:23:54 +0200 Message-Id: <20180406084344.595753875@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream. Ensure that device exists prior to accessing its properties. Reported-by: Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/ucma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1335,7 +1335,7 @@ static ssize_t ucma_notify(struct ucma_f { struct rdma_ucm_notify cmd; struct ucma_context *ctx; - int ret; + int ret = -EINVAL; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; @@ -1344,7 +1344,9 @@ static ssize_t ucma_notify(struct ucma_f if (IS_ERR(ctx)) return PTR_ERR(ctx); - ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event); + if (ctx->cm_id->device) + ret = rdma_notify(ctx->cm_id, (enum ib_event_type)cmd.event); + ucma_put_ctx(ctx); return ret; }