Received: by 10.213.65.68 with SMTP id h4csp646882imn; Fri, 6 Apr 2018 06:43:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ULH3hvq5ra2EXlGD5GTbaimLSKoNalseIms7bD7S7fW9fsv42JCPMcmzvy1i3+vzYX6GS X-Received: by 10.98.32.199 with SMTP id m68mr20578665pfj.218.1523022185275; Fri, 06 Apr 2018 06:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022185; cv=none; d=google.com; s=arc-20160816; b=QD1rbltU84slxy9MhXvs3kf1D/sFhuul7ubW4aCDOEiVc+zX5igMG2ydCZy7JOdd1p n2TFbiO6/nQAN5pfccxT5eTOo/Cr63pZmvVPadb4BtJmryp6513suiXOtaRzu3mXZ4gs hsVA0j9z1g0/REglbilou7pHxp30EIrTeLIMFy/In4/BiWsgDtzLOXhK4j/wMJieafb8 MWwHkpRZIYt5pMUwt5ShMuhJJ5yPWw7p285mBJ+/Oyj40tDFkFTunyC28TVoyhQSvDYx qwZ2ZyQg443mer8ldp7YtjmrTDeXstGQyF8JdfqipeJfqjPUpb7OyPD6i4C9FjcTExYd pijw== 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=tICcy8FVDQ9pr70MPM+Kii9BtT6chlh2ydJOwG0wAhI=; b=NB89loPDb+0UT0buqn6bYTIlZiSZI4HTdnIkvKlg7z8pvGgu9p19MXh3IUthSyqhvd XMizQhKnKf9bnnbBM/Z8FkNBZNjSo99BCO2+l9Ckw3Mtl6Znm0TFi83cBVrJVb4hoUND x+4K/ZMxYNW+qeFvcdwHJL7tY2WiBoayanUiYxXGA7db9fjgQwx1q5fh0FK0X1O+4bFo GQ52VwBtI+Pl9QzlwbmOOFI9tRikoOUyTNdadxLyPRHJAVUsF0+3mSKqk/GUmOjcf5vr zTLXt3NkIZfLANbhTz1Pedr2AjhMsZ4dSzPgaXrDsQ1o7AuLqbSBv8rlrMyOUk/Ji1/t BNjg== 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 r3-v6si7960539plb.666.2018.04.06.06.42.51; Fri, 06 Apr 2018 06:43:05 -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 S932915AbeDFNln (ORCPT + 99 others); Fri, 6 Apr 2018 09:41:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36352 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932904AbeDFNlf (ORCPT ); Fri, 6 Apr 2018 09:41:35 -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 07EBEDFC; Fri, 6 Apr 2018 13:41:34 +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.15 26/72] RDMA/ucma: Check that device exists prior to accessing it Date: Fri, 6 Apr 2018 15:24:01 +0200 Message-Id: <20180406084351.535492166@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084349.367583460@linuxfoundation.org> References: <20180406084349.367583460@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.15-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; }