From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AIpwx490zl8esdOg9OPE6IvZQVJ34ApIgmAKOfAEYmMO8+ygpgS6g1DpRXQmWlnDdfAy3EqNU4pF ARC-Seal: i=1; a=rsa-sha256; t=1523021729; cv=none; d=google.com; s=arc-20160816; b=HSfhLhCJ1X6P/qyGy3ZLKb7WCZmE6g4j/1sBDl7sRGtx6qcPQQT6cj2a3aXQHWR4Iz 719XDrQdwQKP40YBbtxiawKL39pXaQpglUrPmXnzmvy8nMfMNCJITlPmbQj6cbIXhJCW l8lxr6IjzCHuuYkXf7x1HfbWD62IWaDLyiM9WP7Z++RCXYYbSN8FUWA0QwHhIbUVCsFD Xrvx4Jvt3ZXpJhMq3jkazn/FXmn8fciWETlVIaky4lQnkMWw5dUOOg3qD08MFFHMkpFZ 0YgtW3XgpW63mXYHJ47KxM0nSTOuVKaT4jWT7OUQjClytestgA/bXb8DARD8O8YXjXFU 1tAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WdqFgtiBuzs0yJvg++lK3B3dh8pgcX/XmfX952L2ZWI=; b=rbqKQpqs0ranN6yjdkdLSV6TQzkI2PKzIlDivQkY2BWVfVHY/a6IakI/XvnMQe8RpT GF3PcJVOGdwzMbuMZsp/N0eAw7ljOyS8QW4JKQCdc39fcG/3wpR/mRMgHiNeWkP8YyhQ yxuc/JBqHtAuFBftItJmV4GrHuLTM2vMimU+exUJB8bJv5str1zDbM/pEbzj2lQMjBoy BgXLhgSGRFHGLxzYE/o+lKglOf6kWLD7ewW48VxDTS+0d1yg6NGi/7QjHO3Q//8PMBnY UxhV0DBaj6yYqpcxuMFAT0WV5uD2yhQymZdTn/VRPGdGsgbaz5twH2drGx/Ne3EtMO7s VN4A== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.61.202 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.61.202 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1597003714922293729?= X-GMAIL-MSGID: =?utf-8?q?1597004032280083694?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; }