Received: by 10.213.65.68 with SMTP id h4csp708828imn; Fri, 6 Apr 2018 07:38:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+KSPuRE/2JpOn3KeZMTFBR1L5es6YBqIkUZex3b50ny+WdbvFxSC/QTy3PCecQ5Cdl47Ql X-Received: by 10.98.72.74 with SMTP id v71mr20437342pfa.241.1523025484026; Fri, 06 Apr 2018 07:38:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025483; cv=none; d=google.com; s=arc-20160816; b=q9stRNfK8scyhwEoP8O7Iq6vaUANe4mJY0arhZGLjBRDryoI3jR+fQF2OQ6eZyybHv wwbhfmGD6FOEACYvcuRSQwSmy7TmsCNPrPsKpqOAjI75/a/55oaYxhkuWMyVgTRIbnEv g1p1+F8tOtCgz2oI5UOdAAjbZ5dNSBn14QDPlscoX1YO0PvSqGp7Co1HWV2tY1hrsz2R xp7Zd7zPTUKsSCvJgHuGBAdhfjxhCsdpcU16NuZeAKyJ/zzmSuOA541v299PfjZYFVps yRTjjFvwllQXREbY+B2WfO39+YSn0qYy4wKJzw/Kj32MWhkt8KhC/lu8PwmmdoX0hS7j PusA== 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=WdqFgtiBuzs0yJvg++lK3B3dh8pgcX/XmfX952L2ZWI=; b=UZnZbp2R5YRSekhSQDXxhZIlrdQx2iZBxHUOBg7x+xAOaluaN+B2nKqYPeABZuC+tR McyjdS1K5N3ElVKp8+LtJ4wIx8XGeBMZiOuhW/X6c6qrcZIRwcoTmElgjA3GD4BzjDyX cSufoGgvE9nonwhc+UJt/HdPS+CE69qkrsOWaZh+qP5EcMtxa+64xKYyysN0TxQuc94F wxwEi8d8Av6FjYOyh6VlPC4t6M8opaP79wn9W+60UhsnJDBNZoMuo64JoMDRgx1rfpx+ FkNoWMHwKD3oN6XjDuPMmlVtUnqu1WM17Qke7XMN8C3wgaD0ee/oBQ0l8gM+uNsqYsKs r9yg== 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 a1si8094433pfb.415.2018.04.06.07.37.49; Fri, 06 Apr 2018 07:38:03 -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 S1756092AbeDFOgs (ORCPT + 99 others); Fri, 6 Apr 2018 10:36:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58846 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754260AbeDFNf3 (ORCPT ); Fri, 6 Apr 2018 09:35:29 -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 4B3ACDC0; Fri, 6 Apr 2018 13:35:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+dcfd344365a56fbebd0f@syzkaller.appspotmail.com, Leon Romanovsky , Sean Hefty , Jason Gunthorpe Subject: [PATCH 4.9 037/102] RDMA/ucma: Fix use-after-free access in ucma_close Date: Fri, 6 Apr 2018 15:23:18 +0200 Message-Id: <20180406084336.901940201@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 ed65a4dc22083e73bac599ded6a262318cad7baf upstream. The error in ucma_create_id() left ctx in the list of contexts belong to ucma file descriptor. The attempt to close this file descriptor causes to use-after-free accesses while iterating over such list. Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Reported-by: Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -495,6 +495,9 @@ err1: mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); mutex_unlock(&mut); + mutex_lock(&file->mut); + list_del(&ctx->list); + mutex_unlock(&file->mut); kfree(ctx); return ret; }