Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Stephen Smalley <stephen.smalley.work@gmail.com>
To: Daniel Burgener <dburgener@linux.microsoft.com>
Cc: SElinux list <selinux@vger.kernel.org>,
	Ondrej Mosnacek <omosnace@redhat.com>,
	Paul Moore <paul@paul-moore.com>,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v2 1/4] selinux: Create function for selinuxfs directory cleanup
Date: Wed, 12 Aug 2020 15:21:58 -0400	[thread overview]
Message-ID: <CAEjxPJ61+Dusa-i_uggdGDQ-3iGb7+JDJkbsC48DpKpx_gEJSA@mail.gmail.com> (raw)
In-Reply-To: <20200812191525.1120850-2-dburgener@linux.microsoft.com>

On Wed, Aug 12, 2020 at 3:15 PM Daniel Burgener
<dburgener@linux.microsoft.com> wrote:
>
> Separating the cleanup from the creation will simplify two things in
> future patches in this series.  First, the creation can be made generic,
> to create directories not tied to the selinux_fs_info structure.  Second,
> we will ultimately want to reorder creation and deletion so that the
> deletions aren't performed until the new directory structures have already
> been moved into place.
>
> Signed-off-by: Daniel Burgener <dburgener@linux.microsoft.com>
> ---
>  security/selinux/selinuxfs.c | 41 ++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
> index 131816878e50..fc914facb48f 100644
> --- a/security/selinux/selinuxfs.c
> +++ b/security/selinux/selinuxfs.c
> @@ -355,6 +355,9 @@ static int sel_make_classes(struct selinux_fs_info *fsi,
>  static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
>                         unsigned long *ino);
>
> +/* declaration for sel_remove_old_policy_nodes */
> +static void sel_remove_entries(struct dentry *de);
> +
>  static ssize_t sel_read_mls(struct file *filp, char __user *buf,
>                                 size_t count, loff_t *ppos)
>  {
> @@ -509,11 +512,35 @@ static const struct file_operations sel_policy_ops = {
>         .llseek         = generic_file_llseek,
>  };
>
> +static void sel_remove_old_policy_nodes(struct selinux_fs_info *fsi)
> +{
> +       u32 i;
> +
> +       /* bool_dir cleanup */
> +       for (i = 0; i < fsi->bool_num; i++)
> +               kfree(fsi->bool_pending_names[i]);
> +       kfree(fsi->bool_pending_names);
> +       kfree(fsi->bool_pending_values);
> +       fsi->bool_num = 0;
> +       fsi->bool_pending_names = NULL;
> +       fsi->bool_pending_values = NULL;
> +
> +       sel_remove_entries(fsi->bool_dir);
> +
> +       /* class_dir cleanup */
> +       sel_remove_entries(fsi->class_dir);
> +
> +       /* policycap_dir cleanup */
> +       sel_remove_entries(fsi->policycap_dir);

This one shouldn't have its entries removed anymore.

  reply	other threads:[~2020-08-12 19:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 19:15 [PATCH v2 0/4] Update SELinuxfs out of tree and then swapover Daniel Burgener
2020-08-12 19:15 ` [PATCH v2 1/4] selinux: Create function for selinuxfs directory cleanup Daniel Burgener
2020-08-12 19:21   ` Stephen Smalley [this message]
2020-08-13 14:04     ` Daniel Burgener
2020-08-12 19:15 ` [PATCH v2 2/4] selinux: Refactor selinuxfs directory populating functions Daniel Burgener
2020-08-12 19:15 ` [PATCH v2 3/4] selinux: Standardize string literal usage for selinuxfs directory names Daniel Burgener
2020-08-12 19:15 ` [PATCH v2 4/4] selinux: Create new booleans and class dirs out of tree Daniel Burgener
2020-08-13 16:25   ` Stephen Smalley
2020-08-18 13:49     ` Daniel Burgener
2020-08-18 13:55       ` Stephen Smalley
2020-08-19 19:58         ` Daniel Burgener

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=CAEjxPJ61+Dusa-i_uggdGDQ-3iGb7+JDJkbsC48DpKpx_gEJSA@mail.gmail.com \
    --to=stephen.smalley.work@gmail.com \
    --cc=dburgener@linux.microsoft.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH v2 1/4] selinux: Create function for selinuxfs directory cleanup' \
    /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

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).