Skip to contentSkip to conversation

selinux: randomize layout of key structures

RFC PATCH In review Stephen Smalley 4 participants 10 messages Dec 13, 2019 – Dec 19, 2019 3 messages not in the archive SELinux security module

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 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.

---
I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

 security/selinux/include/objsec.h   | 2 +-
 security/selinux/include/security.h | 2 +-
 security/selinux/ss/policydb.h      | 2 +-
 security/selinux/ss/services.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
security/selinux/include/objsec.h +1 -1
index a4a86cbcfb0a..330b7b6d44e0 100644
@@ -35,7 +35,7 @@ struct task_security_struct {
 	u32 create_sid;		/* fscreate SID */
 	u32 keycreate_sid;	/* keycreate SID */
 	u32 sockcreate_sid;	/* fscreate SID */
-};
+} __randomize_layout;
 
 enum label_initialized {
 	LABEL_INVALID,		/* invalid or not initialized */
security/selinux/include/security.h +1 -1
index 49737087ad33..3ea406ad91b6 100644
@@ -110,7 +110,7 @@ struct selinux_state {
 	bool policycap[__POLICYDB_CAPABILITY_MAX];
 	struct selinux_avc *avc;
 	struct selinux_ss *ss;
-};
+} __randomize_layout;
 
 void selinux_ss_init(struct selinux_ss **ss);
 void selinux_avc_init(struct selinux_avc **avc);
security/selinux/ss/policydb.h +1 -1
index bc56b14e2216..98afe52a3d19 100644
@@ -307,7 +307,7 @@ struct policydb {
 
 	u16 process_class;
 	u32 process_trans_perms;
-};
+} __randomize_layout;;
 
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab *s);
security/selinux/ss/services.h +1 -1
index fc40640a9725..c5896f39e8f6 100644
@@ -31,7 +31,7 @@ struct selinux_ss {
 	struct selinux_map map;
 	struct page *status_page;
 	struct mutex status_lock;
-};
+} __randomize_layout;
 
 void services_compute_xperms_drivers(struct extended_perms *xperms,
 				struct avtab_node *node);
Signature · 1 line
2.23.0
#1 lore raw
Quoted 6 lines · Stephen Smalley

I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

There's currently a long-standing bug with the GCC plugin where the generated debug info is in declaration order, not build order (see:
[1]). So, to verify it, try looking at the generated machine code.

Planned Clang implementation of this feature does not have this bug.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?format=multiple&id=84052

Signature · 1 line
Dan Aloni
#2 lore raw
Quoted 11 lines · Dan Aloni
Quoted 6 lines · Stephen Smalley

I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

There's currently a long-standing bug with the GCC plugin where the generated debug info is in declaration order, not build order (see:
[1]). So, to verify it, try looking at the generated machine code.

Thanks for that clarification; I can see in the code that the struct layout has changed between the two kernel builds.

Quoted 4 lines

Planned Clang implementation of this feature does not have this bug.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?format=multiple&id=84052

maintainer
#3 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 8 lines · Dan Aloni
Quoted 6 lines · Stephen Smalley

I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

Quoted 6 lines
Quoted 3 lines

There's currently a long-standing bug with the GCC plugin where the generated debug info is in declaration order, not build order (see:
[1]). So, to verify it, try looking at the generated machine code.

Thanks for that clarification; I can see in the code that the struct layout has changed between the two kernel builds.

This likely falls under the category of stupid questions, but I'm assuming it passed the test suite w/o problems and the system generally ran as expected?

I've also heard some comments about performance concerns, have you done any testing? I'm guessing that isn't a major concern here because I don't recall any of the structs marked in this patch going through any optimizations, but I could be forgetting something (or missing a performance concern with RANDSTRUCT).

Signature · 2 lines
paul moore
www.paul-moore.com
#4 lore raw
Quoted 14 lines · Paul Moore
Quoted 13 lines · Stephen Smalley
Quoted 11 lines · Dan Aloni
Quoted 6 lines · Stephen Smalley

I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

There's currently a long-standing bug with the GCC plugin where the generated debug info is in declaration order, not build order (see:
[1]). So, to verify it, try looking at the generated machine code.

Quoted 6 lines
Quoted 2 lines

Thanks for that clarification; I can see in the code that the struct layout has changed between the two kernel builds.

This likely falls under the category of stupid questions, but I'm assuming it passed the test suite w/o problems and the system generally ran as expected?

Yes, it tested fine for me. It did require a full rebuild to ensure that the randomized struct layouts were being used consistently throughout, and requires a make mrproper or distclean to remove the random seed before rebuilding if you want to generate a new random seed.

Quoted 5 lines

I've also heard some comments about performance concerns, have you done any testing? I'm guessing that isn't a major concern here because I don't recall any of the structs marked in this patch going through any optimizations, but I could be forgetting something (or missing a performance concern with RANDSTRUCT).

I haven't done any specific performance testing, but it will only impact users who enable RANDSTRUCT, so it is entirely opt-in, and as you say, these structs have not been especially optimized in the first place.

I think these same structures (or at least significant subsets thereof) are good candidates for write-rare protections if those ever reach mainline. Haven't seen any progress there in a while.

maintainer
#5 lore raw
Quoted 33 lines · Stephen Smalley
Quoted 14 lines · Paul Moore
Quoted 13 lines · Stephen Smalley
Quoted 11 lines · Dan Aloni
Quoted 6 lines · Stephen Smalley

I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

There's currently a long-standing bug with the GCC plugin where the generated debug info is in declaration order, not build order (see:
[1]). So, to verify it, try looking at the generated machine code.

Quoted 6 lines
Quoted 2 lines

Thanks for that clarification; I can see in the code that the struct layout has changed between the two kernel builds.

This likely falls under the category of stupid questions, but I'm assuming it passed the test suite w/o problems and the system generally ran as expected?

Yes, it tested fine for me. It did require a full rebuild to ensure that the randomized struct layouts were being used consistently throughout, and requires a make mrproper or distclean to remove the random seed before rebuilding if you want to generate a new random seed.

Quoted 5 lines

I've also heard some comments about performance concerns, have you done any testing? I'm guessing that isn't a major concern here because I don't recall any of the structs marked in this patch going through any optimizations, but I could be forgetting something (or missing a performance concern with RANDSTRUCT).

Quoted 7 lines

I haven't done any specific performance testing, but it will only impact users who enable RANDSTRUCT, so it is entirely opt-in, and as you say, these structs have not been especially optimized in the first place.

I think these same structures (or at least significant subsets thereof) are good candidates for write-rare protections if those ever reach mainline. Haven't seen any progress there in a while.

Okay, thanks. I think it's worth getting this now, even if there is some question about how widely they will be used. At least they will be there and we can use this as a starting point.

Thanks for putting this patch together, but as a FYI, I did take the liberty to remove the double semi-colon during the merge ;)

Signature · 2 lines
paul moore
www.paul-moore.com
Reviewed-by on v1 1/1
#6 lore raw
In reply to Stephen Smalley
Quoted 9 lines · Stephen Smalley

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.

-Kees

Quoted 69 lines

---
I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of this change if enabled?

 security/selinux/include/objsec.h   | 2 +-
 security/selinux/include/security.h | 2 +-
 security/selinux/ss/policydb.h      | 2 +-
 security/selinux/ss/services.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
security/selinux/include/objsec.h +1 -1
index a4a86cbcfb0a..330b7b6d44e0 100644
@@ -35,7 +35,7 @@ struct task_security_struct {
 	u32 create_sid;		/* fscreate SID */
 	u32 keycreate_sid;	/* keycreate SID */
 	u32 sockcreate_sid;	/* fscreate SID */
-};
+} __randomize_layout;
 
 enum label_initialized {
 	LABEL_INVALID,		/* invalid or not initialized */
security/selinux/include/security.h +1 -1
index 49737087ad33..3ea406ad91b6 100644
@@ -110,7 +110,7 @@ struct selinux_state {
 	bool policycap[__POLICYDB_CAPABILITY_MAX];
 	struct selinux_avc *avc;
 	struct selinux_ss *ss;
-};
+} __randomize_layout;
 
 void selinux_ss_init(struct selinux_ss **ss);
 void selinux_avc_init(struct selinux_avc **avc);
security/selinux/ss/policydb.h +1 -1
index bc56b14e2216..98afe52a3d19 100644
@@ -307,7 +307,7 @@ struct policydb {
 
 	u16 process_class;
 	u32 process_trans_perms;
-};
+} __randomize_layout;;
 
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab *s);
security/selinux/ss/services.h +1 -1
index fc40640a9725..c5896f39e8f6 100644
@@ -31,7 +31,7 @@ struct selinux_ss {
 	struct selinux_map map;
 	struct page *status_page;
 	struct mutex status_lock;
-};
+} __randomize_layout;
 
 void services_compute_xperms_drivers(struct extended_perms *xperms,
 				struct avtab_node *node);
Signature · 1 line
2.23.0
Signature · 1 line
Kees Cook

A message that is not in the archive (sent off-list or not yet received): CAOSEQ1qFpLX5hTyNZ+QZuhunH3gr+KAB5PDgcoFjUcyNojEVMQ@mail.gmail.com

#8 lore raw
Quoted 8 lines · Wenhui Zhang

Hi, Sorry for bothering you again.

However I came into some *evm code* in LSM, which calculates HMAC for data structures.
It looks like HMAC could protect integrity of LSM data structures.

IMHO, __randomize_layout and evm might duplicate the work, any instructions on this please?

When does the EVM code perform the checking? I would assume these are complimentary features rather than duplicate.

-Kees

Quoted 106 lines · Kees Cook
Quoted 94 lines · Stephen Smalley
Quoted 9 lines

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.

-Kees

Quoted 6 lines

---
I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong?
Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits of

this

Review

Quoted 9 lines

change if enabled?

 security/selinux/include/objsec.h   | 2 +-
 security/selinux/include/security.h | 2 +-
 security/selinux/ss/policydb.h      | 2 +-
 security/selinux/ss/services.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/security/selinux/include/objsec.h

Review

Quoted 13 lines

index a4a86cbcfb0a..330b7b6d44e0 100644

security/selinux/include/objsec.h +1 -1
@@ -35,7 +35,7 @@ struct task_security_struct {
      u32 create_sid;         /* fscreate SID */
      u32 keycreate_sid;      /* keycreate SID */
      u32 sockcreate_sid;     /* fscreate SID */
-};
+} __randomize_layout;
 
 enum label_initialized {
      LABEL_INVALID,          /* invalid or not initialized */
(quoted diff) +0 -0

b/security/selinux/include/security.h

Review

Quoted 13 lines

index 49737087ad33..3ea406ad91b6 100644

security/selinux/include/security.h +1 -1
@@ -110,7 +110,7 @@ struct selinux_state {
      bool policycap[__POLICYDB_CAPABILITY_MAX];
      struct selinux_avc *avc;
      struct selinux_ss *ss;
-};
+} __randomize_layout;
 
 void selinux_ss_init(struct selinux_ss **ss);
 void selinux_avc_init(struct selinux_avc **avc);
(quoted diff) +0 -0

b/security/selinux/ss/policydb.h

Review

Quoted 13 lines

index bc56b14e2216..98afe52a3d19 100644

security/selinux/ss/policydb.h +1 -1
@@ -307,7 +307,7 @@ struct policydb {
 
      u16 process_class;
      u32 process_trans_perms;
-};
+} __randomize_layout;;
 
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab *s);
(quoted diff) +0 -0

b/security/selinux/ss/services.h

Quoted 13 lines

index fc40640a9725..c5896f39e8f6 100644

security/selinux/ss/services.h +1 -2
@@ -31,7 +31,7 @@ struct selinux_ss {
      struct selinux_map map;
      struct page *status_page;
      struct mutex status_lock;
-};
+} __randomize_layout;
 
 void services_compute_xperms_drivers(struct extended_perms *xperms,
                              struct avtab_node *node);
--
Quoted 2 lines

2.23.0

--
Kees Cook

Signature · 6 lines
V/R,

Wenhui Zhang

Email: [email protected]
           Telephone: 1-(703) 424 3193
Signature · 1 line
Kees Cook

A message that is not in the archive (sent off-list or not yet received): CAOSEQ1ow2XGQ4faoFekK9s3HfmfcvnVKZgGC6tPm0ChJ0F+-vw@mail.gmail.com

#10 lore raw
Quoted 6 lines · Wenhui Zhang

In my understanding, evm is called whenever a security related attribute is committed to VFS.
It is set as enabled by default.
(ref.
https://github.com/torvalds/linux/blob/8b68150883ca466a23e90902dd4113b22e692f04/security/integrity/evm/evm_main.c
)

Okay, so yes, complimentary. randstruct means attackers need use bugs to expose enough memory from the kernel to determine the order of structure members before they can manipulate them with a kernel bug.

-Kees

Quoted 141 lines · Kees Cook
Quoted 130 lines · Wenhui Zhang
Quoted 3 lines

Hi, Sorry for bothering you again.

However I came into some *evm code* in LSM, which calculates HMAC for

data

Quoted 4 lines

structures.
It looks like HMAC could protect integrity of LSM data structures.

IMHO, __randomize_layout and evm might duplicate the work, any

instructions

Quoted 1 line

on this please?

When does the EVM code perform the checking? I would assume these are complimentary features rather than duplicate.

-Kees

Quoted 17 lines · Kees Cook
Quoted 14 lines · Stephen Smalley
Quoted 9 lines

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.

Quoted 8 lines
Quoted 8 lines

-Kees

Quoted 6 lines

---
I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case. They do have different seeds. Am I doing something wrong? Also, does DEBUG_INFO_BTF effectively undermine/negate the benefits

of

Quoted 44 lines
Quoted 44 lines

this

Review

Quoted 9 lines

change if enabled?

 security/selinux/include/objsec.h   | 2 +-
 security/selinux/include/security.h | 2 +-
 security/selinux/ss/policydb.h      | 2 +-
 security/selinux/ss/services.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/security/selinux/include/objsec.h

Review

Quoted 13 lines

index a4a86cbcfb0a..330b7b6d44e0 100644

security/selinux/include/objsec.h +1 -1
@@ -35,7 +35,7 @@ struct task_security_struct {
      u32 create_sid;         /* fscreate SID */
      u32 keycreate_sid;      /* keycreate SID */
      u32 sockcreate_sid;     /* fscreate SID */
-};
+} __randomize_layout;
 
 enum label_initialized {
      LABEL_INVALID,          /* invalid or not initialized */
(quoted diff) +0 -0

b/security/selinux/include/security.h

Review

Quoted 13 lines

index 49737087ad33..3ea406ad91b6 100644

security/selinux/include/security.h +1 -1
@@ -110,7 +110,7 @@ struct selinux_state {
      bool policycap[__POLICYDB_CAPABILITY_MAX];
      struct selinux_avc *avc;
      struct selinux_ss *ss;
-};
+} __randomize_layout;
 
 void selinux_ss_init(struct selinux_ss **ss);
 void selinux_avc_init(struct selinux_avc **avc);
(quoted diff) +0 -0

b/security/selinux/ss/policydb.h

Quoted 5 lines

index bc56b14e2216..98afe52a3d19 100644

security/selinux/ss/policydb.h +0 -0
@@ -307,7 +307,7 @@ struct policydb {
 
Quoted 7 lines
Quoted 7 lines

security/selinux/ss/policydb.h struct policydb {

Quoted 7 lines
security/selinux/ss/policydb.h +1 -1
      u16 process_class;
      u32 process_trans_perms;
-};
+} __randomize_layout;;
 
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab

*s);

Quoted 23 lines
Quoted 12 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/security/selinux/ss/services.h

Quoted 10 lines

index fc40640a9725..c5896f39e8f6 100644

security/selinux/ss/services.h +1 -1
@@ -31,7 +31,7 @@ struct selinux_ss {
      struct selinux_map map;
      struct page *status_page;
      struct mutex status_lock;
-};
+} __randomize_layout;
 
Quoted 9 lines
Quoted 5 lines
security/selinux/ss/services.h +0 -1
 void services_compute_xperms_drivers(struct extended_perms *xperms,
                              struct avtab_node *node);
--

2.23.0

--
Kees Cook

Quoted 7 lines

--
V/R,

Wenhui Zhang

Email: [email protected]

           Telephone: 1-(703) 424 3193

--
Kees Cook

Signature · 6 lines
V/R,

Wenhui Zhang

Email: [email protected]
           Telephone: 1-(703) 424 3193
Signature · 1 line
Kees Cook

A message that is not in the archive (sent off-list or not yet received): CAOSEQ1quzmnB4700JdOob=DNgbF5ma2rt7O-ayZwWeWBjymcjw@mail.gmail.com

#12 lore raw
Quoted 11 lines · Wenhui Zhang

EVM protects while security attributes data in memory and disk. structrand protects security attributes data in memory.

It seem like EVM introduces higher overhead than trampoline based structrand in general.

So, if we know our disks are reliable, does it make sense if we add some ifdef options for disabling EVM please?

However this really depends on which one is faster, the trampoline function or the encryption hash function.

There is no trampoline. It's just a per-compile re-ordering of the structures. It makes attack that depend on knowing structure layouts less reliable. EVM does not check these at memory access times, so they are complimentary.

-Kees

Quoted 180 lines · Kees Cook
Quoted 168 lines · Wenhui Zhang
Quoted 1 line

In my understanding, evm is called whenever a security related attribute

is

Quoted 4 lines

committed to VFS.
It is set as enabled by default.
(ref.

https://github.com/torvalds/linux/blob/8b68150883ca466a23e90902dd4113b22e692f04/security/integrity/evm/evm_main.c

Quoted 1 line

)

Okay, so yes, complimentary. randstruct means attackers need use bugs to expose enough memory from the kernel to determine the order of structure members before they can manipulate them with a kernel bug.

-Kees

Quoted 23 lines · Kees Cook
Quoted 21 lines · Wenhui Zhang
Quoted 3 lines

Hi, Sorry for bothering you again.

However I came into some *evm code* in LSM, which calculates HMAC for

data

Quoted 4 lines

structures.
It looks like HMAC could protect integrity of LSM data structures.

IMHO, __randomize_layout and evm might duplicate the work, any

instructions

Quoted 1 line

on this please?

When does the EVM code perform the checking? I would assume these are complimentary features rather than duplicate.

-Kees

Quoted 3 lines

On Tue, Dec 17, 2019 at 6:50 PM Kees Cook <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Stephen Smalley
Quoted 6 lines

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,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and enable CONFIG_GCC_PLUGIN_RANDSTRUCT in the kernel

configuration.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

-Kees

Quoted 4 lines

---
I would have expected that two kernels built with the same config with this enabled would have yielded different struct layouts in pahole vmlinux output, but that doesn't appear to be the case.

They

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

do have different seeds. Am I doing something wrong? Also, does DEBUG_INFO_BTF effectively undermine/negate the

benefits

Quoted 65 lines
Quoted 65 lines

of

Quoted 44 lines
Quoted 44 lines

this

Review

Quoted 9 lines

change if enabled?

 security/selinux/include/objsec.h   | 2 +-
 security/selinux/include/security.h | 2 +-
 security/selinux/ss/policydb.h      | 2 +-
 security/selinux/ss/services.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/security/selinux/include/objsec.h

Review

Quoted 13 lines

index a4a86cbcfb0a..330b7b6d44e0 100644

security/selinux/include/objsec.h +1 -1
@@ -35,7 +35,7 @@ struct task_security_struct {
      u32 create_sid;         /* fscreate SID */
      u32 keycreate_sid;      /* keycreate SID */
      u32 sockcreate_sid;     /* fscreate SID */
-};
+} __randomize_layout;
 
 enum label_initialized {
      LABEL_INVALID,          /* invalid or not initialized */
(quoted diff) +0 -0

b/security/selinux/include/security.h

Review

Quoted 13 lines

index 49737087ad33..3ea406ad91b6 100644

security/selinux/include/security.h +1 -1
@@ -110,7 +110,7 @@ struct selinux_state {
      bool policycap[__POLICYDB_CAPABILITY_MAX];
      struct selinux_avc *avc;
      struct selinux_ss *ss;
-};
+} __randomize_layout;
 
 void selinux_ss_init(struct selinux_ss **ss);
 void selinux_avc_init(struct selinux_avc **avc);
(quoted diff) +0 -0

b/security/selinux/ss/policydb.h

Quoted 5 lines

index bc56b14e2216..98afe52a3d19 100644

security/selinux/ss/policydb.h +0 -0
@@ -307,7 +307,7 @@ struct policydb {
 
Quoted 7 lines
Quoted 7 lines

security/selinux/ss/policydb.h struct policydb { · line 313

Quoted 7 lines
security/selinux/ss/policydb.h +1 -1
      u16 process_class;
      u32 process_trans_perms;
-};
+} __randomize_layout;;
 
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab

*s);

Quoted 12 lines
Quoted 12 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/security/selinux/ss/services.h

Quoted 10 lines

index fc40640a9725..c5896f39e8f6 100644

security/selinux/ss/services.h +1 -1
@@ -31,7 +31,7 @@ struct selinux_ss {
      struct selinux_map map;
      struct page *status_page;
      struct mutex status_lock;
-};
+} __randomize_layout;
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

security/selinux/ss/services.h struct selinux_ss { · line 36

Quoted 1 line
security/selinux/ss/services.h +0 -0
 void services_compute_xperms_drivers(struct extended_perms

*xperms,

Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 4 lines
security/selinux/ss/services.h +0 -1
                              struct avtab_node *node);
--

2.23.0

--
Kees Cook

--
V/R,

Quoted 8 lines
Quoted 4 lines

Wenhui Zhang

Email: [email protected]

           Telephone: 1-(703) 424 3193

--
Kees Cook

Quoted 7 lines

--
V/R,

Wenhui Zhang

Email: [email protected]

           Telephone: 1-(703) 424 3193

--
Kees Cook

Signature · 6 lines
V/R,

Wenhui Zhang

Email: [email protected]
           Telephone: 1-(703) 424 3193
Signature · 1 line
Kees Cook