From: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
To: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
Kees Cook <keescook@chromium.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 09/11] smack: namespace groundwork
Date: Thu, 15 Oct 2015 14:53:22 +0200 [thread overview]
Message-ID: <1444913602.5661.9.camel@samsung.com> (raw)
In-Reply-To: <1444912906.5661.7.camel@samsung.com>
On czw, 2015-10-15 at 14:41 +0200, Lukasz Pawelczyk wrote:
> No, not a typo. A regular bug. Thanks for spotting it. Also sync
> mechanism before freeing was missing:
Hitfix, will be integrated with the next respin:
diff --git a/security/smack/smack.h b/security/smack/smack.h
index 3d432f4..3a795bf 100644
--- a/security/smack/smack.h
+++ b/security/smack/smack.h
@@ -97,6 +97,7 @@ struct smack_ns {
struct smack_known_ns {
struct list_head smk_list_known;
struct list_head smk_list_ns;
+ struct rcu_head smk_rcu;
struct user_namespace *smk_ns;
char *smk_mapped;
struct smack_known *smk_unmapped;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 8e0da67..234da71 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -4669,6 +4669,15 @@ static inline int smack_userns_create(struct user_namespace *ns)
return 0;
}
+static void smk_free_known_ns(struct rcu_head *head)
+{
+ struct smack_known_ns *sknp = container_of(head, struct smack_known_ns, smk_rcu);
+
+ if (sknp->smk_allocated)
+ kfree(sknp->smk_mapped);
+ kfree(sknp);
+}
+
static inline void smack_userns_free(struct user_namespace *ns)
{
struct smack_ns *snsp = ns->security;
@@ -4680,12 +4689,11 @@ static inline void smack_userns_free(struct user_namespace *ns)
mutex_lock(&skp->smk_mapped_lock);
list_del_rcu(&sknp->smk_list_known);
- if (sknp->smk_allocated)
- kfree(sknp->smk_mapped);
- kfree(sknp);
mutex_unlock(&skp->smk_mapped_lock);
list_del(&sknp->smk_list_ns);
+
+ call_rcu(&sknp->smk_rcu, smk_free_known_ns);
}
kfree(snsp);
--
--
Lukasz Pawelczyk
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2015-10-15 12:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <019801d1071b$2c124000$8436c000$@alibaba-inc.com>
2015-10-15 7:38 ` [PATCH v4 09/11] smack: namespace groundwork Hillf Danton
2015-10-15 12:41 ` Lukasz Pawelczyk
2015-10-15 12:53 ` Lukasz Pawelczyk [this message]
2015-10-16 3:04 ` Hillf Danton
2015-10-16 10:13 ` Lukasz Pawelczyk
2015-10-14 12:41 [PATCH v4 00/11] Smack namespace Lukasz Pawelczyk
2015-10-14 12:42 ` [PATCH v4 09/11] smack: namespace groundwork Lukasz Pawelczyk
2015-10-29 22:51 ` Casey Schaufler
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=1444913602.5661.9.camel@samsung.com \
--to=l.pawelczyk@samsung.com \
--cc=hillf.zj@alibaba-inc.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
/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