* Re: euid missing
From: Chris Nandor @ 2016-07-13 16:51 UTC (permalink / raw)
To: Steve Grubb; +Cc: linux-audit
In-Reply-To: <4373501.sMjiJxmkID@x2>
[-- Attachment #1.1: Type: text/plain, Size: 1577 bytes --]
Ah, thanks. I had only recently added -k rootcmd so I didn't notice it was
different earlier ... but I should've noticed this time. Thanks!
On Wed, Jul 13, 2016 at 9:39 AM, Steve Grubb <sgrubb@redhat.com> wrote:
> On Wednesday, July 13, 2016 9:27:25 AM EDT Chris Nandor wrote:
> > As mentioned in previous e-mail, we want to log what users do as root. I
> > have these two rules, only:
> >
> > -a exit,always -F arch=b32 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
> > execve -k rootcmd
> > -a exit,always -F arch=b64 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
> > execve -k rootcmd
> >
> > But this line shows up:
> >
> > node=grax.sea.marchex.com type=ANOM_ABEND
> > msg=audit(1468426871.752:3282575): auid=811 uid=811 gid=811 ses=12
> > pid=18504 comm="chromium-browse" reason="seccomp" sig=0 syscall=91
> compat=0
> > ip=0x7f296c759c77 code=0x50001
>
> There are two kinds of events. There are the ones that are triggered by the
> rules you load, and there are rules that are hardwired to be logged because
> something significant happened. In this case the seccomp filter killed
> chromium-browse because it violated policy. It has nothing to do with your
> rules which have a rootcmd key.
>
> To find the events triggered by your rule, use:
> ausearch --start today -k rootcmd -i
>
> -Steve
>
> > My guess is that it is because euid is missing; maybe euid=0 is true if
> > euid is null? I could put uid=0, instead of euid ... but that isn't
> > exactly what I want, I think. Is there a way to have the rule require
> euid
> > actually be 0?
> >
> > --Chris
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 2279 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: Weird issues in 2.6.5
From: Steve Grubb @ 2016-07-13 16:42 UTC (permalink / raw)
To: linux-audit
In-Reply-To: <1592387.yc9HYPXd4B@x2>
On Wednesday, July 13, 2016 12:32:55 PM EDT Steve Grubb wrote:
> On Wednesday, July 13, 2016 9:22:57 AM EDT Chris Nandor wrote:
> > Secondary question: the reason for what I'm working on is that we want to
> > be able to audit what folks do as root on our production hosts. We're not
> > a bank, and a perfect solution is not required, but we do need to be able
> > to take reasonable steps to find out if people with access are doing bad
> > things.
> >
> > Is this setup reasonable for that purpose?
>
> Yes. You would want to do two things, first enable tty auditing. This is
> done by the pam_tty_audit module. Second consider adding the
> 32-power-abuse.rules to your rules.
>
> > I know that's a loaded question
> > and I can answer any questions anyone has that are necessary to figure
> > this
> > out. I am not asking so much about rules, but about architecture: logging
> > according to whatever rules we set up, to the local audit.log and
> > immediately to a remote using audisp-remote, so the log can't be easily
> > manipulated.
>
> Remote logging is the defence against local log manipulation.
Another thing to consider is that the 2.6 version of the audit user space has
a new logging format. You might consider going into auditd.conf and setting
log_format = enriched. This resolves some information locally before sending
it to the remote system.
-Steve
^ permalink raw reply
* Re: euid missing
From: Steve Grubb @ 2016-07-13 16:39 UTC (permalink / raw)
To: linux-audit
In-Reply-To: <CAHcE2wp8nCcqfeUMLd6pHuqWfKYbGFm67+w6S1DipoiO0Bf0pA@mail.gmail.com>
On Wednesday, July 13, 2016 9:27:25 AM EDT Chris Nandor wrote:
> As mentioned in previous e-mail, we want to log what users do as root. I
> have these two rules, only:
>
> -a exit,always -F arch=b32 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
> execve -k rootcmd
> -a exit,always -F arch=b64 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
> execve -k rootcmd
>
> But this line shows up:
>
> node=grax.sea.marchex.com type=ANOM_ABEND
> msg=audit(1468426871.752:3282575): auid=811 uid=811 gid=811 ses=12
> pid=18504 comm="chromium-browse" reason="seccomp" sig=0 syscall=91 compat=0
> ip=0x7f296c759c77 code=0x50001
There are two kinds of events. There are the ones that are triggered by the
rules you load, and there are rules that are hardwired to be logged because
something significant happened. In this case the seccomp filter killed
chromium-browse because it violated policy. It has nothing to do with your
rules which have a rootcmd key.
To find the events triggered by your rule, use:
ausearch --start today -k rootcmd -i
-Steve
> My guess is that it is because euid is missing; maybe euid=0 is true if
> euid is null? I could put uid=0, instead of euid ... but that isn't
> exactly what I want, I think. Is there a way to have the rule require euid
> actually be 0?
>
> --Chris
^ permalink raw reply
* Re: Weird issues in 2.6.5
From: Steve Grubb @ 2016-07-13 16:32 UTC (permalink / raw)
To: Chris Nandor; +Cc: linux-audit
In-Reply-To: <CAHcE2wryUe3E0LtMn2WijR9w_Wu0Mg2+TWeQbq2aUUPEKiTX-A@mail.gmail.com>
On Wednesday, July 13, 2016 9:22:57 AM EDT Chris Nandor wrote:
> Secondary question: the reason for what I'm working on is that we want to
> be able to audit what folks do as root on our production hosts. We're not
> a bank, and a perfect solution is not required, but we do need to be able
> to take reasonable steps to find out if people with access are doing bad
> things.
>
> Is this setup reasonable for that purpose?
Yes. You would want to do two things, first enable tty auditing. This is done
by the pam_tty_audit module. Second consider adding the 32-power-abuse.rules
to your rules.
> I know that's a loaded question
> and I can answer any questions anyone has that are necessary to figure this
> out. I am not asking so much about rules, but about architecture: logging
> according to whatever rules we set up, to the local audit.log and
> immediately to a remote using audisp-remote, so the log can't be easily
> manipulated.
Remote logging is the defence against local log manipulation.
-Steve
> On Wed, Jul 13, 2016 at 8:57 AM, Steve Grubb <sgrubb@redhat.com> wrote:
> > On Wednesday, July 13, 2016 8:47:58 AM EDT Chris Nandor wrote:
> > > Hi, I had some odd behavior to report.
> > >
> > > I am running ubuntu 12.04. Using the default auditd and audispd-plugins
> > > packages for my release, I was able to get logs sent to local syslog and
> >
> > to
> >
> > > a remote auditd server (same basic configuration), but the entries were
> > > being buffered somewhere (I think on the client side), and if the server
> > > died reconnections didn't happen.
> > >
> > > So, I wanted a more recent version, so I compiled audit-userspace from
> >
> > the
> >
> > > github src mirror,* trunk@1341.
> >
> > The github repo is a mirror of svn and is not always up to date. The issue
> > you
> > are seeing is fixed in the next commit after the mirror stops.
> >
> > https://fedorahosted.org/audit/changeset/1342
> >
> > if you want the lastest you can:
> >
> > svn co http://svn.fedorahosted.org/svn/audit/trunk
> >
> > and then generate from there. I am planning to release audit-2.6.5
> > tomorrow.
> > So, if anyone can test the current code, I'd really appreciate it. I'm
> > hoping
> > the next release settles down the audit code.
> >
> > > When I did, I got some weird results. For example, I expected got
> > >
> > > something like this in my audit.log:
> > > node=host.example.com type=CWD msg=audit(1468363871.644:3279856):
> > > cwd="/etc/audisp"
> > >
> > > And that was as expected. In syslog, I expected to get:
> > > Jul 13 08:34:53 host audispd: node=host.loc.example.com type=CWD
> > >
> > > msg=audit(1468363871.644:3279856): cwd="/etc/audisp"
> > >
> > > But instead, I got:
> > > Jul 13 08:34:53 host audispd: type=CWD msg=node=host.loc.example.com
> > >
> > > type=CWD msg=audit(1468363871.644
> > >
> > > As you can see, the whole thing was prepended with "type=CWD msg=", and
> >
> > the
> >
> > > line was truncated. Similarly, on the remote host, I got the same
thing:
> > > type=CWD msg=node=host.loc.example.com type=CWD
> >
> > msg=audit(1468363871.644
> >
> > > I noticed that the most recent version of the src for ubuntu was 2.4.5,
> >
> > so
> >
> > > I grabbed the src tarball from packages.ubuntu and built it, and now
> > > everything looks fine. The exact same line I see in my audit.log shows
> >
> > up
> >
> > > in the remote audit.log, with no buffering. When I restart the remote
> > > auditd server or client, it reconnects. syslog has same entry
> > > (prepended
> > > with the timestamp etc.). Everything seems happy now.
> > >
> > >
> > > *For some reason I had to define `CC_FOR_BUILD=gcc` in my shell when I
> >
> > ran
> >
> > > `make` from the svn/git src. I did not require this when building 2.4.5
> > > from the ubuntu src.
> >
> > I think that should have been detected during configure.
> >
> > -Steve
^ permalink raw reply
* euid missing
From: Chris Nandor @ 2016-07-13 16:27 UTC (permalink / raw)
To: linux-audit
[-- Attachment #1.1: Type: text/plain, Size: 765 bytes --]
As mentioned in previous e-mail, we want to log what users do as root. I
have these two rules, only:
-a exit,always -F arch=b32 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
execve -k rootcmd
-a exit,always -F arch=b64 -F euid=0 -F auid>=0 -F auid!=4294967295 -S
execve -k rootcmd
But this line shows up:
node=grax.sea.marchex.com type=ANOM_ABEND
msg=audit(1468426871.752:3282575): auid=811 uid=811 gid=811 ses=12
pid=18504 comm="chromium-browse" reason="seccomp" sig=0 syscall=91 compat=0
ip=0x7f296c759c77 code=0x50001
My guess is that it is because euid is missing; maybe euid=0 is true if
euid is null? I could put uid=0, instead of euid ... but that isn't
exactly what I want, I think. Is there a way to have the rule require euid
actually be 0?
--Chris
[-- Attachment #1.2: Type: text/html, Size: 1040 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: Weird issues in 2.6.5
From: Chris Nandor @ 2016-07-13 16:22 UTC (permalink / raw)
To: Steve Grubb; +Cc: linux-audit
In-Reply-To: <17910807.r7x1d9MGge@x2>
[-- Attachment #1.1: Type: text/plain, Size: 3429 bytes --]
Thanks, I'll try building with the actual latest in a bit.
Secondary question: the reason for what I'm working on is that we want to
be able to audit what folks do as root on our production hosts. We're not
a bank, and a perfect solution is not required, but we do need to be able
to take reasonable steps to find out if people with access are doing bad
things.
Is this setup reasonable for that purpose? I know that's a loaded question
and I can answer any questions anyone has that are necessary to figure this
out. I am not asking so much about rules, but about architecture: logging
according to whatever rules we set up, to the local audit.log and
immediately to a remote using audisp-remote, so the log can't be easily
manipulated.
On Wed, Jul 13, 2016 at 8:57 AM, Steve Grubb <sgrubb@redhat.com> wrote:
> On Wednesday, July 13, 2016 8:47:58 AM EDT Chris Nandor wrote:
> > Hi, I had some odd behavior to report.
> >
> > I am running ubuntu 12.04. Using the default auditd and audispd-plugins
> > packages for my release, I was able to get logs sent to local syslog and
> to
> > a remote auditd server (same basic configuration), but the entries were
> > being buffered somewhere (I think on the client side), and if the server
> > died reconnections didn't happen.
> >
> > So, I wanted a more recent version, so I compiled audit-userspace from
> the
> > github src mirror,* trunk@1341.
>
> The github repo is a mirror of svn and is not always up to date. The issue
> you
> are seeing is fixed in the next commit after the mirror stops.
>
> https://fedorahosted.org/audit/changeset/1342
>
> if you want the lastest you can:
>
> svn co http://svn.fedorahosted.org/svn/audit/trunk
>
> and then generate from there. I am planning to release audit-2.6.5
> tomorrow.
> So, if anyone can test the current code, I'd really appreciate it. I'm
> hoping
> the next release settles down the audit code.
>
>
> > When I did, I got some weird results. For example, I expected got
> > something like this in my audit.log:
> >
> > node=host.example.com type=CWD msg=audit(1468363871.644:3279856):
> > cwd="/etc/audisp"
> >
> > And that was as expected. In syslog, I expected to get:
> >
> > Jul 13 08:34:53 host audispd: node=host.loc.example.com type=CWD
> > msg=audit(1468363871.644:3279856): cwd="/etc/audisp"
> >
> > But instead, I got:
> >
> > Jul 13 08:34:53 host audispd: type=CWD msg=node=host.loc.example.com
> > type=CWD msg=audit(1468363871.644
> >
> > As you can see, the whole thing was prepended with "type=CWD msg=", and
> the
> > line was truncated. Similarly, on the remote host, I got the same thing:
> >
> > type=CWD msg=node=host.loc.example.com type=CWD
> msg=audit(1468363871.644
> >
> > I noticed that the most recent version of the src for ubuntu was 2.4.5,
> so
> > I grabbed the src tarball from packages.ubuntu and built it, and now
> > everything looks fine. The exact same line I see in my audit.log shows
> up
> > in the remote audit.log, with no buffering. When I restart the remote
> > auditd server or client, it reconnects. syslog has same entry (prepended
> > with the timestamp etc.). Everything seems happy now.
> >
> >
> > *For some reason I had to define `CC_FOR_BUILD=gcc` in my shell when I
> ran
> > `make` from the svn/git src. I did not require this when building 2.4.5
> > from the ubuntu src.
>
> I think that should have been detected during configure.
>
> -Steve
>
[-- Attachment #1.2: Type: text/html, Size: 4755 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: Weird issues in 2.6.5
From: Richard Guy Briggs @ 2016-07-13 16:20 UTC (permalink / raw)
To: Chris Nandor; +Cc: linux-audit
In-Reply-To: <CAHcE2wqW0c16dBbEuAJDBM0MZrow0eHLf6JdW_485gGvkbrQQg@mail.gmail.com>
On 2016-07-13 08:47, Chris Nandor wrote:
> *For some reason I had to define `CC_FOR_BUILD=gcc` in my shell when I ran
> `make` from the svn/git src. I did not require this when building 2.4.5
> from the ubuntu src.
Ok, so it isn't just me. I had a similar problem a couple of months ago
when building from current source on RHEL6.
> --Chris
- RGB
--
Richard Guy Briggs <rgb@redhat.com>
Kernel Security Engineering, Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635
^ permalink raw reply
* Re: Weird issues in 2.6.5
From: Steve Grubb @ 2016-07-13 15:57 UTC (permalink / raw)
To: linux-audit
In-Reply-To: <CAHcE2wqW0c16dBbEuAJDBM0MZrow0eHLf6JdW_485gGvkbrQQg@mail.gmail.com>
On Wednesday, July 13, 2016 8:47:58 AM EDT Chris Nandor wrote:
> Hi, I had some odd behavior to report.
>
> I am running ubuntu 12.04. Using the default auditd and audispd-plugins
> packages for my release, I was able to get logs sent to local syslog and to
> a remote auditd server (same basic configuration), but the entries were
> being buffered somewhere (I think on the client side), and if the server
> died reconnections didn't happen.
>
> So, I wanted a more recent version, so I compiled audit-userspace from the
> github src mirror,* trunk@1341.
The github repo is a mirror of svn and is not always up to date. The issue you
are seeing is fixed in the next commit after the mirror stops.
https://fedorahosted.org/audit/changeset/1342
if you want the lastest you can:
svn co http://svn.fedorahosted.org/svn/audit/trunk
and then generate from there. I am planning to release audit-2.6.5 tomorrow.
So, if anyone can test the current code, I'd really appreciate it. I'm hoping
the next release settles down the audit code.
> When I did, I got some weird results. For example, I expected got
> something like this in my audit.log:
>
> node=host.example.com type=CWD msg=audit(1468363871.644:3279856):
> cwd="/etc/audisp"
>
> And that was as expected. In syslog, I expected to get:
>
> Jul 13 08:34:53 host audispd: node=host.loc.example.com type=CWD
> msg=audit(1468363871.644:3279856): cwd="/etc/audisp"
>
> But instead, I got:
>
> Jul 13 08:34:53 host audispd: type=CWD msg=node=host.loc.example.com
> type=CWD msg=audit(1468363871.644
>
> As you can see, the whole thing was prepended with "type=CWD msg=", and the
> line was truncated. Similarly, on the remote host, I got the same thing:
>
> type=CWD msg=node=host.loc.example.com type=CWD msg=audit(1468363871.644
>
> I noticed that the most recent version of the src for ubuntu was 2.4.5, so
> I grabbed the src tarball from packages.ubuntu and built it, and now
> everything looks fine. The exact same line I see in my audit.log shows up
> in the remote audit.log, with no buffering. When I restart the remote
> auditd server or client, it reconnects. syslog has same entry (prepended
> with the timestamp etc.). Everything seems happy now.
>
>
> *For some reason I had to define `CC_FOR_BUILD=gcc` in my shell when I ran
> `make` from the svn/git src. I did not require this when building 2.4.5
> from the ubuntu src.
I think that should have been detected during configure.
-Steve
^ permalink raw reply
* Weird issues in 2.6.5
From: Chris Nandor @ 2016-07-13 15:47 UTC (permalink / raw)
To: linux-audit
[-- Attachment #1.1: Type: text/plain, Size: 1804 bytes --]
Hi, I had some odd behavior to report.
I am running ubuntu 12.04. Using the default auditd and audispd-plugins
packages for my release, I was able to get logs sent to local syslog and to
a remote auditd server (same basic configuration), but the entries were
being buffered somewhere (I think on the client side), and if the server
died reconnections didn't happen.
So, I wanted a more recent version, so I compiled audit-userspace from the
github src mirror,* trunk@1341.
When I did, I got some weird results. For example, I expected got
something like this in my audit.log:
node=host.example.com type=CWD msg=audit(1468363871.644:3279856):
cwd="/etc/audisp"
And that was as expected. In syslog, I expected to get:
Jul 13 08:34:53 host audispd: node=host.loc.example.com type=CWD
msg=audit(1468363871.644:3279856): cwd="/etc/audisp"
But instead, I got:
Jul 13 08:34:53 host audispd: type=CWD msg=node=host.loc.example.com
type=CWD msg=audit(1468363871.644
As you can see, the whole thing was prepended with "type=CWD msg=", and the
line was truncated. Similarly, on the remote host, I got the same thing:
type=CWD msg=node=host.loc.example.com type=CWD msg=audit(1468363871.644
I noticed that the most recent version of the src for ubuntu was 2.4.5, so
I grabbed the src tarball from packages.ubuntu and built it, and now
everything looks fine. The exact same line I see in my audit.log shows up
in the remote audit.log, with no buffering. When I restart the remote
auditd server or client, it reconnects. syslog has same entry (prepended
with the timestamp etc.). Everything seems happy now.
*For some reason I had to define `CC_FOR_BUILD=gcc` in my shell when I ran
`make` from the svn/git src. I did not require this when building 2.4.5
from the ubuntu src.
--Chris
[-- Attachment #1.2: Type: text/html, Size: 2449 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: Questions about the standard (Google Summer of Code Project)
From: Steve Grubb @ 2016-07-13 14:23 UTC (permalink / raw)
To: linux-audit; +Cc: Konrad Witaszczyk
In-Reply-To: <B946B6D5-FA5C-436A-AF7E-A5B50E3FAAE6@FreeBSD.org>
Hello,
On Wednesday, July 13, 2016 1:23:29 PM EDT Mateusz Piotrowski wrote:
> I participate in Google Summer of Code and my project involves converting
> Linux Audit logs to BSM logs.
>
> As I was writing a parser and converter I stumbled upon a couple of things I
> do not understand and I cannot find in the documentation:
The linux audit system has a library, libauparse, that encapsulates all the
quirks of the audit system so that writing applications like a translator is
easy. I would recommend using that as a starting point so that you don't have
to recreate it from scratch.
> 1. Where are all the elements like auditd start, user, etc. listed? I cannot
> find any document which specifies what can occurs between the colon
> (separating the type and the msg=audit(…) from the fields) and the record’s
> fields.
There really is none, Libauparse takes care of all of this so that you don't
have to. If you are wanting to do translation, you can feed the logs into
auparse and then just format the event the way you want.
That said, there is a big change coming soon which might make your project
easier. I'm planning to create a field classification extension to auparse that
will allow you to say, "give me the subject of this event", "give me the
action being performed", "give me the object", "give me the results". This
would probably make tranlators of all kinds easier to write.
> 2. Why are there two spaces between the colon and the first field in records
> of type=CWD and a field cwd=“/root”? Here’s an example:
>
> type=CWD msg=audit(1464013682.961:409): cwd="/root”
Human error? We use strtok_r to parse and it doesn't care.
> 3. According to Red Hat’s documentation[1]:
> > Each record consists of several name=value pairs separated by a white
> > space or a comma.
> a) Is a white space always a space?
Yes.
> Can be any white space like the tab character?
No.
> b) Why do some records are separated by a comma and a
> whitespace? Example:
>
> type=DAEMON_START msg=audit(1363713609.192:5426): auditd start,
> ver=2.2 format=raw kernel=2.6.32-358.2.1.el6.x86_64 auid=500 pid=4979
> subj=unconfined_u:system_r:auditd_t:s0 res=success
A long time ago the records were meant to be both human readable (don't laugh)
and machine consumable. Over time these have been converted name=value pairs.
Even the one you mention above has been fixed.
> I’ve posted the question on Unix & Linux SE: [3].
>
> 4. Is it possible that there are duplicate fields in a record?
Sometimes. I've tried to fix those when it happens. The problem is that not
everyone runs their audit code by this mail list so that we can check it to
see that its well formed. What I am planning to do is write an audit event
validation suite that checks that events are well formed and that expected
events are being written when they are supposed to and in the order that they
are supoosed to. Cleaning up these events is high on my TODO list.
> Something
> like (which doesn’t make much sense obviously):
>
> type=CWD msg=audit(1464013682.961:409): cwd="/root” cwd=“/usr”
Something like this will not happen, its more likely around auid and uid. The
reason being that the kernel adds somethings automatically because its a
trusted source of information. User space can write contradictory information.
For example if a daemon is working on behalf of a user but its auid has not
been set for the user, then you might see this.
> I’ve already asked a similar question on Unix & Linux SE: [4].
This mail list is where you will get the best answers.
> 5. Is there a document which answers my questions? That would be cool!
https://github.com/linux-audit/audit-documentation/wiki
-Steve
--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailman/listinfo/linux-audit
^ permalink raw reply
* Re: Upgrading audit package
From: Steve Grubb @ 2016-07-13 12:59 UTC (permalink / raw)
To: Bhagwat, Shriniketan Manjunath; +Cc: linux-audit@redhat.com
In-Reply-To: <AT5PR84MB014747BF10579EC4098CC733FA310@AT5PR84MB0147.NAMPRD84.PROD.OUTLOOK.COM>
Hello,
On Wednesday, July 13, 2016 5:38:38 AM EDT Bhagwat, Shriniketan Manjunath
wrote:
> As requested in my previous email, I am interested in understanding the
> relation between Linux audit kernel and user space audit. Will a audit
> kernel available with Linux kernel 2.6.32 compatible with user space audit
> 2.6.X? I understand you might be busy with your regular schedules. :-)
To some extent, yes they are compatible. How much? I don't know. I have never
tried that combination because they were never meant to run together.
-Steve
> From: Bhagwat, Shriniketan Manjunath
> Sent: Monday, July 11, 2016 1:48 PM
> To: 'Steve Grubb' <sgrubb@redhat.com>
> Cc: linux-audit@redhat.com
> Subject: Upgrading audit package
>
> Hi Steve,
>
> I am using audit in my development environment. My development environment
> is as below.
>
> RHEL 5.2 with kernel 2.6.32-431.el6.x86_64 and audit-2.2-2.el6.x86_64.
> SUSE 11 SP3 with kernel 3.0.76-0.11-default and audit-1.8-0.30.1
>
> As I understand the above audit packages I am using in my environment are
> user space audit. I want to upgrade it to the latest version. If I upgrade
> the audit packages to latest version 2.6.X will there be any issues? Linux
> Audit kernel available with kernel 2.6.32-431.el6.x86_64 and 3.0.76-0.11
> are compatible with user space audit 2.6.X? In your opinion what is the
> suitable audit package for my environment to upgrade? If these topics are
> already documented please guide me to the documentation.
>
> Regards,
> Ketan
^ permalink raw reply
* Questions about the standard (Google Summer of Code Project)
From: Mateusz Piotrowski @ 2016-07-13 11:23 UTC (permalink / raw)
To: linux-audit; +Cc: Konrad Witaszczyk
[-- Attachment #1.1: Type: text/plain, Size: 2549 bytes --]
Hi,
I participate in Google Summer of Code and my project involves converting Linux Audit logs to BSM logs.
As I was writing a parser and converter I stumbled upon a couple of things I do not understand and I cannot find in the documentation:
1. Where are all the elements like auditd start, user, etc. listed? I cannot find any document which specifies what can occurs between the colon (separating the type and the msg=audit(…) from the fields) and the record’s fields.
2. Why are there two spaces between the colon and the first field in records of type=CWD and a field cwd=“/root”? Here’s an example:
type=CWD msg=audit(1464013682.961:409): cwd="/root”
3. According to Red Hat’s documentation[1]:
> Each record consists of several name=value pairs separated by a white space or a comma.
a) Is a white space always a space? Can be any white space like the tab character?
b) Why do some records are separated by a comma and a whitespace? Example:
type=DAEMON_START msg=audit(1363713609.192:5426): auditd start, ver=2.2 format=raw kernel=2.6.32-358.2.1.el6.x86_64 auid=500 pid=4979 subj=unconfined_u:system_r:auditd_t:s0 res=success
I’ve posted the question on Unix & Linux SE: [3].
4. Is it possible that there are duplicate fields in a record? Something like (which doesn’t make much sense obviously):
type=CWD msg=audit(1464013682.961:409): cwd="/root” cwd=“/usr”
I’ve already asked a similar question on Unix & Linux SE: [4].
5. Is there a document which answers my questions? That would be cool!
Thanks a lot for help!
Cheers!
Matuesz Piotrowski
[GSoC project’s wiki]: https://wiki.freebsd.org/SummerOfCode2016/NonBSMtoBSMConversionTools <https://wiki.freebsd.org/SummerOfCode2016/NonBSMtoBSMConversionTools>
[1]: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Understanding_Audit_Log_Files.html <https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Understanding_Audit_Log_Files.html>
[3]: http://unix.stackexchange.com/questions/293975/undocumented-format-of-linux-audit-log-records <http://unix.stackexchange.com/questions/293975/undocumented-format-of-linux-audit-log-records>
[4]: http://unix.stackexchange.com/questions/293809/can-i-be-sure-that-the-name-of-a-linux-audit-records-field-is-unique <http://unix.stackexchange.com/questions/293809/can-i-be-sure-that-the-name-of-a-linux-audit-records-field-is-unique>
[-- Attachment #1.2: Type: text/html, Size: 4074 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Topi Miettinen @ 2016-07-13 7:30 UTC (permalink / raw)
To: Eric W. Biederman
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, pmladek-IBi9RG/b67k,
luto-DgEjT+Ai2ygdnm+yROfE0A, serge-A9i7LUbDfNHQT0dZR+AlfA,
keescook-F7+t8E8rja9g9hUCZPvPmw, Paul Moore, Eric Paris,
Tejun Heo, Li Zefan, Johannes Weiner,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <878tx79et8.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
On 07/12/16 13:16, Eric W. Biederman wrote:
> Topi Miettinen <toiwoton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> On 07/11/16 21:57, Eric W. Biederman wrote:
>>> Topi Miettinen <toiwoton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>>
>>>> There are many basic ways to control processes, including capabilities,
>>>> cgroups and resource limits. However, there are far fewer ways to find
>>>> out useful values for the limits, except blind trial and error.
>>>>
>>>> Currently, there is no way to know which capabilities are actually used.
>>>> Even the source code is only implicit, in-depth knowledge of each
>>>> capability must be used when analyzing a program to judge which
>>>> capabilities the program will exercise.
>>>>
>>>> Generate an audit message at system call exit, when capabilities are used.
>>>> This can then be used to configure capability sets for services by a
>>>> software developer, maintainer or system administrator.
>>>>
>>>> Test case demonstrating basic capability monitoring with the new
>>>> message types 1330 and 1331 and how the cgroups are displayed (boot to
>>>> rdshell):
>>>
>>> You totally miss the interactions with the user namespace so this won't
>>> give you the information you are aiming for.
>>
>> Please correct me if this is not right:
>>
>> There are two cases:
>> a) real capability use as seen outside the namespace
>> b) use of capabilities granted by the namespace
>> Both cases could be active independently.
>>
>> For auditing purposes, we're mostly interested in a) and log noise from
>> b) could be even seen a distraction.
>>
>> For configuration purposes, both cases can be interesting, a) for the
>> configuration of services and b) in case where the containerized
>> configuration is planned to be deployed outside. I'd still only log
>> a).
>>
>>
>> The same logic should apply with cgroup namespaces.
>
> Not logging capabilities outside of the initial user namespace is
> certainly the conservative place to start, and what selinux does.
>
> You should also be logging capability use from cap_capable. Not
But cap_capable is not called from apparmor aa_capable or selinux
selinux_capable, how about security_capable()?
> ns_capable. You are missing several kinds of capability use as
> a quick review of kernel/capability.c should have shown you.
Right, sorry about that.
-Topi
>
> Eric
>
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Topi Miettinen @ 2016-07-13 6:52 UTC (permalink / raw)
To: Tejun Heo
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ebiederm-aS9lmoZGLiVWk0Htik3J/w, pmladek-IBi9RG/b67k,
luto-DgEjT+Ai2ygdnm+yROfE0A, serge-A9i7LUbDfNHQT0dZR+AlfA,
keescook-F7+t8E8rja9g9hUCZPvPmw, Paul Moore, Eric Paris, Li Zefan,
Johannes Weiner, moderated list:AUDIT SUBSYSTEM,
open list:CONTROL GROUP (CGROUP), open list:CAPABILITIES
In-Reply-To: <20160712145936.GH3190-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
On 07/12/16 14:59, Tejun Heo wrote:
> On Mon, Jul 11, 2016 at 07:47:44PM +0000, Topi Miettinen wrote:
>> It's really critical to be able to associate a task in the logs to
>> cgroups which were valid that time. Or can we infer somehow what cgroups
>
> When is "that time"? Without logging all operations, this is
> meaningless.
>
>> a task was taking part, long time after task exit? Perhaps task cgroup
>> membership changes and changes in available cgroups should be logged too?
>>
>> Some kind of cgroup IDs could be logged instead of long paths. Then
>> these IDs should be reliably resolvable to paths offline somehow.
>
> I don't think that's doable. That pretty much requires the kernel to
> remember paths of all past cgroups.
That's a show stopper for audit approach for getting helpful information
for configuration. I'll try something different, probably cgroupstats.
-Topi
>
>> How usual migrations between cgroups are? Why would a task ever move
>> from (say) systemd/system.slice/smartd.service to anywhere else?
>
> In most cases, they won't move once set up initially but that's not
> the point of audit subsystem. Logging this once one exit isn't gonna
> help anything for auditing the system.
>
> Thanks.
>
^ permalink raw reply
* RE: Upgrading audit package
From: Bhagwat, Shriniketan Manjunath @ 2016-07-13 5:38 UTC (permalink / raw)
To: Steve Grubb; +Cc: linux-audit@redhat.com
[-- Attachment #1.1: Type: text/plain, Size: 1273 bytes --]
Hi Steve,
As requested in my previous email, I am interested in understanding the relation between Linux audit kernel and user space audit. Will a audit kernel available with Linux kernel 2.6.32 compatible with user space audit 2.6.X?
I understand you might be busy with your regular schedules. :-)
Regards,
Ketan
From: Bhagwat, Shriniketan Manjunath
Sent: Monday, July 11, 2016 1:48 PM
To: 'Steve Grubb' <sgrubb@redhat.com>
Cc: linux-audit@redhat.com
Subject: Upgrading audit package
Hi Steve,
I am using audit in my development environment. My development environment is as below.
RHEL 5.2 with kernel 2.6.32-431.el6.x86_64 and audit-2.2-2.el6.x86_64.
SUSE 11 SP3 with kernel 3.0.76-0.11-default and audit-1.8-0.30.1
As I understand the above audit packages I am using in my environment are user space audit. I want to upgrade it to the latest version.
If I upgrade the audit packages to latest version 2.6.X will there be any issues?
Linux Audit kernel available with kernel 2.6.32-431.el6.x86_64 and 3.0.76-0.11 are compatible with user space audit 2.6.X?
In your opinion what is the suitable audit package for my environment to upgrade?
If these topics are already documented please guide me to the documentation.
Regards,
Ketan
[-- Attachment #1.2: Type: text/html, Size: 4119 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Paul Moore @ 2016-07-12 22:00 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Topi Miettinen, linux-kernel, pmladek, luto, serge, keescook,
Eric Paris, Tejun Heo, Li Zefan, Johannes Weiner,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <878tx79et8.fsf@x220.int.ebiederm.org>
On Tue, Jul 12, 2016 at 9:16 AM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Not logging capabilities outside of the initial user namespace is
> certainly the conservative place to start, and what selinux does.
FYI, we added some basic userns capability smarts to SELinux in Linux 4.7.
commit 8e4ff6f228e4722cac74db716e308d1da33d744f
Author: Stephen Smalley <sds@tycho.nsa.gov>
Date: Fri Apr 8 13:52:00 2016 -0400
selinux: distinguish non-init user namespace capability checks
Distinguish capability checks against a target associated
with the init user namespace versus capability checks against
a target associated with a non-init user namespace by defining
and using separate security classes for the latter.
This is needed to support e.g. Chrome usage of user namespaces
for the Chrome sandbox without needing to allow Chrome to also
exercise capabilities on targets in the init user namespace.
Suggested-by: Dan Walsh <dwalsh@redhat.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
--
paul moore
www.paul-moore.com
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Paul Moore @ 2016-07-12 21:56 UTC (permalink / raw)
To: Topi Miettinen, moderated list:AUDIT SUBSYSTEM
Cc: linux-kernel, ebiederm, mladek, luto, serge, keescook, Eric Paris,
Tejun Heo, Li Zefan, Johannes Weiner, Serge Hallyn,
open list:CONTROL GROUP (CGROUP), open list:CAPABILITIES
In-Reply-To: <1468235672-3745-1-git-send-email-toiwoton@gmail.com>
On Mon, Jul 11, 2016 at 7:14 AM, Topi Miettinen <toiwoton@gmail.com> wrote:
> There are many basic ways to control processes, including capabilities,
> cgroups and resource limits. However, there are far fewer ways to find
> out useful values for the limits, except blind trial and error.
>
> Currently, there is no way to know which capabilities are actually used.
> Even the source code is only implicit, in-depth knowledge of each
> capability must be used when analyzing a program to judge which
> capabilities the program will exercise.
>
> Generate an audit message at system call exit, when capabilities are used.
> This can then be used to configure capability sets for services by a
> software developer, maintainer or system administrator.
>
> Test case demonstrating basic capability monitoring with the new
> message types 1330 and 1331 and how the cgroups are displayed (boot to
> rdshell):
NOTE: additional comments inline with the patch.
I can understand the desire to audit the capabilities, but I'm a
little uncertain about the value of auditing cgroups at this point in
time. The audit subsystem focuses primarily on security relevant
information, and while you could make an argument for cgroups here, I
think it is a relatively weak argument at the moment.
Also, please continue to work on reducing the impact of this on the
audit logs (your discussion with Serge).
> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index e38e3fc..971cb2e 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -438,6 +438,8 @@ static inline void audit_mmap_fd(int fd, int flags)
> __audit_mmap_fd(fd, flags);
> }
>
> +extern void audit_log_cap_use(int cap);
> +
> extern int audit_n_rules;
> extern int audit_signals;
> #else /* CONFIG_AUDITSYSCALL */
> @@ -545,6 +547,8 @@ static inline void audit_mmap_fd(int fd, int flags)
> { }
> static inline void audit_ptrace(struct task_struct *t)
> { }
> +static inline void audit_log_cap_use(int cap)
> +{ }
> #define audit_n_rules 0
> #define audit_signals 0
> #endif /* CONFIG_AUDITSYSCALL */
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index a20320c..b5dc8aa 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -100,6 +100,8 @@ char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
> int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
> int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
> struct pid *pid, struct task_struct *tsk);
> +struct audit_buffer;
> +void audit_cgroup_list(struct audit_buffer *ab);
>
> void cgroup_fork(struct task_struct *p);
> extern int cgroup_can_fork(struct task_struct *p);
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index d820aa9..c1ae016 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -111,6 +111,8 @@
> #define AUDIT_PROCTITLE 1327 /* Proctitle emit event */
> #define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
> #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */
> +#define AUDIT_CAPABILITY 1330 /* Record showing capability use */
> +#define AUDIT_CGROUP 1331 /* Record showing cgroups */
As Tejun Heo already stated, please put the capability changes and the
cgroup changes into two separate patches in one patchset.
> #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
> #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 8d528f9..98dd920 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -54,6 +54,7 @@
> #include <linux/kthread.h>
> #include <linux/kernel.h>
> #include <linux/syscalls.h>
> +#include <linux/cgroup.h>
>
> #include <linux/audit.h>
>
> @@ -1682,7 +1683,7 @@ void audit_log_cap(struct audit_buffer *ab, char *prefix, kernel_cap_t *cap)
> {
> int i;
>
> - audit_log_format(ab, " %s=", prefix);
> + audit_log_format(ab, "%s=", prefix);
Why?
> CAP_FOR_EACH_U32(i) {
> audit_log_format(ab, "%08x",
> cap->cap[CAP_LAST_U32 - i]);
> @@ -1696,11 +1697,11 @@ static void audit_log_fcaps(struct audit_buffer *ab, struct audit_names *name)
> int log = 0;
>
> if (!cap_isclear(*perm)) {
> - audit_log_cap(ab, "cap_fp", perm);
> + audit_log_cap(ab, " cap_fp", perm);
This is not an improvement, please stick with the leading space in
audit_log_cap() so callers do not have to worry about formatting
issues like this.
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 2672d10..32c3813 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1439,6 +1439,18 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>
> audit_log_proctitle(tsk, context);
>
> + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CAPABILITY);
> + if (ab) {
> + audit_log_cap(ab, "cap_used", &context->cap_used);
> + audit_log_end(ab);
> + }
> + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CGROUP);
> + if (ab) {
> + audit_log_format(ab, "cgroups=");
> + audit_cgroup_list(ab);
Why not just move the "cgroups=" into audit_cgroup_list()? Can you
ever think of a reason why you would need to record the cgroups
without the "cgroup=" field prefix?
> + audit_log_end(ab);
> + }
> +
> /* Send end of event record to help user space know we are finished */
> ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
> if (ab)
> @@ -2428,3 +2440,17 @@ struct list_head *audit_killed_trees(void)
> return NULL;
> return &ctx->killed_trees;
> }
> +
> +void audit_log_cap_use(int cap)
> +{
> + struct audit_context *context = current->audit_context;
> +
> + if (context) {
> + cap_raise(context->cap_used, cap);
> + audit_set_auditable(context);
> + } else {
> + audit_log(NULL, GFP_NOFS, AUDIT_CAPABILITY,
> + "cap_used=%d pid=%d no audit_context",
> + cap, task_pid_nr(current));
> + }
> +}
You can't log "no audit_context" in the audit record, all information
logged should follow the "<field>=<value>" format.
--
paul moore
www.paul-moore.com
^ permalink raw reply
* Re: Trivial patches
From: Steve Grubb @ 2016-07-12 16:31 UTC (permalink / raw)
To: linux-audit
In-Reply-To: <d9f987bb-ba5f-3626-0b5f-4787412124be@debian.org>
Hello,
On Tuesday, July 12, 2016 5:15:01 PM EDT Laurent Bigonville wrote:
> Could you please merge the following patches that have been proposed to
> debian by Nicolas Braud-Santoni?
Yes, thanks.
> The patches add the Documentation key in the .service file and also fix
> some typos.
They are now applied. If anyone has any other bug fixes, please send them.
There will be a 2.6.5 release later this week that fixes events in the old
format that get passed to plugins such as selinux troubleshooter. This is
commit 1342 in case anyone needs it today.
-Steve
^ permalink raw reply
* Trivial patches
From: Laurent Bigonville @ 2016-07-12 15:15 UTC (permalink / raw)
To: linux-audit
[-- Attachment #1: Type: text/plain, Size: 227 bytes --]
Hi,
Could you please merge the following patches that have been proposed to
debian by Nicolas Braud-Santoni?
The patches add the Documentation key in the .service file and also fix
some typos.
Cheers,
Laurent Bigonville
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-Fix-typos-in-manpages-and-messages.patch --]
[-- Type: text/x-patch; name="02-Fix-typos-in-manpages-and-messages.patch", Size: 4672 bytes --]
From: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
Date: Tue, 28 Jun 2016 22:59:59 +0200
Subject: Fix typos in manpages and messages
---
bindings/python/auparse_python.c | 6 +++---
docs/auditd.conf.5 | 2 +-
docs/auparse_find_field.3 | 2 +-
docs/auparse_find_field_next.3 | 4 ++--
tools/auvirt/auvirt.8 | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/bindings/python/auparse_python.c b/bindings/python/auparse_python.c
index 6ec22c9..37d99be 100644
--- a/bindings/python/auparse_python.c
+++ b/bindings/python/auparse_python.c
@@ -1383,7 +1383,7 @@ PyDoc_STRVAR(find_field_doc,
"find_field(name) Search for field name.\n\
\n\
find_field() will scan all records in an event to find the first\n\
-occurance of the field name passed to it. Searching begins from the\n\
+occurence of the field name passed to it. Searching begins from the\n\
cursor’s current position. The field name is stored for subsequent\n\
searching.\n\
\n\
@@ -1413,9 +1413,9 @@ const char *auparse_find_field_next(auparse_state_t *au);
* auparse_find_field_next
********************************/
PyDoc_STRVAR(find_field_next_doc,
-"find_field_next() Get next occurrance of field name\n\
+"find_field_next() Get next occurrence of field name\n\
\n\
-find_field_next() returns the value associated next occurrance of field name.\n\
+find_field_next() returns the value associated next occurrence of field name.\n\
Returns value associated with field or None if there is no next field.\n\
Raises exception (EnvironmentError) on error.\n\
");
diff --git a/docs/auditd.conf.5 b/docs/auditd.conf.5
index 6715341..6a16c21 100644
--- a/docs/auditd.conf.5
+++ b/docs/auditd.conf.5
@@ -204,7 +204,7 @@ means that it will issue a warning to syslog.
.I rotate
will rotate logs, losing the oldest to free up space.
.I exec
-/path-to-script will execute the script. You cannot pass parameters to the script. The script is also responsible for telling the auditd daemon to resume loggin
+/path-to-script will execute the script. You cannot pass parameters to the script. The script is also responsible for telling the auditd daemon to resume login
g once its completed its action. This can be done by adding service auditd resume to the script.
.I Suspend
will cause the audit daemon to stop writing records to the disk. The daemon will still be alive. The
diff --git a/docs/auparse_find_field.3 b/docs/auparse_find_field.3
index 4062588..a9db80e 100644
--- a/docs/auparse_find_field.3
+++ b/docs/auparse_find_field.3
@@ -8,7 +8,7 @@ const char *auparse_find_field(auparse_state_t *au, const char *name);
.SH "DESCRIPTION"
-auparse_find_field will scan all records in an event to find the first occurance of the field name passed to it. Searching begins from the cursor's current position. The field name is stored for subsequent searching.
+auparse_find_field will scan all records in an event to find the first occurrence of the field name passed to it. Searching begins from the cursor's current position. The field name is stored for subsequent searching.
.SH "RETURN VALUE"
diff --git a/docs/auparse_find_field_next.3 b/docs/auparse_find_field_next.3
index f072fe7..e921080 100644
--- a/docs/auparse_find_field_next.3
+++ b/docs/auparse_find_field_next.3
@@ -1,6 +1,6 @@
.TH "AUPARSE_FIND_FIELD_NEXT" "3" "Feb 2007" "Red Hat" "Linux Audit API"
.SH NAME
-auparse_find_field_next \- find next occurrance of field name
+auparse_find_field_next \- find next occurrence of field name
.SH "SYNOPSIS"
.B #include <auparse.h>
.sp
@@ -8,7 +8,7 @@ const char *auparse_find_field_next(auparse_state_t *au);
.SH "DESCRIPTION"
-auparse_find_field_next finds the next occurrance of the previously stored field name. It will scan until it reaches the last record of the current event.
+auparse_find_field_next finds the next occurrence of the previously stored field name. It will scan until it reaches the last record of the current event.
.SH "RETURN VALUE"
diff --git a/tools/auvirt/auvirt.8 b/tools/auvirt/auvirt.8
index 96123f4..1fbc1f5 100644
--- a/tools/auvirt/auvirt.8
+++ b/tools/auvirt/auvirt.8
@@ -13,7 +13,7 @@ guest, both UUID or VM name can be given.
For each guest session the tool prints a record with the domain name, the user
that started the guest, the time when the guest was started and the time when
-the guest was stoped.
+the guest was stopped.
If the option "\-\-all\-events" is given a more detailed output is shown. In this
mode other records are shown for guest's stops, resource
[-- Attachment #3: 0003-Add-documentation-links-in-systemd-unit-file.patch --]
[-- Type: text/x-patch, Size: 640 bytes --]
From: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
Date: Tue, 28 Jun 2016 23:25:01 +0200
Subject: Add documentation links in systemd unit file
---
init.d/auditd.service | 1 +
1 file changed, 1 insertion(+)
diff --git a/init.d/auditd.service b/init.d/auditd.service
index cb0ebfb..0793a92 100644
--- a/init.d/auditd.service
+++ b/init.d/auditd.service
@@ -5,6 +5,7 @@ After=local-fs.target systemd-tmpfiles-setup.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
ConditionKernelCommandLine=!audit=0
+Documentation=man:auditd(8) https://people.redhat.com/sgrubb/audit/
[Service]
ExecStart=/sbin/auditd -n
[-- Attachment #4: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related
* Re: [PATCH] capabilities: audit capability use
From: Tejun Heo @ 2016-07-12 14:59 UTC (permalink / raw)
To: Topi Miettinen
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ebiederm-aS9lmoZGLiVWk0Htik3J/w, pmladek-IBi9RG/b67k,
luto-DgEjT+Ai2ygdnm+yROfE0A, serge-A9i7LUbDfNHQT0dZR+AlfA,
keescook-F7+t8E8rja9g9hUCZPvPmw, Paul Moore, Eric Paris, Li Zefan,
Johannes Weiner, Serge Hallyn, moderated list:AUDIT SUBSYSTEM,
open list:CONTROL GROUP (CGROUP), open list:CAPABILITIES
In-Reply-To: <683cdbb9-c414-07c7-16d3-41c4138ddf8d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Mon, Jul 11, 2016 at 07:47:44PM +0000, Topi Miettinen wrote:
> It's really critical to be able to associate a task in the logs to
> cgroups which were valid that time. Or can we infer somehow what cgroups
When is "that time"? Without logging all operations, this is
meaningless.
> a task was taking part, long time after task exit? Perhaps task cgroup
> membership changes and changes in available cgroups should be logged too?
>
> Some kind of cgroup IDs could be logged instead of long paths. Then
> these IDs should be reliably resolvable to paths offline somehow.
I don't think that's doable. That pretty much requires the kernel to
remember paths of all past cgroups.
> How usual migrations between cgroups are? Why would a task ever move
> from (say) systemd/system.slice/smartd.service to anywhere else?
In most cases, they won't move once set up initially but that's not
the point of audit subsystem. Logging this once one exit isn't gonna
help anything for auditing the system.
Thanks.
--
tejun
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Eric W. Biederman @ 2016-07-12 13:16 UTC (permalink / raw)
To: Topi Miettinen
Cc: linux-kernel, pmladek, luto, serge, keescook, Paul Moore,
Eric Paris, Tejun Heo, Li Zefan, Johannes Weiner,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <ab56ac20-1d56-714c-eb54-9a43db496526@gmail.com>
Topi Miettinen <toiwoton@gmail.com> writes:
> On 07/11/16 21:57, Eric W. Biederman wrote:
>> Topi Miettinen <toiwoton@gmail.com> writes:
>>
>>> There are many basic ways to control processes, including capabilities,
>>> cgroups and resource limits. However, there are far fewer ways to find
>>> out useful values for the limits, except blind trial and error.
>>>
>>> Currently, there is no way to know which capabilities are actually used.
>>> Even the source code is only implicit, in-depth knowledge of each
>>> capability must be used when analyzing a program to judge which
>>> capabilities the program will exercise.
>>>
>>> Generate an audit message at system call exit, when capabilities are used.
>>> This can then be used to configure capability sets for services by a
>>> software developer, maintainer or system administrator.
>>>
>>> Test case demonstrating basic capability monitoring with the new
>>> message types 1330 and 1331 and how the cgroups are displayed (boot to
>>> rdshell):
>>
>> You totally miss the interactions with the user namespace so this won't
>> give you the information you are aiming for.
>
> Please correct me if this is not right:
>
> There are two cases:
> a) real capability use as seen outside the namespace
> b) use of capabilities granted by the namespace
> Both cases could be active independently.
>
> For auditing purposes, we're mostly interested in a) and log noise from
> b) could be even seen a distraction.
>
> For configuration purposes, both cases can be interesting, a) for the
> configuration of services and b) in case where the containerized
> configuration is planned to be deployed outside. I'd still only log
> a).
>
>
> The same logic should apply with cgroup namespaces.
Not logging capabilities outside of the initial user namespace is
certainly the conservative place to start, and what selinux does.
You should also be logging capability use from cap_capable. Not
ns_capable. You are missing several kinds of capability use as
a quick review of kernel/capability.c should have shown you.
Eric
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Topi Miettinen @ 2016-07-12 8:54 UTC (permalink / raw)
To: Eric W. Biederman
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, pmladek-IBi9RG/b67k,
luto-DgEjT+Ai2ygdnm+yROfE0A, serge-A9i7LUbDfNHQT0dZR+AlfA,
keescook-F7+t8E8rja9g9hUCZPvPmw, Paul Moore, Eric Paris,
Tejun Heo, Li Zefan, Johannes Weiner,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <87vb0bbzyo.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
On 07/11/16 21:57, Eric W. Biederman wrote:
> Topi Miettinen <toiwoton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> There are many basic ways to control processes, including capabilities,
>> cgroups and resource limits. However, there are far fewer ways to find
>> out useful values for the limits, except blind trial and error.
>>
>> Currently, there is no way to know which capabilities are actually used.
>> Even the source code is only implicit, in-depth knowledge of each
>> capability must be used when analyzing a program to judge which
>> capabilities the program will exercise.
>>
>> Generate an audit message at system call exit, when capabilities are used.
>> This can then be used to configure capability sets for services by a
>> software developer, maintainer or system administrator.
>>
>> Test case demonstrating basic capability monitoring with the new
>> message types 1330 and 1331 and how the cgroups are displayed (boot to
>> rdshell):
>
> You totally miss the interactions with the user namespace so this won't
> give you the information you are aiming for.
Please correct me if this is not right:
There are two cases:
a) real capability use as seen outside the namespace
b) use of capabilities granted by the namespace
Both cases could be active independently.
For auditing purposes, we're mostly interested in a) and log noise from
b) could be even seen a distraction.
For configuration purposes, both cases can be interesting, a) for the
configuration of services and b) in case where the containerized
configuration is planned to be deployed outside. I'd still only log a).
The same logic should apply with cgroup namespaces.
-Topi
>
> Eric
>
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Eric W. Biederman @ 2016-07-11 21:57 UTC (permalink / raw)
To: Topi Miettinen
Cc: linux-kernel, mladek, luto, serge, keescook, Paul Moore,
Eric Paris, Tejun Heo, Li Zefan, Johannes Weiner, Serge Hallyn,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP CGROUP,
open list:CAPABILITIES
In-Reply-To: <1468235672-3745-1-git-send-email-toiwoton@gmail.com>
Topi Miettinen <toiwoton@gmail.com> writes:
> There are many basic ways to control processes, including capabilities,
> cgroups and resource limits. However, there are far fewer ways to find
> out useful values for the limits, except blind trial and error.
>
> Currently, there is no way to know which capabilities are actually used.
> Even the source code is only implicit, in-depth knowledge of each
> capability must be used when analyzing a program to judge which
> capabilities the program will exercise.
>
> Generate an audit message at system call exit, when capabilities are used.
> This can then be used to configure capability sets for services by a
> software developer, maintainer or system administrator.
>
> Test case demonstrating basic capability monitoring with the new
> message types 1330 and 1331 and how the cgroups are displayed (boot to
> rdshell):
You totally miss the interactions with the user namespace so this won't
give you the information you are aiming for.
Eric
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Topi Miettinen @ 2016-07-11 19:47 UTC (permalink / raw)
To: Tejun Heo
Cc: linux-kernel, ebiederm, pmladek, luto, serge, keescook,
Paul Moore, Eric Paris, Li Zefan, Johannes Weiner, Serge Hallyn,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <20160711170711.GB3337@htj.duckdns.org>
On 07/11/16 17:09, Tejun Heo wrote:
> Hello,
>
> On Mon, Jul 11, 2016 at 02:14:31PM +0300, Topi Miettinen wrote:
>> [ 28.443674] audit: type=1327 audit(1468234333.144:520): proctitle=6D6B6E6F64002F6465762F7A5F343639006300310032
>> [ 28.465888] audit: type=1330 audit(1468234333.144:520): cap_used=0000000008000000
>> [ 28.482080] audit: type=1331 audit(1468234333.144:520): cgroups=:/test;
>
> Please don't put additions of the two different audit types into one
> patch and I don't think the cgroup audit logging makes much sense.
> Without logging all migrations, it doesn't help auditing all that
> much. Also, printing all cgroup membership like that can be
> problematic for audit it can be arbitrarily long.
>
> Thanks.
>
It's really critical to be able to associate a task in the logs to
cgroups which were valid that time. Or can we infer somehow what cgroups
a task was taking part, long time after task exit? Perhaps task cgroup
membership changes and changes in available cgroups should be logged too?
Some kind of cgroup IDs could be logged instead of long paths. Then
these IDs should be reliably resolvable to paths offline somehow.
How usual migrations between cgroups are? Why would a task ever move
from (say) systemd/system.slice/smartd.service to anywhere else?
-Topi
^ permalink raw reply
* Re: [PATCH] capabilities: audit capability use
From: Topi Miettinen @ 2016-07-11 19:28 UTC (permalink / raw)
To: Serge E. Hallyn
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
ebiederm-aS9lmoZGLiVWk0Htik3J/w, pmladek-IBi9RG/b67k,
luto-DgEjT+Ai2ygdnm+yROfE0A, keescook-F7+t8E8rja9g9hUCZPvPmw,
Paul Moore, Eric Paris, Tejun Heo, Li Zefan, Johannes Weiner,
moderated list:AUDIT SUBSYSTEM, open list:CONTROL GROUP (CGROUP),
open list:CAPABILITIES
In-Reply-To: <0355f70f-8356-f685-d37d-ba28668363a1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 07/11/16 16:05, Topi Miettinen wrote:
> On 07/11/16 15:25, Serge E. Hallyn wrote:
>> Quoting Topi Miettinen (toiwoton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org):
>>> There are many basic ways to control processes, including capabilities,
>>> cgroups and resource limits. However, there are far fewer ways to find
>>> out useful values for the limits, except blind trial and error.
>>>
>>> Currently, there is no way to know which capabilities are actually used.
>>> Even the source code is only implicit, in-depth knowledge of each
>>> capability must be used when analyzing a program to judge which
>>> capabilities the program will exercise.
>>>
>>> Generate an audit message at system call exit, when capabilities are used.
>>> This can then be used to configure capability sets for services by a
>>> software developer, maintainer or system administrator.
>>>
>>> Test case demonstrating basic capability monitoring with the new
>>> message types 1330 and 1331 and how the cgroups are displayed (boot to
>>> rdshell):
>>
>> Thanks, Topi, I'll find time this week to look this over in detail.
>>
>> How much chattier does this make the syslog/journald during a regular
>> boot? I was thinking "this is audit, we can choose what messages
>> will show up", but I guess that' sonly what auditd actually listens to,
>> not what kernel emits? (sorry i've not looked at audit in a long
>> time). Drat, that makes it seem like tracepoints would be better
>> after all. But let's see how much it addes to the noise.
>
> For example "loadkeys" causes thousands of entries. :-( I'm checking how
> to avoid audit message rate limiting, now some messages are lost.
>
> It's still too easy to drown the logs with noise. That could be limited
> a lot by emitting a message only when the capability is used for the
> first time. But the question is how to define where to start counting
> (fork, exec, and/or setpcap?). I'm also not sure if that is the right
> way to log, since the first use of a capability could be expected and an
> innocent one, but then the 100th one could be malicious.
>
> It's also very complex and error-prone to collect a capability mask from
> audit logs, which was my original goal.
What if only a summary of capabilities was logged at task exit? That
should make the log volume reasonable.
-Topi
>
> -Topi
>
>>
>>> BusyBox v1.22.1 (Debian 1:1.22.0-19) built-in shell (ash)
>>> Enter 'help' for a list of built-in commands.
>>>
>>> (initramfs) cd /sys/fs
>>> (initramfs) mount -t cgroup2 cgroup cgroup
>>> [ 12.343152] audit_printk_skb: 5886 callbacks suppressed
>>> [ 12.355214] audit: type=1300 audit(1468234317.100:518): arch=c000003e syscall=165 success=yes exit=0 a0=7fffe1e9ae2d a1=7fffe1e9ae34 a2=7fffe1e9ae25 a3=8000 items=0 ppid=469 pid=470 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="mount" exe="/bin/mount" key=(null)
>>> [ 12.414853] audit: type=1327 audit(1468234317.100:518): proctitle=6D6F756E74002D74006367726F757032006367726F7570006367726F7570
>>> [ 12.438338] audit: type=1330 audit(1468234317.100:518): cap_used=0000000000200000
>>> [ 12.453893] audit: type=1331 audit(1468234317.100:518): cgroups=:/;
>>> (initramfs) cd cgroup
>>> (initramfs) mkdir test; cd test
>>> [ 17.335625] audit: type=1300 audit(1468234322.092:519): arch=c000003e syscall=83 success=yes exit=0 a0=7ffddfd75e29 a1=1ff a2=0 a3=1e2 items=0 ppid=469 pid=471 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="mkdir" exe="/bin/mkdir" key=(null)
>>> [ 17.392686] audit: type=1327 audit(1468234322.092:519): proctitle=6D6B6469720074657374
>>> [ 17.409404] audit: type=1330 audit(1468234322.092:519): cap_used=0000000000000002
>>> [ 17.425404] audit: type=1331 audit(1468234322.092:519): cgroups=:/;
>>> (initramfs) echo $$ >cgroup.procs
>>> (initramfs) mknod /dev/z_$$ c 1 2
>>> [ 28.385681] audit: type=1300 audit(1468234333.144:520): arch=c000003e syscall=133 success=yes exit=0 a0=7ffe16324e11 a1=21b6 a2=102 a3=5c9 items=0 ppid=469 pid=472 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="mknod" exe="/bin/mknod" key=(null)
>>> [ 28.443674] audit: type=1327 audit(1468234333.144:520): proctitle=6D6B6E6F64002F6465762F7A5F343639006300310032
>>> [ 28.465888] audit: type=1330 audit(1468234333.144:520): cap_used=0000000008000000
>>> [ 28.482080] audit: type=1331 audit(1468234333.144:520): cgroups=:/test;
>>> (initramfs) chown 1234 /dev/z_*
>>> [ 34.772992] audit: type=1300 audit(1468234339.532:521): arch=c000003e syscall=92 success=yes exit=0 a0=7ffd0b563e17 a1=4d2 a2=0 a3=60a items=0 ppid=469 pid=473 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="chown" exe="/bin/chown" key=(null)
>>> [ 34.828569] audit: type=1327 audit(1468234339.532:521): proctitle=63686F776E0031323334002F6465762F7A5F343639
>>> [ 34.848747] audit: type=1330 audit(1468234339.532:521): cap_used=0000000000000001
>>> [ 34.864404] audit: type=1331 audit(1468234339.532:521): cgroups=:/test;
>>>
>>> Signed-off-by: Topi Miettinen <toiwoton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> ---
>>> include/linux/audit.h | 4 +++
>>> include/linux/cgroup.h | 2 ++
>>> include/uapi/linux/audit.h | 2 ++
>>> kernel/audit.c | 7 +++---
>>> kernel/audit.h | 1 +
>>> kernel/auditsc.c | 28 ++++++++++++++++++++-
>>> kernel/capability.c | 5 ++--
>>> kernel/cgroup.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++
>>> 8 files changed, 105 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/include/linux/audit.h b/include/linux/audit.h
>>> index e38e3fc..971cb2e 100644
>>> --- a/include/linux/audit.h
>>> +++ b/include/linux/audit.h
>>> @@ -438,6 +438,8 @@ static inline void audit_mmap_fd(int fd, int flags)
>>> __audit_mmap_fd(fd, flags);
>>> }
>>>
>>> +extern void audit_log_cap_use(int cap);
>>> +
>>> extern int audit_n_rules;
>>> extern int audit_signals;
>>> #else /* CONFIG_AUDITSYSCALL */
>>> @@ -545,6 +547,8 @@ static inline void audit_mmap_fd(int fd, int flags)
>>> { }
>>> static inline void audit_ptrace(struct task_struct *t)
>>> { }
>>> +static inline void audit_log_cap_use(int cap)
>>> +{ }
>>> #define audit_n_rules 0
>>> #define audit_signals 0
>>> #endif /* CONFIG_AUDITSYSCALL */
>>> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
>>> index a20320c..b5dc8aa 100644
>>> --- a/include/linux/cgroup.h
>>> +++ b/include/linux/cgroup.h
>>> @@ -100,6 +100,8 @@ char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
>>> int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
>>> int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
>>> struct pid *pid, struct task_struct *tsk);
>>> +struct audit_buffer;
>>> +void audit_cgroup_list(struct audit_buffer *ab);
>>>
>>> void cgroup_fork(struct task_struct *p);
>>> extern int cgroup_can_fork(struct task_struct *p);
>>> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
>>> index d820aa9..c1ae016 100644
>>> --- a/include/uapi/linux/audit.h
>>> +++ b/include/uapi/linux/audit.h
>>> @@ -111,6 +111,8 @@
>>> #define AUDIT_PROCTITLE 1327 /* Proctitle emit event */
>>> #define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
>>> #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */
>>> +#define AUDIT_CAPABILITY 1330 /* Record showing capability use */
>>> +#define AUDIT_CGROUP 1331 /* Record showing cgroups */
>>>
>>> #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
>>> #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
>>> diff --git a/kernel/audit.c b/kernel/audit.c
>>> index 8d528f9..98dd920 100644
>>> --- a/kernel/audit.c
>>> +++ b/kernel/audit.c
>>> @@ -54,6 +54,7 @@
>>> #include <linux/kthread.h>
>>> #include <linux/kernel.h>
>>> #include <linux/syscalls.h>
>>> +#include <linux/cgroup.h>
>>>
>>> #include <linux/audit.h>
>>>
>>> @@ -1682,7 +1683,7 @@ void audit_log_cap(struct audit_buffer *ab, char *prefix, kernel_cap_t *cap)
>>> {
>>> int i;
>>>
>>> - audit_log_format(ab, " %s=", prefix);
>>> + audit_log_format(ab, "%s=", prefix);
>>> CAP_FOR_EACH_U32(i) {
>>> audit_log_format(ab, "%08x",
>>> cap->cap[CAP_LAST_U32 - i]);
>>> @@ -1696,11 +1697,11 @@ static void audit_log_fcaps(struct audit_buffer *ab, struct audit_names *name)
>>> int log = 0;
>>>
>>> if (!cap_isclear(*perm)) {
>>> - audit_log_cap(ab, "cap_fp", perm);
>>> + audit_log_cap(ab, " cap_fp", perm);
>>> log = 1;
>>> }
>>> if (!cap_isclear(*inh)) {
>>> - audit_log_cap(ab, "cap_fi", inh);
>>> + audit_log_cap(ab, " cap_fi", inh);
>>> log = 1;
>>> }
>>>
>>> diff --git a/kernel/audit.h b/kernel/audit.h
>>> index a492f4c..680e8b5 100644
>>> --- a/kernel/audit.h
>>> +++ b/kernel/audit.h
>>> @@ -202,6 +202,7 @@ struct audit_context {
>>> };
>>> int fds[2];
>>> struct audit_proctitle proctitle;
>>> + kernel_cap_t cap_used;
>>> };
>>>
>>> extern u32 audit_ever_enabled;
>>> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
>>> index 2672d10..32c3813 100644
>>> --- a/kernel/auditsc.c
>>> +++ b/kernel/auditsc.c
>>> @@ -197,7 +197,6 @@ static int audit_match_filetype(struct audit_context *ctx, int val)
>>> * References in it _are_ dropped - at the same time we free/drop aux stuff.
>>> */
>>>
>>> -#ifdef CONFIG_AUDIT_TREE
>>> static void audit_set_auditable(struct audit_context *ctx)
>>> {
>>> if (!ctx->prio) {
>>> @@ -206,6 +205,7 @@ static void audit_set_auditable(struct audit_context *ctx)
>>> }
>>> }
>>>
>>> +#ifdef CONFIG_AUDIT_TREE
>>> static int put_tree_ref(struct audit_context *ctx, struct audit_chunk *chunk)
>>> {
>>> struct audit_tree_refs *p = ctx->trees;
>>> @@ -1439,6 +1439,18 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>>>
>>> audit_log_proctitle(tsk, context);
>>>
>>> + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CAPABILITY);
>>> + if (ab) {
>>> + audit_log_cap(ab, "cap_used", &context->cap_used);
>>> + audit_log_end(ab);
>>> + }
>>> + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CGROUP);
>>> + if (ab) {
>>> + audit_log_format(ab, "cgroups=");
>>> + audit_cgroup_list(ab);
>>> + audit_log_end(ab);
>>> + }
>>> +
>>> /* Send end of event record to help user space know we are finished */
>>> ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
>>> if (ab)
>>> @@ -2428,3 +2440,17 @@ struct list_head *audit_killed_trees(void)
>>> return NULL;
>>> return &ctx->killed_trees;
>>> }
>>> +
>>> +void audit_log_cap_use(int cap)
>>> +{
>>> + struct audit_context *context = current->audit_context;
>>> +
>>> + if (context) {
>>> + cap_raise(context->cap_used, cap);
>>> + audit_set_auditable(context);
>>> + } else {
>>> + audit_log(NULL, GFP_NOFS, AUDIT_CAPABILITY,
>>> + "cap_used=%d pid=%d no audit_context",
>>> + cap, task_pid_nr(current));
>>> + }
>>> +}
>>> diff --git a/kernel/capability.c b/kernel/capability.c
>>> index 45432b5..d45d5b1 100644
>>> --- a/kernel/capability.c
>>> +++ b/kernel/capability.c
>>> @@ -366,8 +366,8 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
>>> * @ns: The usernamespace we want the capability in
>>> * @cap: The capability to be tested for
>>> *
>>> - * Return true if the current task has the given superior capability currently
>>> - * available for use, false if not.
>>> + * Return true if the current task has the given superior capability
>>> + * currently available for use, false if not. Write an audit message.
>>> *
>>> * This sets PF_SUPERPRIV on the task if the capability is available on the
>>> * assumption that it's about to be used.
>>> @@ -380,6 +380,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
>>> }
>>>
>>> if (security_capable(current_cred(), ns, cap) == 0) {
>>> + audit_log_cap_use(cap);
>>> current->flags |= PF_SUPERPRIV;
>>> return true;
>>> }
>>> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
>>> index 75c0ff0..1931679 100644
>>> --- a/kernel/cgroup.c
>>> +++ b/kernel/cgroup.c
>>> @@ -63,6 +63,7 @@
>>> #include <linux/nsproxy.h>
>>> #include <linux/proc_ns.h>
>>> #include <net/sock.h>
>>> +#include <linux/audit.h>
>>>
>>> /*
>>> * pidlists linger the following amount before being destroyed. The goal
>>> @@ -5789,6 +5790,67 @@ out:
>>> return retval;
>>> }
>>>
>>> +/*
>>> + * audit_cgroup_list()
>>> + * - Print task's cgroup paths with audit_log_format()
>>> + * - Used for capability audit logging
>>> + * - Otherwise very similar to proc_cgroup_show().
>>> + */
>>> +void audit_cgroup_list(struct audit_buffer *ab)
>>> +{
>>> + char *buf, *path;
>>> + struct cgroup_root *root;
>>> +
>>> + buf = kmalloc(PATH_MAX, GFP_NOFS);
>>> + if (!buf)
>>> + return;
>>> +
>>> + mutex_lock(&cgroup_mutex);
>>> + spin_lock_irq(&css_set_lock);
>>> +
>>> + for_each_root(root) {
>>> + struct cgroup_subsys *ss;
>>> + struct cgroup *cgrp;
>>> + int ssid, count = 0;
>>> +
>>> + if (root == &cgrp_dfl_root && !cgrp_dfl_visible)
>>> + continue;
>>> +
>>> + if (root != &cgrp_dfl_root)
>>> + for_each_subsys(ss, ssid)
>>> + if (root->subsys_mask & (1 << ssid))
>>> + audit_log_format(ab, "%s%s",
>>> + count++ ? "," : "",
>>> + ss->legacy_name);
>>> + if (strlen(root->name))
>>> + audit_log_format(ab, "%sname=%s", count ? "," : "",
>>> + root->name);
>>> + audit_log_format(ab, ":");
>>> +
>>> + cgrp = task_cgroup_from_root(current, root);
>>> +
>>> + if (cgroup_on_dfl(cgrp) || !(current->flags & PF_EXITING)) {
>>> + path = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,
>>> + current->nsproxy->cgroup_ns);
>>> + if (!path)
>>> + goto out_unlock;
>>> + } else
>>> + path = "/";
>>> +
>>> + audit_log_format(ab, "%s", path);
>>> +
>>> + if (cgroup_on_dfl(cgrp) && cgroup_is_dead(cgrp))
>>> + audit_log_format(ab, " (deleted);");
>>> + else
>>> + audit_log_format(ab, ";");
>>> + }
>>> +
>>> +out_unlock:
>>> + spin_unlock_irq(&css_set_lock);
>>> + mutex_unlock(&cgroup_mutex);
>>> + kfree(buf);
>>> +}
>>> +
>>> /* Display information about each subsystem and each hierarchy */
>>> static int proc_cgroupstats_show(struct seq_file *m, void *v)
>>> {
>>> --
>>> 2.8.1
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox