Received: by 10.213.65.68 with SMTP id h4csp663736imn; Fri, 6 Apr 2018 07:00:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49D+4+LFMBVkVlLbL5ZREX/kOelnsnnkzDukuZGIn8BBj2Khg1KQR5YOtsKsY/1yDTgV23O X-Received: by 2002:a17:902:bc45:: with SMTP id t5-v6mr27357457plz.343.1523023214461; Fri, 06 Apr 2018 07:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523023214; cv=none; d=google.com; s=arc-20160816; b=D+yWisIqvZSlELLo3ivCVC7fxWmFuTqpZFAbaIMKYrYBfyISmyQhMGmqSkBWDNfqnS z8zZBVRqrGobnZQQ+EnHK1laAPXmrS0JRMHT/xE2v5EPRPTwbBBKkDBEMFlhBjx6+vmj SpiVyI9L8ksMH9Uh/nEhnsEMzRFgyjY4eP8RTvUdZp9VIlY/YDQFMjgJtTr9qnJ4tXtd 8ASOghA4xTMBB98Pyq++d5Cc0OLFP5dLb0PbqmPyvn4GeMIocA3jMqkE+vbZe5cxg47N Ur8URzhDGfJpS+cTzj+xQa2qB/GnlWWvsPzP7FehNRSliYkz07hagmflSuaEQ60BvJYz NY9Q== 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=A7Za5o36EPILp1TBw6DNj+8lXz5oexTE4dV07vMncSs=; b=HIjpVTMKvoUNwAv80ZexFQokW7icEbYq+7hBjwSBTIZ5arkaNzdXUDc1Q6MQE50Zvg punm5jSf3YMzy+6pF3g8/fFM3QexGQQ8+p2wldoqhQFUcrl/r45XALGsXJ5jb6DrLGE8 9qFhMzNzzqoWv510NfTrqlFA6+XiiSXglNhgPBvvMtrHWAnTSc0DGNMdmXGUYZlaBvF3 3UTGoMF2IAC+nEJot5ABOs5whFuuSyayr0Iy1cJpJC5Cw15aw31TMP99+LTSxXCx92RO V+0GNUEweUrJQm7no5cJE/6trjDsBPcnBr65XJSplNtxuaMed/SVdbfeOPOpJcYJ0fzC D6IQ== 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 o6si7327353pgf.658.2018.04.06.07.00.00; Fri, 06 Apr 2018 07:00:14 -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 S932809AbeDFNnA (ORCPT + 99 others); Fri, 6 Apr 2018 09:43:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37168 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752692AbeDFNm5 (ORCPT ); Fri, 6 Apr 2018 09:42:57 -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 88EE9DB5; Fri, 6 Apr 2018 13:42:56 +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.15 22/72] RDMA/ucma: Fix use-after-free access in ucma_close Date: Fri, 6 Apr 2018 15:23:57 +0200 Message-Id: <20180406084351.232272204@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 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; }