Skip to content

Commit

Permalink
selinux: mark some global variables __ro_after_init
Browse files Browse the repository at this point in the history
All of these are never modified outside initcalls, so they can be
__ro_after_init.

Signed-off-by: Ondrej Mosnacek <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
WOnder93 authored and pcmoore committed Jan 12, 2021
1 parent db478cd commit cd2bb4c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ void avc_set_cache_threshold(struct selinux_avc *avc,
avc->avc_cache_threshold = cache_threshold;
}

static struct avc_callback_node *avc_callbacks;
static struct kmem_cache *avc_node_cachep;
static struct kmem_cache *avc_xperms_data_cachep;
static struct kmem_cache *avc_xperms_decision_cachep;
static struct kmem_cache *avc_xperms_cachep;
static struct avc_callback_node *avc_callbacks __ro_after_init;
static struct kmem_cache *avc_node_cachep __ro_after_init;
static struct kmem_cache *avc_xperms_data_cachep __ro_after_init;
static struct kmem_cache *avc_xperms_decision_cachep __ro_after_init;
static struct kmem_cache *avc_xperms_cachep __ro_after_init;

static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass)
{
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "security.h"

static struct sock *selnl;
static struct sock *selnl __ro_after_init;

static int selnl_msglen(int msgtype)
{
Expand Down
4 changes: 2 additions & 2 deletions security/selinux/selinuxfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2204,8 +2204,8 @@ static struct file_system_type sel_fs_type = {
.kill_sb = sel_kill_sb,
};

static struct vfsmount *selinuxfs_mount;
struct path selinux_null;
static struct vfsmount *selinuxfs_mount __ro_after_init;
struct path selinux_null __ro_after_init;

static int __init init_sel_fs(void)
{
Expand Down
4 changes: 2 additions & 2 deletions security/selinux/ss/avtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "avtab.h"
#include "policydb.h"

static struct kmem_cache *avtab_node_cachep;
static struct kmem_cache *avtab_xperms_cachep;
static struct kmem_cache *avtab_node_cachep __ro_after_init;
static struct kmem_cache *avtab_xperms_cachep __ro_after_init;

/* Based on MurmurHash3, written by Austin Appleby and placed in the
* public domain.
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/ss/ebitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#define BITS_PER_U64 (sizeof(u64) * 8)

static struct kmem_cache *ebitmap_node_cachep;
static struct kmem_cache *ebitmap_node_cachep __ro_after_init;

int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2)
{
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/ss/hashtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/errno.h>
#include "hashtab.h"

static struct kmem_cache *hashtab_node_cachep;
static struct kmem_cache *hashtab_node_cachep __ro_after_init;

/*
* Here we simply round the number of elements up to the nearest power of two.
Expand Down

0 comments on commit cd2bb4c

Please sign in to comment.