From nobody Tue Jun 21 09:34:08 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9538B87776A; Tue, 21 Jun 2022 09:34:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LS1YX6CFpz3Fpd; Tue, 21 Jun 2022 09:34:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655804049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YSWwOOe+iAuT2gtM67pH4bJiNodh2qLvdtdwcufGq84=; b=W38PEYpOCN7Xxg0F6iN1VNMXZXjfaDANGc9qMLyj5BgUoNfQUCDLOffH/ugY9yL+6ww619 NBZXKH4e3WFjzk4fnG9LS3fVyJTiAHXHaOaslds6p0w/asIjK+XbyLPA9OhkX8K+e3loeR v94UK/1P72A5C+uiyXgbah7N49KyNHBLd8tqHsP+sZOZNMEql5p44zqCT+ro/tKpKrfamC Dy5scJceUUARGHEG1MN4McWz2cAlpBh45e4tVXtcLKHpvAFoJjQ3TNviPPJaCbiS+ZYvLl frtCspKqgT1opzeqXPWp6qEVq6JmBVg57ixzNfapUaFwxhjuW/yrEvjwHr42/g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B2F7F707E; Tue, 21 Jun 2022 09:34:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25L9Y846090211; Tue, 21 Jun 2022 09:34:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25L9Y8Le090210; Tue, 21 Jun 2022 09:34:08 GMT (envelope-from git) Date: Tue, 21 Jun 2022 09:34:08 GMT Message-Id: <202206210934.25L9Y8Le090210@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 9fc6a635220f - main - ibcore: Fix a race with disassociate and exit_mmap() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fc6a635220fdd8a0a29de0a985a4a0c3a6890fd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655804049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YSWwOOe+iAuT2gtM67pH4bJiNodh2qLvdtdwcufGq84=; b=pxhkkERzjJYAPorixnej/KhGLONFqum7QiJnhkx12muFtGmfalAMeTy2AGHjLt0UwaNdvd KJsqmpXBbU952Iq/w7ZqtPf0zD6aUy8jsjTtlvuTn2wHfytvmxlFK1ct0K9zWAAmfthGdI IDKxug8v+OwwRaPb7TBmjCYf2TOIMPXXtr+4DZ+xBSsa4TJ2uo86t0UKXTtFfSymLZxkDO vhyErJw/m09NztNJyvzAIOwaiGQ8/207nEDUmGHCrDGWUbjji7g7NQzdHKAVeG/d06U7wq +7xkPoVZOZeA4ZsJp+uB5+4YugSbc1Mvi35akCEtBjTGGKu3fWiHQkZuoNlqwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655804049; a=rsa-sha256; cv=none; b=ygRCRXSQM8wwgx9kBMEGNGvCUmu8Cntbj+N6vHO1b1+BS0e7fHKn8ikr17hF8shwuUO+6O I93GUP6NzW9k+ZawBcVwRReQpYjMlLFWOVJXsskEmp7v88Iu2xgoBdcAZqWy6p+oiM2BhC W8ZGXX7Cd3XeWiuA4fCJZ41uRqMVqPe6Nowd5ezMUjzyb6AcrV8sA1vY6mVLQ/QjeVs0lz 5pJJr0VuJ9grnlTZxyshZy0SKGcmqE+DZz5Aw57i5RVgYWZLjN2NCd7oFaBeAMOesbeppS JbCzmS5VeDx7hnFzhr1LL4S++zgVnlM+gFU3e79Jung8GaOoLpdcrNx4gFeaoQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=9fc6a635220fdd8a0a29de0a985a4a0c3a6890fd commit 9fc6a635220fdd8a0a29de0a985a4a0c3a6890fd Author: Hans Petter Selasky AuthorDate: 2022-06-21 09:23:55 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-21 09:33:27 +0000 ibcore: Fix a race with disassociate and exit_mmap() If uverbs_user_mmap_disassociate() is called while the mmap is concurrently doing exit_mmap then the ordering of the rdma_user_mmap_entry_put() is not reliable. The put must be done before uvers_user_mmap_disassociate() returns, otherwise there can be a use after free on the ucontext, and a left over entry in the xarray. If the put is not done here then it is done during rdma_umap_close() later. Add the missing put to the error exit path. Linux commit: 39c011a538272589b9eb02ff1228af528522a22c PR: 264473 MFC after: 3 days Sponsored by: NVIDIA Networking --- sys/ofed/drivers/infiniband/core/ib_uverbs_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c index 1661458c689b..432d46760ecb 100644 --- a/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c +++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c @@ -778,6 +778,10 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile) ret = mmget_not_zero(mm); if (!ret) { list_del_init(&priv->list); + if (priv->entry) { + rdma_user_mmap_entry_put(priv->entry); + priv->entry = NULL; + } mm = NULL; continue; }