Commit 8b3e07ac authored by J. Bruce Fields's avatar J. Bruce Fields

svcrpc: fix rare race on unix_domain creation

Note that "new" here is not yet fully initialized; auth_domain_put
should be called only on auth_domains that have actually been added to
the hash.

Before this fix, two attempts to add the same domain at once could
cause the hlist_del in auth_domain_put to fail.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 5ece3caf
...@@ -38,6 +38,14 @@ struct unix_domain { ...@@ -38,6 +38,14 @@ struct unix_domain {
extern struct auth_ops svcauth_unix; extern struct auth_ops svcauth_unix;
static void svcauth_unix_domain_release(struct auth_domain *dom)
{
struct unix_domain *ud = container_of(dom, struct unix_domain, h);
kfree(dom->name);
kfree(ud);
}
struct auth_domain *unix_domain_find(char *name) struct auth_domain *unix_domain_find(char *name)
{ {
struct auth_domain *rv; struct auth_domain *rv;
...@@ -47,7 +55,7 @@ struct auth_domain *unix_domain_find(char *name) ...@@ -47,7 +55,7 @@ struct auth_domain *unix_domain_find(char *name)
while(1) { while(1) {
if (rv) { if (rv) {
if (new && rv != &new->h) if (new && rv != &new->h)
auth_domain_put(&new->h); svcauth_unix_domain_release(new);
if (rv->flavour != &svcauth_unix) { if (rv->flavour != &svcauth_unix) {
auth_domain_put(rv); auth_domain_put(rv);
...@@ -74,14 +82,6 @@ struct auth_domain *unix_domain_find(char *name) ...@@ -74,14 +82,6 @@ struct auth_domain *unix_domain_find(char *name)
} }
EXPORT_SYMBOL_GPL(unix_domain_find); EXPORT_SYMBOL_GPL(unix_domain_find);
static void svcauth_unix_domain_release(struct auth_domain *dom)
{
struct unix_domain *ud = container_of(dom, struct unix_domain, h);
kfree(dom->name);
kfree(ud);
}
/************************************************** /**************************************************
* cache for IP address to unix_domain * cache for IP address to unix_domain
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment