diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2020-08-27 18:27:53 +0200 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2020-08-31 10:00:14 -0400 |
commit | 66ccd2560affc6e653ef7372ea36fb825743d186 (patch) | |
tree | 45914d8e221deb583c42bb24e84bc8f4eca0c51e /security/selinux/selinuxfs.c | |
parent | 9ff9abc4c6be27ff27b6df625501a46711730520 (diff) | |
download | lwn-66ccd2560affc6e653ef7372ea36fb825743d186.tar.gz lwn-66ccd2560affc6e653ef7372ea36fb825743d186.zip |
selinux: simplify away security_policydb_len()
Remove the security_policydb_len() calls from sel_open_policy() and
instead update the inode size from the size returned from
security_read_policy().
Since after this change security_policydb_len() is only called from
security_load_policy(), remove it entirely and just open-code it there.
Also, since security_load_policy() is always called with policy_mutex
held, make it dereference the policy pointer directly and drop the
unnecessary RCU locking.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r-- | security/selinux/selinuxfs.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 29567acdda21..45e9efa9bf5b 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -415,16 +415,16 @@ static int sel_open_policy(struct inode *inode, struct file *filp) if (!plm) goto err; - if (i_size_read(inode) != security_policydb_len(state)) { - inode_lock(inode); - i_size_write(inode, security_policydb_len(state)); - inode_unlock(inode); - } - rc = security_read_policy(state, &plm->data, &plm->len); if (rc) goto err; + if ((size_t)i_size_read(inode) != plm->len) { + inode_lock(inode); + i_size_write(inode, plm->len); + inode_unlock(inode); + } + fsi->policy_opened = 1; filp->private_data = plm; |