Received: by 10.213.65.68 with SMTP id h4csp716565imn; Fri, 6 Apr 2018 07:46:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx489gtCwbAQl19lR2vwHRO3D5slcPL+v/FFEcE8D+zYrXMexub/0BNwghEXg2Rlkjyi7j2Q+ X-Received: by 2002:a17:902:8c93:: with SMTP id t19-v6mr27533261plo.301.1523025961080; Fri, 06 Apr 2018 07:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025961; cv=none; d=google.com; s=arc-20160816; b=szMJYKXPUANH2RrY10MwjR5Bugk3Gtg+NptX4uUm4iHy+wJhLdjo2yqiLO6ud7NrRt l5U3OsUx7RgRU8aUevrEFK0mhCfZgCPWfoCmyPLPcIRt0dRMO/vGVhID4ZQ83UVhXZTG V1JC6VAuc/emw0U5w1MXh8on1W3AlwhAVnznBoqvEgOIF636/YkuZtT9lOR5O0b2lrQw 718rSuWRgqPSEpihFq+CMfHVpQAuCjpEuRDbdouXb08bNbNRJYogZNaYJ5mgwCU39FKr 5+Vs3XvMn1GqGrt6weuoOspTGwPc607g3qzzfE8fQQBAgySuJEq8bni2kG7CI0yRSEyM tzRw== 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=H+C8Azqyd7rrPUEQRzrjg8s5AIeJ9WFt0Jj8w5jk7nk=; b=OlICbA4Auu/TCaRY5sBs/RmGlwSySWMvtWMUgdGp0S5YICS7sNthify7r0mJlvwRZs 6P1GHD7Fixw8DQGNp7ntmqdllqY25gFA+FYbmjCYFlGUZsvwDmY2cu+yW/sSG6sUQsXL EysY1sBFl/lDGML9O2Ei0J5n3jRJcx1fVyGYNSLg9LnezwrKCGiEPnh3ZVZkI+57qDXM hgV/Q/rNU3X+rC7rsGNIXHaVQuldMs0NAPpSbCFRtjtzdD4uVZk10adipzE1C9UAsygz Sax/qi3VGFXGW1hoQEbXmNSz8smFUFZNOhTCTEnZxL+m71YJy4TLjCAJY/kv337z2YoS 7+Bg== 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 1si7107180pgf.512.2018.04.06.07.45.47; Fri, 06 Apr 2018 07:46:01 -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 S1755915AbeDFOoh (ORCPT + 99 others); Fri, 6 Apr 2018 10:44:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58176 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755755AbeDFNeG (ORCPT ); Fri, 6 Apr 2018 09:34:06 -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 0A777D0B; Fri, 6 Apr 2018 13:34:05 +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.9 040/102] RDMA/ucma: Check that device exists prior to accessing it Date: Fri, 6 Apr 2018 15:23:21 +0200 Message-Id: <20180406084337.314603101@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@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.9-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 @@ -1317,7 +1317,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; @@ -1326,7 +1326,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; }