All of lore.kernel.org
 help / color / mirror / Atom feed
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:41:46 +0200	[thread overview]
Message-ID: <1444912906.5661.7.camel@samsung.com> (raw)
In-Reply-To: <01a101d1071c$8ce631b0$a6b29510$@alibaba-inc.com>

On czw, 2015-10-15 at 15:38 +0800, Hillf Danton wrote:
> > 
> > +static inline void smack_userns_free(struct user_namespace *ns)
> > +{
> > +	struct smack_ns *snsp = ns->security;
> > +	struct smack_known *skp;
> > +	struct smack_known_ns *sknp, *n;
> > +
> > +	list_for_each_entry_safe(sknp, n, &snsp->smk_mapped,
> > smk_list_ns) {
> > +		skp = sknp->smk_unmapped;
> > +
> > +		mutex_lock(&skp->smk_mapped_lock);
> > +		list_del_rcu(&sknp->smk_list_known);
> > +		if (sknp->smk_allocated)
> > +			kfree(sknp->smk_mapped);
> > +		kfree(sknp);
> 
> sknp is released,
> > +		mutex_unlock(&skp->smk_mapped_lock);
> > +
> > +		list_del(&sknp->smk_list_ns);
> 
> but it is used again! typo?

No, not a typo. A regular bug. Thanks for spotting it. Also sync
mechanism before freeing was missing:

	skp = sknp->smk_unmapped;

	mutex_lock(&skp->smk_mapped_lock);
	list_del_rcu(&sknp->smk_list_known);
	mutex_unlock(&skp->smk_mapped_lock);

	list_del(&sknp->smk_list_ns);

	call_rcu(&sknp->smk_rcu, smk_free_known_ns);


-- 
Lukasz Pawelczyk
Samsung R&D Institute Poland
Samsung Electronics





  reply	other threads:[~2015-10-15 12:41 UTC|newest]

Thread overview: 11+ 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 [this message]
2015-10-15 12:53     ` Lukasz Pawelczyk
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
     [not found] ` <1444826525-9758-1-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-14 12:42   ` [PATCH v4 09/11] smack: namespace groundwork Lukasz Pawelczyk
2015-10-14 12:42     ` Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-10-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:51       ` Casey Schaufler
2015-10-29 22:51     ` Casey Schaufler
2015-10-29 22:51     ` Casey Schaufler
2015-10-14 12:42 ` Lukasz Pawelczyk

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=1444912906.5661.7.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.