* Re: [PATCH] selinux: add __randomize_layout to selinux_audit_data
2022-05-18 9:21 [PATCH] selinux: add __randomize_layout to selinux_audit_data GONG, Ruiqi
@ 2022-05-18 1:39 ` Paul Moore
2022-05-18 6:53 ` Gong Ruiqi
0 siblings, 1 reply; 5+ messages in thread
From: Paul Moore @ 2022-05-18 1:39 UTC (permalink / raw)
To: GONG, Ruiqi
Cc: Stephen Smalley, Eric Paris, Kees Cook, selinux, linux-kernel,
Wang Weiyang, Xiu Jianfeng
On Tue, May 17, 2022 at 9:21 PM GONG, Ruiqi <gongruiqi1@huawei.com> wrote:
>
> Randomize the layout of struct selinux_audit_data as suggested in [1],
> since it contains a pointer to struct selinux_state, an already
> randomized strucure.
>
> [1]: https://github.com/KSPP/linux/issues/188
>
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> ---
> security/selinux/include/avc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
> index 2b372f98f2d7..5525b94fd266 100644
> --- a/security/selinux/include/avc.h
> +++ b/security/selinux/include/avc.h
> @@ -53,7 +53,7 @@ struct selinux_audit_data {
> u32 denied;
> int result;
> struct selinux_state *state;
> -};
> +} __randomize_layout;
I'll apologize in advance for the stupid question, but does
__randomize_layout result in any problems when the struct is used in a
trace event? (see include/trace/events/avc.h)
--
paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selinux: add __randomize_layout to selinux_audit_data
2022-05-18 1:39 ` Paul Moore
@ 2022-05-18 6:53 ` Gong Ruiqi
2022-05-18 16:03 ` Paul Moore
0 siblings, 1 reply; 5+ messages in thread
From: Gong Ruiqi @ 2022-05-18 6:53 UTC (permalink / raw)
To: Paul Moore
Cc: Stephen Smalley, Eric Paris, Kees Cook, selinux, linux-kernel,
Wang Weiyang, Xiu Jianfeng
On 2022/05/18 9:39, Paul Moore wrote:
> On Tue, May 17, 2022 at 9:21 PM GONG, Ruiqi <gongruiqi1@huawei.com> wrote:
>>
>> Randomize the layout of struct selinux_audit_data as suggested in [1],
>> since it contains a pointer to struct selinux_state, an already
>> randomized strucure.
>>
>> [1]: https://github.com/KSPP/linux/issues/188
>>
>> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
>> ---
>> security/selinux/include/avc.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
>> index 2b372f98f2d7..5525b94fd266 100644
>> --- a/security/selinux/include/avc.h
>> +++ b/security/selinux/include/avc.h
>> @@ -53,7 +53,7 @@ struct selinux_audit_data {
>> u32 denied;
>> int result;
>> struct selinux_state *state;
>> -};
>> +} __randomize_layout;
>
> I'll apologize in advance for the stupid question, but does
Not at all :)
> __randomize_layout result in any problems when the struct is used in a
> trace event? (see include/trace/events/avc.h)
>
No, as least it doesn't in the testing I did. I believe we can use the
struct tagged with __randomize_layout as normal except that 1) it should
be initialized with a designated initializer, and 2) pointers to this
type can't be cast to/from pointers to another type. Other operations
like dereferencing members of the struct (as in
include/trace/events/avc.h) shouldn't be a problem.
I did a testing to the patch on a qemu vm by running the selinux
testsuite with tracing events "avc:selinux_audited" enabled. The
testsuite completed successfully and from the tracing log I saw nothing
abnormal with my bare eyes. You can do more testing if you want or you
have other ideas of how to do so ;)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] selinux: add __randomize_layout to selinux_audit_data
@ 2022-05-18 9:21 GONG, Ruiqi
2022-05-18 1:39 ` Paul Moore
0 siblings, 1 reply; 5+ messages in thread
From: GONG, Ruiqi @ 2022-05-18 9:21 UTC (permalink / raw)
To: Paul Moore, Stephen Smalley, Eric Paris, Kees Cook
Cc: selinux, linux-kernel, Wang Weiyang, Xiu Jianfeng, gongruiqi1
Randomize the layout of struct selinux_audit_data as suggested in [1],
since it contains a pointer to struct selinux_state, an already
randomized strucure.
[1]: https://github.com/KSPP/linux/issues/188
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
security/selinux/include/avc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
index 2b372f98f2d7..5525b94fd266 100644
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -53,7 +53,7 @@ struct selinux_audit_data {
u32 denied;
int result;
struct selinux_state *state;
-};
+} __randomize_layout;
/*
* AVC operations
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] selinux: add __randomize_layout to selinux_audit_data
2022-05-18 6:53 ` Gong Ruiqi
@ 2022-05-18 16:03 ` Paul Moore
2022-06-07 20:05 ` Paul Moore
0 siblings, 1 reply; 5+ messages in thread
From: Paul Moore @ 2022-05-18 16:03 UTC (permalink / raw)
To: Gong Ruiqi
Cc: Stephen Smalley, Eric Paris, Kees Cook, selinux, linux-kernel,
Wang Weiyang, Xiu Jianfeng
On Wed, May 18, 2022 at 2:53 AM Gong Ruiqi <gongruiqi1@huawei.com> wrote:
> On 2022/05/18 9:39, Paul Moore wrote:
> > On Tue, May 17, 2022 at 9:21 PM GONG, Ruiqi <gongruiqi1@huawei.com> wrote:
> >>
> >> Randomize the layout of struct selinux_audit_data as suggested in [1],
> >> since it contains a pointer to struct selinux_state, an already
> >> randomized strucure.
> >>
> >> [1]: https://github.com/KSPP/linux/issues/188
> >>
> >> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> >> ---
> >> security/selinux/include/avc.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
> >> index 2b372f98f2d7..5525b94fd266 100644
> >> --- a/security/selinux/include/avc.h
> >> +++ b/security/selinux/include/avc.h
> >> @@ -53,7 +53,7 @@ struct selinux_audit_data {
> >> u32 denied;
> >> int result;
> >> struct selinux_state *state;
> >> -};
> >> +} __randomize_layout;
> >
> > I'll apologize in advance for the stupid question, but does
>
> Not at all :)
>
> > __randomize_layout result in any problems when the struct is used in a
> > trace event? (see include/trace/events/avc.h)
>
> No, as least it doesn't in the testing I did. I believe we can use the
> struct tagged with __randomize_layout as normal except that 1) it should
> be initialized with a designated initializer, and 2) pointers to this
> type can't be cast to/from pointers to another type. Other operations
> like dereferencing members of the struct (as in
> include/trace/events/avc.h) shouldn't be a problem.
>
> I did a testing to the patch on a qemu vm by running the selinux
> testsuite with tracing events "avc:selinux_audited" enabled. The
> testsuite completed successfully and from the tracing log I saw nothing
> abnormal with my bare eyes. You can do more testing if you want or you
> have other ideas of how to do so ;)
That's great, thanks for verifying this. I was aware of the other
restrictions but wasn't sure about tracing. Now I know :)
It's too late to go into selinux/next for this dev cycle, but I'll
queue this up for selinux/next once the merge window closes.
Thanks again!
--
paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selinux: add __randomize_layout to selinux_audit_data
2022-05-18 16:03 ` Paul Moore
@ 2022-06-07 20:05 ` Paul Moore
0 siblings, 0 replies; 5+ messages in thread
From: Paul Moore @ 2022-06-07 20:05 UTC (permalink / raw)
To: Gong Ruiqi
Cc: Stephen Smalley, Eric Paris, Kees Cook, selinux, linux-kernel,
Wang Weiyang, Xiu Jianfeng
On Wed, May 18, 2022 at 12:03 PM Paul Moore <paul@paul-moore.com> wrote:
>
> On Wed, May 18, 2022 at 2:53 AM Gong Ruiqi <gongruiqi1@huawei.com> wrote:
> > On 2022/05/18 9:39, Paul Moore wrote:
> > > On Tue, May 17, 2022 at 9:21 PM GONG, Ruiqi <gongruiqi1@huawei.com> wrote:
> > >>
> > >> Randomize the layout of struct selinux_audit_data as suggested in [1],
> > >> since it contains a pointer to struct selinux_state, an already
> > >> randomized strucure.
> > >>
> > >> [1]: https://github.com/KSPP/linux/issues/188
> > >>
> > >> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> > >> ---
> > >> security/selinux/include/avc.h | 2 +-
> > >> 1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
> > >> index 2b372f98f2d7..5525b94fd266 100644
> > >> --- a/security/selinux/include/avc.h
> > >> +++ b/security/selinux/include/avc.h
> > >> @@ -53,7 +53,7 @@ struct selinux_audit_data {
> > >> u32 denied;
> > >> int result;
> > >> struct selinux_state *state;
> > >> -};
> > >> +} __randomize_layout;
> > >
> > > I'll apologize in advance for the stupid question, but does
> >
> > Not at all :)
> >
> > > __randomize_layout result in any problems when the struct is used in a
> > > trace event? (see include/trace/events/avc.h)
> >
> > No, as least it doesn't in the testing I did. I believe we can use the
> > struct tagged with __randomize_layout as normal except that 1) it should
> > be initialized with a designated initializer, and 2) pointers to this
> > type can't be cast to/from pointers to another type. Other operations
> > like dereferencing members of the struct (as in
> > include/trace/events/avc.h) shouldn't be a problem.
> >
> > I did a testing to the patch on a qemu vm by running the selinux
> > testsuite with tracing events "avc:selinux_audited" enabled. The
> > testsuite completed successfully and from the tracing log I saw nothing
> > abnormal with my bare eyes. You can do more testing if you want or you
> > have other ideas of how to do so ;)
>
> That's great, thanks for verifying this. I was aware of the other
> restrictions but wasn't sure about tracing. Now I know :)
>
> It's too late to go into selinux/next for this dev cycle, but I'll
> queue this up for selinux/next once the merge window closes.
I just merged this into my local selinux/next branch and I'll be
pushing it up to the mail selinux tree later today - thanks!
--
paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-08 0:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 9:21 [PATCH] selinux: add __randomize_layout to selinux_audit_data GONG, Ruiqi
2022-05-18 1:39 ` Paul Moore
2022-05-18 6:53 ` Gong Ruiqi
2022-05-18 16:03 ` Paul Moore
2022-06-07 20:05 ` Paul Moore
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.