Skip to content

Commit 5c108d4

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: randomize layout of key structures
Randomize the layout of key selinux data structures. Initially this is applied to the selinux_state, selinux_ss, policydb, and task_security_struct data structures. NB To test/use this mechanism, one must install the necessary build-time dependencies, e.g. gcc-plugin-devel on Fedora, and enable CONFIG_GCC_PLUGIN_RANDSTRUCT in the kernel configuration. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Reviewed-by: Kees Cook <keescook@chromium.org> [PM: double semi-colon fixed] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 6c5a682 commit 5c108d4

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎security/selinux/include/objsec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct task_security_struct {
3535
u32 create_sid; /* fscreate SID */
3636
u32 keycreate_sid; /* keycreate SID */
3737
u32 sockcreate_sid; /* fscreate SID */
38-
};
38+
} __randomize_layout;
3939

4040
enum label_initialized {
4141
LABEL_INVALID, /* invalid or not initialized */

‎security/selinux/include/security.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct selinux_state {
110110
bool policycap[__POLICYDB_CAPABILITY_MAX];
111111
struct selinux_avc *avc;
112112
struct selinux_ss *ss;
113-
};
113+
} __randomize_layout;
114114

115115
void selinux_ss_init(struct selinux_ss **ss);
116116
void selinux_avc_init(struct selinux_avc **avc);

‎security/selinux/ss/policydb.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ struct policydb {
307307

308308
u16 process_class;
309309
u32 process_trans_perms;
310-
};
310+
} __randomize_layout;
311311

312312
extern void policydb_destroy(struct policydb *p);
313313
extern int policydb_load_isids(struct policydb *p, struct sidtab *s);

‎security/selinux/ss/services.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct selinux_ss {
3131
struct selinux_map map;
3232
struct page *status_page;
3333
struct mutex status_lock;
34-
};
34+
} __randomize_layout;
3535

3636
void services_compute_xperms_drivers(struct extended_perms *xperms,
3737
struct avtab_node *node);

0 commit comments

Comments
 (0)