2009-03-19 17:18:19

by Miloslav Trmac

[permalink] [raw]
Subject: [PATCH] Add SELinux context and TTY name to AUDIT_TTY records

From: Miloslav Trmač <[email protected]>

Add SELinux context information and TTY name (consistent with the
AUDIT_SYSCALL record) to AUDIT_TTY. An example record after applying
this patch:

type=TTY msg=audit(1237480806.220:22): tty pid=2601 uid=0 auid=500 ses=1
subj=unconfined_u:unconfined_r:unconfined_t:s0 major=136 minor=1 tty=pts1
comm="bash" data=6361740D

(line wrapped, new fields are "subj" and "tty".)

Signed-off-by: Miloslav Trmač <[email protected]>
---
drivers/char/tty_audit.c | 57 ++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 19 deletions(-)


Attachments:
audit-tty-more-fields.patch (4.54 kB)

2009-03-19 20:59:15

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH] Add SELinux context and TTY name to AUDIT_TTY records

On Thursday 19 March 2009 01:18:00 pm Miloslav Trmac wrote:
> From: Miloslav Trmač <[email protected]>
>
> Add SELinux context information and TTY name (consistent with the
> AUDIT_SYSCALL record) to AUDIT_TTY. An example record after applying
> this patch:
>
> type=TTY msg=audit(1237480806.220:22): tty pid=2601 uid=0 auid=500 ses=1
> subj=unconfined_u:unconfined_r:unconfined_t:s0 major=136 minor=1 tty=pts1
> comm="bash" data=6361740D
>
> (line wrapped, new fields are "subj" and "tty".)
>
> Signed-off-by: Miloslav Trmač <[email protected]>
> ---
> drivers/char/tty_audit.c | 57 ++++++++++++++++++++++++-------------
> 1 file changed, 38 insertions(+), 19 deletions(-)

Just a quick procedural comment, in the future you should include patches in
the body of the email; people will likely ignore your submission otherwise.

There are several audit experts which should review this code but two things
jumped out at me when glancing at your patch:

1. SELinux SIDs should not be recorded
2. From a SELinux/security point of view ttys are considered objects
and their labels/contexts should be recorded with "obj=" not "subj="

--
paul moore
linux @ hp

2009-03-20 08:53:47

by Miloslav Trmac

[permalink] [raw]
Subject: Re: [PATCH] Add SELinux context and TTY name to AUDIT_TTY records

Paul,
Thanks for your review.
----- "Paul Moore" <[email protected]> wrote:
> There are several audit experts which should review this code but two
> things
> jumped out at me when glancing at your patch:
>
> 1. SELinux SIDs should not be recorded
Almost all code that logs SELinux contexts in kernel/audit* does the same thing as this patch, falling back to a SID if it can't be converted to a string.

> 2. From a SELinux/security point of view ttys are considered objects
> and their labels/contexts should be recorded with "obj=" not
> "subj="
The patch logs the context of the process, not of the TTY.
Mirek

2009-03-20 13:51:41

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH] Add SELinux context and TTY name to AUDIT_TTY records

On Friday 20 March 2009 04:53:27 am Miloslav Trmac wrote:
> ----- "Paul Moore" <[email protected]> wrote:
> > There are several audit experts which should review this code but two
> > things jumped out at me when glancing at your patch:
> >
> > 1. SELinux SIDs should not be recorded
>
> Almost all code that logs SELinux contexts in kernel/audit* does the same
> thing as this patch, falling back to a SID if it can't be converted to a
> string.

Ungh, that's ugly and questionably useful (I suppose I know why this is done)
but if that convention then who am I to argue.

> > 2. From a SELinux/security point of view ttys are considered objects
> > and their labels/contexts should be recorded with "obj=" not
> > "subj="
>
> The patch logs the context of the process, not of the TTY.

Okay, that is what I get for just glancing at patches and not looking at them
closer :)

--
paul moore
linux @ hp