Received: by 10.213.65.68 with SMTP id h4csp694431imn; Fri, 6 Apr 2018 07:24:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+4wngAOSLDxZ4n/gNy2aEOEePKEMddMF01zaMiLAK1TBmTeypon0PzWi46Z8LxLSyqljvh X-Received: by 2002:a17:902:780d:: with SMTP id p13-v6mr27565344pll.281.1523024681935; Fri, 06 Apr 2018 07:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024681; cv=none; d=google.com; s=arc-20160816; b=wUMnyWACrFI9VlfduK9LAyL94tFSVq1hNNZaIaW2SYOdDF6aRzzMSPofCsUWF2bxij Dz5iqBrB1pTyReM2ntFO+/3wbij0lGLfmjVKioGhxg/a+yczKxUp9xlHvUGnrvSBni+k 5uwi3BRjSqBmQX/fNnrbalfqwLVZg4N3Mi32cSt3Xu31sYMJkTqd0prr5lzk9nNUDJuz kWtyDncHJa7J3XJsxqVVBZi04xmC3GmGUA/BzdreOF2RfPwH7kuccA4zxrHt37zA/SnS fpU1K3ykLPcV+sixKweQjv/vnQtKzcc7cCj5iTdHrnbbIhJyGnqh6c2QxNA5HBJSy9Ho KKcQ== 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=3K7Td3TbuRqEAyNu6OGnZTe9PbPKV6lVwGAKiHh3g9Y=; b=AlSTEZ1UhYwGwmkf+D+30lML90MBTxJKiX8VQS5dClD/o+KFwo/NyW96MvmmlE05Bo Mctvn1zCybghcBR1ju5jKdIaB6XYOp1yMC+J0BXJmEXqlQsDJ2Mz0dQLqcIYxfg+MsuJ 0+HB7iZTdj5fw66BFwY5NA/e81h6qX1SqrSmycIIg9dC0OTeopdsLyz62FEx3i8mwGZa 4RU+GyaK812nkX+GuV5LoLdvBpPEXYQ19NWTOqVdAdyDWq/3baBtTxm/xen8k2OVx1ub 8J7o7A2eOinze1rykHTWEpDwhQ+Uf4C0X+NulwT4RpkLBy1u7fJIcXYbE3/U7gMFFv6A S4wg== 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 p4si7018964pgv.545.2018.04.06.07.24.27; Fri, 06 Apr 2018 07:24: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 S1756700AbeDFOWH (ORCPT + 99 others); Fri, 6 Apr 2018 10:22:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33220 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932359AbeDFNh7 (ORCPT ); Fri, 6 Apr 2018 09:37:59 -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 DED04890; Fri, 6 Apr 2018 13:37:58 +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.14 20/67] RDMA/ucma: Fix use-after-free access in ucma_close Date: Fri, 6 Apr 2018 15:23:50 +0200 Message-Id: <20180406084344.041922579@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 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 @@ -497,6 +497,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; }