All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Paul Moore <paul@paul-moore.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	Eric Paris <eparis@parisplace.org>,
	linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	selinux@vger.kernel.org
Subject: [PATCH 3/4] selinuxfs: free sb->s_fs_info after shutting down the super block
Date: Thu, 31 Aug 2023 07:31:56 +0200	[thread overview]
Message-ID: <20230831053157.256319-4-hch@lst.de> (raw)
In-Reply-To: <20230831053157.256319-1-hch@lst.de>

sb->s_fs_info can only be safely freed after generic_shutdown_super was
called and all access to the super_block has stopped.

Thus only free the private data after calling kill_litter_super, which
calls generic_shutdown_super internally.

Also remove the duplicate freeing in the sel_fill_super error path given
that ->kіll_sb is also called on ->fill_super failure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 security/selinux/selinuxfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 9dafb6ff110d26..8a8a532be8e767 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -2100,9 +2100,6 @@ static int sel_fill_super(struct super_block *sb, struct fs_context *fc)
 err:
 	pr_err("SELinux: %s:  failed while creating inodes\n",
 		__func__);
-
-	selinux_fs_info_free(sb);
-
 	return ret;
 }
 
@@ -2123,8 +2120,8 @@ static int sel_init_fs_context(struct fs_context *fc)
 
 static void sel_kill_sb(struct super_block *sb)
 {
-	selinux_fs_info_free(sb);
 	kill_litter_super(sb);
+	selinux_fs_info_free(sb);
 }
 
 static struct file_system_type sel_fs_type = {
-- 
2.39.2


  parent reply	other threads:[~2023-08-31  5:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31  5:31 sb->s_fs_info freeing fixes Christoph Hellwig
2023-08-31  5:31 ` [PATCH 1/4] ramfs: free sb->s_fs_info after shutting down the super block Christoph Hellwig
2023-08-31  6:25   ` Al Viro
2023-08-31  5:31 ` [PATCH 2/4] devpts: " Christoph Hellwig
2023-08-31  6:31   ` Al Viro
2023-08-31  5:31 ` Christoph Hellwig [this message]
2023-08-31  6:33   ` [PATCH 3/4] selinuxfs: " Al Viro
2023-08-31  5:31 ` [PATCH 4/4] hypfs: " Christoph Hellwig
2023-08-31  6:37   ` Al Viro
2023-08-31 10:20 ` sb->s_fs_info freeing fixes Christian Brauner
2023-08-31 10:29   ` Christian Brauner
2023-08-31 12:36     ` Christoph Hellwig
2023-08-31 13:11       ` Christian Brauner
2023-08-31 14:38         ` Paul Moore
2023-08-31 14:39           ` Christoph Hellwig
2023-08-31 14:49             ` Paul Moore

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=20230831053157.256319-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=agordeev@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=eparis@parisplace.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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.