From: Ondrej Mosnacek <hidden> Date: 2021-02-24 21:58:18
Currently, the lockdown state is queried unconditionally, even though
its result is used only if the PERF_SAMPLE_REGS_INTR bit is set in
attr.sample_type. While that doesn't matter in case of the Lockdown LSM,
it causes trouble with the SELinux's lockdown hook implementation.
SELinux implements the locked_down hook with a check whether the current
task's type has the corresponding "lockdown" class permission
("integrity" or "confidentiality") allowed in the policy. This means
that calling the hook when the access control decision would be ignored
generates a bogus permission check and audit record.
Fix this by checking sample_type first and only calling the hook when
its result would be honored.
Fixes: b0c8fdc7fdb7 ("lockdown: Lock down perf when in confidentiality mode")
Signed-off-by: Ondrej Mosnacek <redacted>
---
kernel/events/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -11796,12 +11796,12 @@ SYSCALL_DEFINE5(perf_event_open,returnerr;}-err=security_locked_down(LOCKDOWN_PERF);-if(err&&(attr.sample_type&PERF_SAMPLE_REGS_INTR))-/* REGS_INTR can leak data, lockdown must prevent this */-returnerr;--err=0;+/* REGS_INTR can leak data, lockdown must prevent this */+if(attr.sample_type&PERF_SAMPLE_REGS_INTR){+err=security_locked_down(LOCKDOWN_PERF);+if(err)+returnerr;+}/**Incgroupmode,thepidargumentisusedtopassthefd
From: Paul Moore <paul@paul-moore.com> Date: 2021-03-16 13:54:15
On Wed, Feb 24, 2021 at 4:59 PM Ondrej Mosnacek [off-list ref] wrote:
Currently, the lockdown state is queried unconditionally, even though
its result is used only if the PERF_SAMPLE_REGS_INTR bit is set in
attr.sample_type. While that doesn't matter in case of the Lockdown LSM,
it causes trouble with the SELinux's lockdown hook implementation.
SELinux implements the locked_down hook with a check whether the current
task's type has the corresponding "lockdown" class permission
("integrity" or "confidentiality") allowed in the policy. This means
that calling the hook when the access control decision would be ignored
generates a bogus permission check and audit record.
Fix this by checking sample_type first and only calling the hook when
its result would be honored.
Fixes: b0c8fdc7fdb7 ("lockdown: Lock down perf when in confidentiality mode")
Signed-off-by: Ondrej Mosnacek <redacted>
---
kernel/events/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Perf/core folks, do you want to pull this in via your tree? If I
don't hear anything in the next day I'll pull this in via the
selinux/next tree.
Reviewed-by: Paul Moore <paul@paul-moore.com>
@@ -11796,12 +11796,12 @@ SYSCALL_DEFINE5(perf_event_open,returnerr;}-err=security_locked_down(LOCKDOWN_PERF);-if(err&&(attr.sample_type&PERF_SAMPLE_REGS_INTR))-/* REGS_INTR can leak data, lockdown must prevent this */-returnerr;--err=0;+/* REGS_INTR can leak data, lockdown must prevent this */+if(attr.sample_type&PERF_SAMPLE_REGS_INTR){+err=security_locked_down(LOCKDOWN_PERF);+if(err)+returnerr;+}/**Incgroupmode,thepidargumentisusedtopassthefd--
From: Peter Zijlstra <peterz@infradead.org> Date: 2021-03-16 14:31:43
On Tue, Mar 16, 2021 at 09:53:21AM -0400, Paul Moore wrote:
On Wed, Feb 24, 2021 at 4:59 PM Ondrej Mosnacek [off-list ref] wrote:
quoted
Currently, the lockdown state is queried unconditionally, even though
its result is used only if the PERF_SAMPLE_REGS_INTR bit is set in
attr.sample_type. While that doesn't matter in case of the Lockdown LSM,
it causes trouble with the SELinux's lockdown hook implementation.
SELinux implements the locked_down hook with a check whether the current
task's type has the corresponding "lockdown" class permission
("integrity" or "confidentiality") allowed in the policy. This means
that calling the hook when the access control decision would be ignored
generates a bogus permission check and audit record.
Fix this by checking sample_type first and only calling the hook when
its result would be honored.
Fixes: b0c8fdc7fdb7 ("lockdown: Lock down perf when in confidentiality mode")
Signed-off-by: Ondrej Mosnacek <redacted>
---
kernel/events/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Perf/core folks, do you want to pull this in via your tree? If I
don't hear anything in the next day I'll pull this in via the
selinux/next tree.
Reviewed-by: Paul Moore <paul@paul-moore.com>
Ah, fell in the cracks... I've no idea what Changelog is trying to tell
me. It is pure gibberish to me. But the patch seems harmless enough to me.
Let me queue it then.
From: Paul Moore <paul@paul-moore.com> Date: 2021-03-16 15:15:06
On Tue, Mar 16, 2021 at 10:30 AM Peter Zijlstra [off-list ref] wrote:
On Tue, Mar 16, 2021 at 09:53:21AM -0400, Paul Moore wrote:
quoted
On Wed, Feb 24, 2021 at 4:59 PM Ondrej Mosnacek [off-list ref] wrote:
quoted
Currently, the lockdown state is queried unconditionally, even though
its result is used only if the PERF_SAMPLE_REGS_INTR bit is set in
attr.sample_type. While that doesn't matter in case of the Lockdown LSM,
it causes trouble with the SELinux's lockdown hook implementation.
SELinux implements the locked_down hook with a check whether the current
task's type has the corresponding "lockdown" class permission
("integrity" or "confidentiality") allowed in the policy. This means
that calling the hook when the access control decision would be ignored
generates a bogus permission check and audit record.
Fix this by checking sample_type first and only calling the hook when
its result would be honored.
Fixes: b0c8fdc7fdb7 ("lockdown: Lock down perf when in confidentiality mode")
Signed-off-by: Ondrej Mosnacek <redacted>
---
kernel/events/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Perf/core folks, do you want to pull this in via your tree? If I
don't hear anything in the next day I'll pull this in via the
selinux/next tree.
Reviewed-by: Paul Moore <paul@paul-moore.com>
Ah, fell in the cracks... I've no idea what Changelog is trying to tell
me. It is pure gibberish to me. But the patch seems harmless enough to me.
Let me queue it then.