selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Daniel Jurgens <danielj@mellanox.com>,
	Parav Pandit <parav@mellanox.com>,
	selinux@vger.kernel.org, paul@paul-moore.com, ddutile@redhat.com
Subject: [PATCH rdma-rc v1 1/4] IB/core: Unregister notifier before freeing MAD security
Date: Sat,  2 Feb 2019 11:09:42 +0200	[thread overview]
Message-ID: <20190202090945.4106-2-leon@kernel.org> (raw)
In-Reply-To: <20190202090945.4106-1-leon@kernel.org>

From: Daniel Jurgens <danielj@mellanox.com>

If the notifier runs after the security context is freed an access of
freed memory can occur.

Fixes: 47a2b338fe63 ("IB/core: Enforce security on management datagrams")
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/security.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c
index 1efadbccf394..402449d4a888 100644
--- a/drivers/infiniband/core/security.c
+++ b/drivers/infiniband/core/security.c
@@ -727,9 +727,10 @@ void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
 	if (!rdma_protocol_ib(agent->device, agent->port_num))
 		return;

-	security_ib_free_security(agent->security);
 	if (agent->lsm_nb_reg)
 		unregister_lsm_notifier(&agent->lsm_nb);
+
+	security_ib_free_security(agent->security);
 }

 int ib_mad_enforce_security(struct ib_mad_agent_private *map, u16 pkey_index)
--
2.19.1


  reply	other threads:[~2019-02-02  9:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-02  9:09 [PATCH rdma-rc v1 0/4] IB selinux related fixes Leon Romanovsky
2019-02-02  9:09 ` Leon Romanovsky [this message]
2019-02-02  9:09 ` [PATCH rdma-rc v1 2/4] IB/core: Fix potential memory leak while creating MAD agents Leon Romanovsky
2019-02-02  9:09 ` [PATCH rdma-rc v1 3/4] IB/core: Eliminate a hole in MAD agent struct Leon Romanovsky
2019-02-02  9:09 ` [PATCH rdma-rc v1 4/4] IB/core: Don't register each MAD agent for LSM notifier Leon Romanovsky
2019-02-06 21:52   ` Paul Moore
2019-02-08 23:49 ` [PATCH rdma-rc v1 0/4] IB selinux related fixes Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190202090945.4106-2-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=danielj@mellanox.com \
    --cc=ddutile@redhat.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@mellanox.com \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).