From: Alexander Grund <theflamefire89@gmail.com>
To: stable@vger.kernel.org
Cc: Tianyue Ren <rentianyue@kylinos.cn>,
Alexander Grund <theflamefire89@gmail.com>
Subject: [PATCH 4.9 5/6] selinux: fix error initialization in inode_doinit_with_dentry()
Date: Sat, 30 Jul 2022 19:03:42 +0200 [thread overview]
Message-ID: <20220730170343.11477-6-theflamefire89@gmail.com> (raw)
In-Reply-To: <20220730170343.11477-1-theflamefire89@gmail.com>
From: Tianyue Ren <rentianyue@kylinos.cn>
commit 83370b31a915493231e5b9addc72e4bef69f8d31 upstream.
Mark the inode security label as invalid if we cannot find
a dentry so that we will retry later rather than marking it
initialized with the unlabeled SID.
Fixes: 9287aed2ad1f ("selinux: Convert isec->lock into a spinlock")
Signed-off-by: Tianyue Ren <rentianyue@kylinos.cn>
[PM: minor comment tweaks]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Alexander Grund <theflamefire89@gmail.com>
---
security/selinux/hooks.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d252890debf7..b9c7e089906c 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1450,7 +1450,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
* inode_doinit with a dentry, before these inodes could
* be used again by userspace.
*/
- goto out;
+ isec->initialized = LABEL_INVALID;
+ /*
+ * There is nothing useful to jump to the "out"
+ * label, except a needless spin lock/unlock
+ * cycle.
+ */
+ return 0;
}
len = INITCONTEXTLEN;
@@ -1558,8 +1564,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
* inode_doinit() with a dentry, before these inodes
* could be used again by userspace.
*/
- if (!dentry)
- goto out;
+ if (!dentry) {
+ isec->initialized = LABEL_INVALID;
+ /*
+ * There is nothing useful to jump to the "out"
+ * label, except a needless spin lock/unlock
+ * cycle.
+ */
+ return 0;
+ }
rc = selinux_genfs_get_sid(dentry, sclass,
sbsec->flags, &sid);
dput(dentry);
--
2.25.1
next prev parent reply other threads:[~2022-07-30 17:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 17:03 [PATCH 4.9 0/6] Convert isec->lock into a spinlock fixing deadlock on GFS2 Alexander Grund
2022-07-30 17:03 ` [PATCH 4.9 1/6] selinux: Minor cleanups Alexander Grund
2022-07-30 17:03 ` [PATCH 4.9 2/6] proc: Pass file mode to proc_pid_make_inode Alexander Grund
2022-07-30 17:03 ` [PATCH 4.9 3/6] selinux: Clean up initialization of isec->sclass Alexander Grund
2022-07-30 17:03 ` [PATCH 4.9 4/6] selinux: Convert isec->lock into a spinlock Alexander Grund
2022-07-30 17:03 ` Alexander Grund [this message]
2022-07-30 17:03 ` [PATCH 4.9 6/6] selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling Alexander Grund
2022-08-01 11:14 ` [PATCH 4.9 0/6] Convert isec->lock into a spinlock fixing deadlock on GFS2 Greg KH
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=20220730170343.11477-6-theflamefire89@gmail.com \
--to=theflamefire89@gmail.com \
--cc=rentianyue@kylinos.cn \
--cc=stable@vger.kernel.org \
/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