Received: by 10.213.65.68 with SMTP id h4csp736350imn; Fri, 6 Apr 2018 08:04:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4++WonTqymtO8wsJIEFYn6chvlhWykSL9POBBwz+BJytZ9cKTV5rXGpEyZR3NAX7fEU/KvR X-Received: by 2002:a17:902:51ce:: with SMTP id y72-v6mr27329434plh.157.1523027073085; Fri, 06 Apr 2018 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523027073; cv=none; d=google.com; s=arc-20160816; b=rPD+HCxQjkcUFyFvo25oASe3Uo8AVXYjGH7HBJuUVk8DfcOHKrD1JuVWoCAOd0tcs7 DyZ1MgeVCfYxcfWOoBdEI1zDIpYoknRPE/aqt6H4MArKf7EidSDqG2BvdbX8VWop82ik IuHg/dYxZOmr5f8hApYwc7QMd1egkPoHnwJMfsDZOMRg1UwWdTF5/6wJ7VjCeIhvjJXk WXs7GTEuGm/r28/5p6QoW8TWFovwfHGzaTpCGVKYf5XgFqbYtBuygcg2oh9PyK80YZJ+ lAtQQBjdvvfdZ8FzNhSCw3ez7lovewCmHnXuHyhwEY6mYiJKZRmEdD1pOLqk2P53sEFa 10lg== 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=MsCfwKWXEq2UcuuYYwiXU5+buWxafs+vr13Pc9sHoR8=; b=ICCgx6Q5vd192OyVQdcFb6rWnjvb/fC4ys5lqxClPGD4+cFUgZZfGqeRUElMCFLXNP 625c58hV3AZIfnCa22oI8EQlH1rQ9lvIcly62ZqvkYsBIVt0zl8olSUgkRfQe4mnEgdg PohuzYpXKv3WvUgTh68w2Z6Qnaysq232Fgcc4mW1afkdyULRAuMfO4xn8XilupaxLNoA 2/8TFi4tZbrB0dAojflAYWYL/CLHnNxI0yGbZcrBxArRvOglWHDeyqZkc9uxkjcJdCG8 O1lLMHuWyTyzsGY20YSbqZuJqvr0qF6ZZjBFAdKdovbFj23pQ83F7p7KBm6BtMFTcjeM R5Pw== 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 h7-v6si9949280pln.648.2018.04.06.08.04.18; Fri, 06 Apr 2018 08:04:33 -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 S1754930AbeDFNah (ORCPT + 99 others); Fri, 6 Apr 2018 09:30:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56168 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754911AbeDFNad (ORCPT ); Fri, 6 Apr 2018 09:30:33 -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 24186D48; Fri, 6 Apr 2018 13:30:32 +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.4 34/72] RDMA/ucma: Check that device exists prior to accessing it Date: Fri, 6 Apr 2018 15:23:35 +0200 Message-Id: <20180406084307.999654474@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084305.210085169@linuxfoundation.org> References: <20180406084305.210085169@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.4-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 @@ -1316,7 +1316,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; @@ -1325,7 +1325,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; }