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 2/4] IB/core: Fix potential memory leak while creating MAD agents
Date: Sat, 2 Feb 2019 11:09:43 +0200 [thread overview]
Message-ID: <20190202090945.4106-3-leon@kernel.org> (raw)
In-Reply-To: <20190202090945.4106-1-leon@kernel.org>
From: Daniel Jurgens <danielj@mellanox.com>
If the MAD agents isn't allowed to manage the subnet, or fails to
register for the LSM notifier, the security context is leaked. Free the
context in these cases.
Fixes: 47a2b338fe63 ("IB/core: Enforce security on management datagrams")
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reported-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/core/security.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c
index 402449d4a888..7662e9347238 100644
--- a/drivers/infiniband/core/security.c
+++ b/drivers/infiniband/core/security.c
@@ -710,16 +710,20 @@ int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
dev_name(&agent->device->dev),
agent->port_num);
if (ret)
- return ret;
+ goto free_security;
agent->lsm_nb.notifier_call = ib_mad_agent_security_change;
ret = register_lsm_notifier(&agent->lsm_nb);
if (ret)
- return ret;
+ goto free_security;
agent->smp_allowed = true;
agent->lsm_nb_reg = true;
return 0;
+
+free_security:
+ security_ib_free_security(agent->security);
+ return ret;
}
void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
--
2.19.1
next prev parent reply other threads:[~2019-02-02 9:10 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 ` [PATCH rdma-rc v1 1/4] IB/core: Unregister notifier before freeing MAD security Leon Romanovsky
2019-02-02 9:09 ` Leon Romanovsky [this message]
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-3-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).