<div dir="ltr">Excellent!!!</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 12, 2015 at 9:58 AM, Viswanath, Logeswari P (MCOU OSTL) <span dir="ltr"><<a href="mailto:logeswari.pv@hp.com" target="_blank">logeswari.pv@hp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
We did profiling of the kernel during our performance test and below were the top 4 functions for the overhead.<br>
<span class=""><br>
11.33%        loader1  [kernel.kallsyms]   [k] format_decode<br>
    10.40%        loader1  [kernel.kallsyms]   [k] memcpy<br>
     7.46%        loader1  [kernel.kallsyms]   [k] number.isra.1<br>
     6.99%        loader1  [kernel.kallsyms]   [k] vsnprintf<br>
<br>
</span>Please find attached the complete profiling data of the kernel using perf tool.<br>
<span class="im HOEnZb"><br>
>From the perf data, we believed the overhead is because of invoking audit_log_format function multiple times.<br>
We changed the code to reduce the number of times this function is called.<br>
With this change the performance degradation is 20% now compared to the performance without auditing.<br>
Without this change the performance degradation is 200% compared to the performance without auditing.<br>
<br>
</span><span class="im HOEnZb">We can publish the code change done tomorrow.<br>
<br>
</span><span class="im HOEnZb">Please let me know your feedback on this idea.<br>
<br>
</span><span class="im HOEnZb">Regards,<br>
Logeswari.<br>
<br>
-----Original Message-----<br>
From: Richard Guy Briggs [mailto:<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>]<br>
</span><span class="im HOEnZb">Sent: Wednesday, February 11, 2015 10:21 PM<br>
To: Viswanath, Logeswari P (MCOU OSTL)<br>
</span><div class="HOEnZb"><div class="h5">Cc: <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a><br>
Subject: Re: Linux audit performance impact<br>
<br>
On 15/02/06, Viswanath, Logeswari P (MCOU OSTL) wrote:<br>
> Hi all,<br>
><br>
> Please find the below the details of the performance test we ran.<br>
> It would be great if we get help to identify the reason behind the degradation and the ways of improving it.<br>
><br>
> Kernel Version:<br>
> root > uname -r<br>
> 3.13.0-36-generic<br>
><br>
> OS Version:<br>
> Ubuntu 14.04.1<br>
><br>
> No. of CPUs:<br>
> root > nproc<br>
> 24<br>
><br>
> Audit Status:<br>
> root > auditctl -s<br>
> AUDIT_STATUS: enabled=1 flag=1 pid=0 rate_limit=0 backlog_limit=320<br>
> lost=57190353 backlog=0<br>
><br>
> Rules Configured:<br>
> root > auditctl -l<br>
> LIST_RULES: exit,always arch=3221225534 (0xc000003e) syscall=all<br>
><br>
> Attached is the program used to load the system.<br>
><br>
> Results:<br>
><br>
> Without enabling audit        12.29<br>
> With auditing enabled and no rules configured 12.31<br>
> With auditing enabled, 1 rule configured but auditd not running - kauditd logs audit records to syslog via printk     41.02<br>
<br>
This would be more meaningful if you hacked the kernel to drain the queue figuratively to /dev/nul to eliminate the effect of auditd draining it, or syslog covering for a missing auditd.  This stat doesn't tell us that much since the I/O act can vary significantly per installation.  That one rule you chose is pretty unnaturally abusive and needs to be carefully thought out to avoid self-measurement.<br>
<br>
> The degradation is around 200%<br>
><br>
> Regards,<br>
> Logeswari.<br>
><br>
> -----Original Message-----<br>
> From: Richard Guy Briggs [mailto:<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>]<br>
> Sent: Wednesday, February 04, 2015 9:46 PM<br>
> To: Viswanath, Logeswari P (MCOU OSTL)<br>
> Cc: Satish Chandra Kilaru; Steve Grubb; <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a><br>
> Subject: Re: Linux audit performance impact<br>
><br>
> On 15/02/04, Viswanath, Logeswari P (MCOU OSTL) wrote:<br>
> > The intent is to calculate the performance impact by the auditing<br>
> > components such as<br>
> ><br>
> > 1) impact because of kauditd without auditd - but kauditd writes to syslog, so we are unable to determine the impact just because of kauditd - It is fine even if the audit record is dropped by kauditd. Is there any way to do this?<br>
><br>
> Not yet.  That is a mode that has not been useful to anyone yet.  You are welcome to hack a custom kernel to disable klog for doing testing instrumentation.<br>
><br>
> > 2) impact because of running auditd - log format NOLOG<br>
> > 3) impact because of running audispd - small plugin is written which will just read the audit records and doesn't processes it.<br>
> ><br>
> > -----Original Message-----<br>
> > From: Richard Guy Briggs [mailto:<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>]<br>
> > Sent: Tuesday, February 03, 2015 10:33 PM<br>
> > To: Satish Chandra Kilaru<br>
> > Cc: Viswanath, Logeswari P (MCOU OSTL); Steve Grubb;<br>
> > <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a><br>
> > Subject: Re: Linux audit performance impact<br>
> ><br>
> > On 15/02/03, Satish Chandra Kilaru wrote:<br>
> > > Thanks for The info. But my question was rhetorical... I meant to<br>
> > > say that it would not be much... She is trying to bombard the<br>
> > > system with open calls ... So lots and lots of events will be<br>
> > > generated and kernel has to write down the events some where or discard them...<br>
> ><br>
> > Exactly.  It is of little practical use.  You have to do I/O at some point, either to the same disk or another, or to a network interface or serial port, otherwise, just chuck it out.  You could do a performance measurement on a short burst, then drain the queue, but what will that actually tell us?<br>
> ><br>
> > > On Tuesday, February 3, 2015, Richard Guy Briggs <<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>> wrote:<br>
> > ><br>
> > > > On 15/02/03, Satish Chandra Kilaru wrote:<br>
> > > > > How many events can kernel accumulate without I/o ?<br>
> > > ><br>
> > > > The kernel default is 64 *buffers*, but I think Fedora and RHEL<br>
> > > > set it to 320.  It is now possible to set it to "0" which means<br>
> > > > limited only by system resources.  See "man auditctl", "-b"<br>
> > > > option.  An event can be made up of several buffers.<br>
> > > ><br>
> > > > Of course, how long a system lasts before the queue blows up<br>
> > > > depends on your rule set...<br>
> > > ><br>
> > > > However, at the moment, it will still write out to klog if<br>
> > > > auditd isn't running.<br>
> > > ><br>
> > > > > On Tuesday, February 3, 2015, Viswanath, Logeswari P (MCOU<br>
> > > > > OSTL) < <a href="mailto:logeswari.pv@hp.com">logeswari.pv@hp.com</a> <javascript:;>> wrote:<br>
> > > > ><br>
> > > > > > I don't want to disable auditing (i.e. disable audit record<br>
> > > > collection),<br>
> > > > > > but just do not want the records to delivered to user space<br>
> > > > > > since I<br>
> > > > want to<br>
> > > > > > remove the I/O overhead while running the performance test.<br>
> > > > > > Is there any option for this?<br>
> > > > > ><br>
> > > > > > -----Original Message-----<br>
> > > > > > From: Richard Guy Briggs [mailto:<a href="mailto:rgb@redhat.com">rgb@redhat.com</a><br>
> > > > > > <javascript:;><br>
> > > > <javascript:;>]<br>
> > > > > > Sent: Thursday, January 29, 2015 10:23 PM<br>
> > > > > > To: Viswanath, Logeswari P (MCOU OSTL)<br>
> > > > > > Cc: Satish Chandra Kilaru; Steve Grubb;<br>
> > > > > > <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a><br>
> > > > <javascript:;><br>
> > > > > > <javascript:;><br>
> > > > > > Subject: Re: Linux audit performance impact<br>
> > > > > ><br>
> > > > > > On 15/01/29, Viswanath, Logeswari P (MCOU OSTL) wrote:<br>
> > > > > > > Please read my question as “Is there any option to<br>
> > > > > > > configure kaudit not to log audit records to syslog? when auditd not running.”<br>
> > > > > ><br>
> > > > > > Yeah, remove audit=1 from the kernel command line, or set<br>
> > > > > > audit=0 in<br>
> > > > its<br>
> > > > > > place.  This will stop all but AVCs and if auditd has ever<br>
> > > > > > run since<br>
> > > > boot.<br>
> > > > > > If audit=0 is on the kernel boot line, it will be impossible<br>
> > > > > > to run<br>
> > > > auditd.<br>
> > > > > ><br>
> > > > > > There is a feature request that is likely coming soon that<br>
> > > > > > could be<br>
> > > > > > useful:<br>
> > > > > ><br>
> > > > > > <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1160046" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=1160046</a><br>
> > > > > > "If no audit daemon is running, but an audit multicast<br>
> > > > > > subscriber is around, then the kernel shouldn't forward audit data to kmsg"<br>
> > > > > ><br>
> > > > > > > From: Viswanath, Logeswari P (MCOU OSTL)<br>
> > > > > > > Sent: Thursday, January 29, 2015 11:49 AM<br>
> > > > > > > To: 'Satish Chandra Kilaru'; Steve Grubb<br>
> > > > > > > Cc: <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a> <javascript:;> <javascript:;><br>
> > > > > > > Subject: RE: Linux audit performance impact<br>
> > > > > > ><br>
> > > > > > > Is there any option to configure kaudit not to log audit<br>
> > > > > > > records to<br>
> > > > > > syslog when auditd is running?<br>
> > > > > > > This way we can assess the impact of enabling audit<br>
> > > > > > > without involving<br>
> > > > > > disk I/o overhead.<br>
> > > > > > ><br>
> > > > > > > From: Satish Chandra Kilaru [mailto:<a href="mailto:iam.kilaru@gmail.com">iam.kilaru@gmail.com</a><br>
> > > > <javascript:;> <javascript:;>]<br>
> > > > > > > Sent: Thursday, January 29, 2015 9:12 AM<br>
> > > > > > > To: Steve Grubb<br>
> > > > > > > Cc: <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a> <javascript:;> <javascript:;><mailto:<br>
> > > > <a href="mailto:linux-audit@redhat.com">linux-audit@redhat.com</a> <javascript:;><br>
> > > > > > <javascript:;>>; Viswanath,<br>
> > > > > > > Logeswari P (MCOU OSTL)<br>
> > > > > > > Subject: Re: Linux audit performance impact<br>
> > > > > > ><br>
> > > > > > > I agree with you... but writing to disk can trigger<br>
> > > > > > > further events<br>
> > > > > > leading spiralling of events...<br>
> > > > > > > I brought down my server few times with stupid rules...<br>
> > > > > > ><br>
> > > > > > > On Wed, Jan 28, 2015 at 10:39 PM, Steve Grubb<br>
> > > > > > > <<a href="mailto:sgrubb@redhat.com">sgrubb@redhat.com</a><br>
> > > > <javascript:;><br>
> > > > > > <javascript:;><mailto:<a href="mailto:sgrubb@redhat.com">sgrubb@redhat.com</a> <javascript:;><br>
> > > > <javascript:;>>> wrote:<br>
> > > > > > > On Wednesday, January 28, 2015 10:18:47 AM Satish Chandra<br>
> > > > > > > Kilaru<br>
> > > > wrote:<br>
> > > > > > > > Write your own program to receive audit events directly<br>
> > > > > > > > without using auditd...<br>
> > > > > > > > That should be faster ....<br>
> > > > > > > > Auditd will log the events to disk causing more I/o than u need...<br>
> > > > > > ><br>
> > > > > > > But even that is configurable in many ways. You can decide<br>
> > > > > > > if you<br>
> > > > want<br>
> > > > > > > logging to disk or not and what kind of assurance that it<br>
> > > > > > > made it to disk and the priority of that audit daemon.<br>
> > > > > > > Then you also have all<br>
> > > > the<br>
> > > > > > > normal tuning knobs for disk throughput that you would use<br>
> > > > > > > for any disk performance critical system.<br>
> > > > > > ><br>
> > > > > > > -Steve<br>
> > > > > > ><br>
> > > > > > > > On Wednesday, January 28, 2015, Viswanath, Logeswari P<br>
> > > > > > > > (MCOU<br>
> > > > > > > > OSTL)<br>
> > > > <<br>
> > > > > > > ><br>
> > > > > > > > <a href="mailto:logeswari.pv@hp.com">logeswari.pv@hp.com</a> <javascript:;> <javascript:;><mailto:<br>
> > > > <a href="mailto:logeswari.pv@hp.com">logeswari.pv@hp.com</a> <javascript:;><br>
> > > > > > <javascript:;>>> wrote:<br>
> > > > > > > > >  Hi Steve,<br>
> > > > > > > > ><br>
> > > > > > > > > I am Logeswari working for HP.<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > We want to know audit performance impact on RHEL and<br>
> > > > > > > > > Suse linux<br>
> > > > to<br>
> > > > > > > > > help us evaluate linux audit as data source for our<br>
> > > > > > > > > host based<br>
> > > > IDS.<br>
> > > > > > > > ><br>
> > > > > > > > > When we ran our own performance test with a test<br>
> > > > > > > > > audispd plugin, we found if a system can perform<br>
> > > > > > > > > 200000 open/close system calls per second without<br>
> > > > > > > > > auditing, system can perform only 3000 open/close<br>
> > > > > > > > > system calls auditing is enabled for open/close system<br>
> > > > > > > > > call which is a HUGE impact on the system performance.<br>
> > > > > > > > > It would<br>
> > > > be<br>
> > > > > > > > > great if anyone can help us answering the following questions.<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > 1)      Is this performance impact expected? If yes, what is the<br>
> > > > > > reason<br>
> > > > > > > > > behind it and can we fix it?<br>
> > > > > > > > ><br>
> > > > > > > > > 2)      Have anyone done any benchmarking for performance<br>
> > > > impact? If<br>
> > > > > > yes,<br>
> > > > > > > > > can you please share the numbers and also the<br>
> > > > > > > > > steps/programs used the run the same.<br>
> > > > > > > > ><br>
> > > > > > > > > 3)      Help us validating the performance test we have done in<br>
> > > > our<br>
> > > > > > test<br>
> > > > > > > > > setup using the steps mentioned along with the results attached.<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > Attached test program (loader.c) to invoke open and<br>
> > > > > > > > > close system<br>
> > > > > > calls.<br>
> > > > > > > > ><br>
> > > > > > > > > Attached idskerndsp is the audispd plugin program.<br>
> > > > > > > > ><br>
> > > > > > > > > We used time command to determine how much time the<br>
> > > > > > > > > system took<br>
> > > > to<br>
> > > > > > > > > complete 50000 open/close system calls without<br>
> > > > > > > > > (results attached<br>
> > > > > > > > > Without-auditing) and with auditing enabled on the<br>
> > > > > > > > > system (With-auditing-NOLOG-audispd-plugin and<br>
> > > > > > > > > With-auditing-RAW)<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > System details:<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > 1 CPU machine<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > *OS Version*<br>
> > > > > > > > ><br>
> > > > > > > > > RHEL 6.5<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > *Kernel Version*<br>
> > > > > > > > ><br>
> > > > > > > > > uname –r<br>
> > > > > > > > ><br>
> > > > > > > > > 2.6.32-431.el6.x86_64<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > Note: auditd was occupying 35% of CPU and was sleeping<br>
> > > > > > > > > for most<br>
> > > > of<br>
> > > > > > > > > the time whereas kauditd was occupying 20% of the CPU.<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > Thanks & Regards,<br>
> > > > > > > > ><br>
> > > > > > > > > Logeswari.<br>
> > > > > > ><br>
> > > > > > ><br>
> > > > > > ><br>
> > > > > > > --<br>
> > > > > > > Please Donate to<br>
> > > > > > > <a href="http://www.wikipedia.org" target="_blank">www.wikipedia.org</a><<a href="http://www.wikipedia.org" target="_blank">http://www.wikipedia.org</a>><br>
> > > > > ><br>
> > > > > > > --<br>
> > > > > > > Linux-audit mailing list<br>
> > > > > > > <a href="mailto:Linux-audit@redhat.com">Linux-audit@redhat.com</a> <javascript:;> <javascript:;><br>
> > > > > > > <a href="https://www.redhat.com/mailman/listinfo/linux-audit" target="_blank">https://www.redhat.com/mailman/listinfo/linux-audit</a><br>
> > > > > ><br>
> > > > > ><br>
> > > > > > - RGB<br>
> > > > > ><br>
> > > > > > --<br>
> > > > > > Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a> <javascript:;><br>
> > > > > > <javascript:;>> Senior Software Engineer, Kernel Security,<br>
> > > > > > AMER ENG Base Operating Systems, Red Hat Remote, Ottawa,<br>
> > > > > > Canada<br>
> > > > > > Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635, Alt:<br>
> > > > > > <a href="tel:%2B1.613.693.0684x3545" value="+16136930684">+1.613.693.0684x3545</a><br>
> > > > > ><br>
> > > > ><br>
> > > > ><br>
> > > > > --<br>
> > > > > Please Donate to <a href="http://www.wikipedia.org" target="_blank">www.wikipedia.org</a><br>
> > > ><br>
> > > > - RGB<br>
> > > ><br>
> > > > --<br>
> > > > Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a> <javascript:;>> Senior<br>
> > > > Software Engineer, Kernel Security, AMER ENG Base Operating<br>
> > > > Systems, Red Hat Remote, Ottawa, Canada<br>
> > > > Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635, Alt:<br>
> > > > <a href="tel:%2B1.613.693.0684x3545" value="+16136930684">+1.613.693.0684x3545</a><br>
> > > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > Please Donate to <a href="http://www.wikipedia.org" target="_blank">www.wikipedia.org</a><br>
> ><br>
> > - RGB<br>
> ><br>
> > --<br>
> > Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a>> Senior Software Engineer,<br>
> > Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote,<br>
> > Ottawa, Canada<br>
> > Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635, Alt:<br>
> > <a href="tel:%2B1.613.693.0684x3545" value="+16136930684">+1.613.693.0684x3545</a><br>
><br>
> - RGB<br>
><br>
> --<br>
> Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a>> Senior Software Engineer,<br>
> Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote,<br>
> Ottawa, Canada<br>
> Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635, Alt:<br>
> <a href="tel:%2B1.613.693.0684x3545" value="+16136930684">+1.613.693.0684x3545</a><br>
<br>
> #include <stdio.h><br>
> #include <stdlib.h><br>
> #include <sys/stat.h><br>
> #include <fcntl.h><br>
> #include <unistd.h><br>
> #include <errno.h><br>
><br>
> void create_load(int iters);<br>
> void cleanup();<br>
><br>
> int   high_rate = 0;<br>
> int   num_iters = 100000;<br>
> int   fd1;<br>
> char  file1[50];<br>
> char  file2[50];<br>
> char  dir1[50];<br>
> char  symlink1[50];<br>
><br>
> /* Purpose: To create system load by invoking system calls used by templates.<br>
>  *<br>
>  * Note: The unlink(2) of a file can be an expensive operation (i.e., event<br>
>  *       rate goes way down).<br>
>  */<br>
><br>
> main(int argc, char **argv) {<br>
><br>
>   int              num_children=1;<br>
>   int              iters;<br>
>   int              i;<br>
>   char             c;<br>
><br>
>   while ((c = getopt(argc, argv, "hi:")) != -1) {<br>
>     switch (c) {<br>
>     case 'h':<br>
>       /*<br>
>        * Desire "high" event rate<br>
>        */<br>
>       high_rate = 1;<br>
>       argc--;<br>
>       break;<br>
>     case 'i':<br>
>       /*<br>
>        * Desire a specified number of iterations<br>
>        */<br>
>       num_iters = atoi(optarg);<br>
>       argc--;<br>
>       break;<br>
>     default:<br>
>       fprintf(stderr,"Unknown option: %c\n",optarg);<br>
>       exit(1);<br>
>     }<br>
>   }<br>
><br>
><br>
>   /*if(argv[optind] != NULL) {<br>
>     num_children = atoi(argv[optind]);<br>
>   } else {<br>
>     num_children = 0;<br>
>   }<br>
>   Register cleanup routine */<br>
>   fprintf(stderr,"Registering cleanup routine...\n");<br>
>   if (atexit(cleanup) == -1) {<br>
>     fprintf(stderr,"Error calling atexit(), errno=%d(%s)\n",<br>
>           errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
><br>
>   /* fork child processes, if any requested */<br>
>   for(i=1; i < num_children; i++) {<br>
>     if(fork() == 0) {<br>
><br>
>       printf("child pid: %d\n",getpid());<br>
><br>
>       /* Setup file names based on child's pid */<br>
>       sprintf(file1,"./file1_%d",getpid());<br>
>       sprintf(file2,"./file2_%d",getpid());<br>
>       sprintf(dir1,"./dir1_%d",getpid());<br>
>       sprintf(symlink1,"./file1symlink_%d",getpid());<br>
><br>
>       /* each child creates load */<br>
>       iters=0;<br>
>       if (num_iters == -1) {<br>
>       while(1) {<br>
>         create_load(iters);<br>
>         iters++;<br>
>         if( (iters % 1000) == 0) {<br>
>           printf("pid %d iteration %d\n",getpid(),iters);<br>
>         }<br>
>       }<br>
>       } else {<br>
>       while(iters < num_iters) {<br>
>         create_load(iters);<br>
>         iters++;<br>
>         if( (iters % 1000) == 0) {<br>
>           printf("pid %d iteration %d\n",getpid(),iters);<br>
>         }<br>
>       }<br>
>       }<br>
>     }<br>
>   }<br>
><br>
>   /* Parent creates load also */<br>
>   printf("parent pid: %d\n",getpid());<br>
><br>
>   /* Setup file names based on parent's pid */<br>
>   sprintf(file1,"./file1_%d",getpid());<br>
>   sprintf(file2,"./file2_%d",getpid());<br>
>   sprintf(dir1,"./dir1_%d",getpid());<br>
>   sprintf(symlink1,"./file1symlink_%d",getpid());<br>
><br>
>   iters=0;<br>
>   if (num_iters == -1) {<br>
>     while(1) {<br>
>       create_load(iters);<br>
>       iters++;<br>
>       if( (iters % 1000) == 0) {<br>
>       printf("pid %d iteration %d\n",getpid(),iters);<br>
>       }<br>
>     }<br>
>   } else {<br>
>     while(iters < num_iters) {<br>
>       create_load(iters);<br>
>       iters++;<br>
>       if( (iters % 1000) == 0) {<br>
>       printf("pid %d iteration %d\n",getpid(),iters);<br>
>       }<br>
>     }<br>
>   }<br>
><br>
> } /* main */<br>
><br>
><br>
> void create_load(int iters) {<br>
><br>
>   int pid;<br>
>   char *args[2];<br>
>   struct stat stat_buf;<br>
><br>
>   fd1 = creat(file1,0x644);<br>
>   if (fd1 == -1) {<br>
>     fprintf(stderr,"pid %d: creat() returned error for file %s, errno=%d(%s)\n",<br>
>           getpid(),file1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (close(fd1) == -1) {<br>
>     fprintf(stderr,"pid %d: close() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   fd1 = open(file1, O_RDWR, 0777);<br>
>   if (fd1 == -1) {<br>
>     fprintf(stderr,"pid %d: open() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   /* Chown this file to root instead of user ids so that we don't generate a<br>
>    * non-owned alert when the file is truncated when invoking creat() again<br>
>    * as root on an existing file owned by another user.<br>
>    */<br>
>   if (chown(file1,0,0) == -1) {<br>
>     fprintf(stderr,"pid %d: chown(%d,%d) returned error, errno=%d(%s)\n",<br>
>           getpid(),0,0,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   if (fchown(fd1,0,0) == -1) {<br>
>     fprintf(stderr,"pid %d: fchown(%d,%d) returned error, errno=%d(%s)\n",<br>
>           getpid(),0,0,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   if (chmod(file1, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) == -1) {<br>
>     fprintf(stderr,"pid %d: chmod(S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (fchmod(fd1,   S_IXUSR|S_IXGRP|S_IXOTH) == -1) {<br>
>     fprintf(stderr,"pid %d: fchmod(S_IXUSR|S_IXGRP|S_IXOTH) returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
><br>
>   if (write(fd1,"Some stuff",strlen("Some stuff")) == -1) {<br>
>     fprintf(stderr,"pid %d: write() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (ftruncate(fd1,7) == -1) {<br>
>     fprintf(stderr,"pid %d: ftruncate() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (close(fd1) == -1) {<br>
>     fprintf(stderr,"pid %d: close() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   if (truncate(file1,3) == -1) {<br>
>     fprintf(stderr,"pid %d: truncate() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (rename(file1,file2) == -1) {<br>
>     fprintf(stderr,"pid %d: rename(%s,%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file1,file2,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (rename(file2,file1) == -1) {<br>
>     fprintf(stderr,"pid %d: rename(%s,%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file2,file1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (link(file1,file2) == -1) {<br>
>     fprintf(stderr,"pid %d: link(%s,%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file1,file2,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (symlink(file1,symlink1) == -1) {<br>
>     fprintf(stderr,"pid %d: symlink(%s,%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file1,symlink1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (lchown(symlink1,0,0) == -1) {<br>
>     fprintf(stderr,"pid %d: lchown(%s,%d,%d) returned error, errno=%d(%s)\n",<br>
>           getpid(),symlink1,0,0,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   if (lstat(symlink1,&stat_buf) == -1) {<br>
>     fprintf(stderr,"pid %d: lstat(%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),symlink1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (stat(file1,&stat_buf) == -1) {<br>
>     fprintf(stderr,"pid %d: stat(%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (unlink(file1) == -1) {<br>
>     fprintf(stderr,"pid %d: unlink(%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (unlink(file2) == -1) {<br>
>     fprintf(stderr,"pid %d: unlink(%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),file2,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (unlink(symlink1) == -1) {<br>
>     fprintf(stderr,"pid %d: unlink(%s) returned error, errno=%d(%s)\n",<br>
>           getpid(),symlink1,errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (mkdir(dir1,S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP) == -1) {<br>
>     fprintf(stderr,"pid %d: mkdir() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
>   if (rmdir(dir1) == -1) {<br>
>     fprintf(stderr,"pid %d: rmdir() returned error, errno=%d(%s)\n",<br>
>           getpid(),errno,strerror(errno));<br>
>     exit(1);<br>
>   }<br>
><br>
>   /* Fork every 10000 iterations to not use up process resources too quickly */<br>
>   if ( (iters % 10000) == 0) {<br>
>     pid = fork();<br>
>     if(pid == 0) {<br>
>       fprintf(stderr,"child pid %d: fork!\n",getpid());<br>
>       // child<br>
>       args[0] = "/bin/ls";<br>
>       args[1] = NULL;<br>
>       close(1);<br>
>       close(2);<br>
>       execve(args[0], args, NULL);<br>
>       fprintf(stderr,"pid %d: execve(%s) returned error, errno=%d(%s)\n",<br>
>             getpid(),args[0],errno,strerror(errno));<br>
>       _exit(1);<br>
>     } else if (pid < 0) {<br>
>       fprintf(stderr,"pid %d: fork() returned error, errno=%d(%s)\n",<br>
>             getpid(),errno,strerror(errno));<br>
>       exit(1);<br>
>     } else {<br>
>       fprintf(stderr,"parent pid %d, child pid: %d: fork!\n",getpid(),pid);<br>
>     }<br>
><br>
>     pid = vfork();<br>
>     if(pid == 0) {<br>
>       args[0] = "/bin/pwd";<br>
>       args[1] = NULL;<br>
>       close(1);<br>
>       close(2);<br>
>       execv(args[0], args);<br>
>       fprintf(stderr,"pid %d: execve(%s) returned error, errno=%d(%s)\n",<br>
>             getpid(),args[0],errno,strerror(errno));<br>
>       _exit(1);<br>
>     } else if (pid < 0) {<br>
>       fprintf(stderr,"pid %d: vfork() returned error, errno=%d(%s)\n",<br>
>             getpid(),errno,strerror(errno));<br>
>       exit(1);<br>
>     }<br>
>   }<br>
><br>
>   /* Make sure everything is cleaned up and deleted before returning */<br>
>   cleanup();<br>
><br>
> } /* create_load() */<br>
><br>
> void cleanup() {<br>
>   close(fd1);<br>
>   unlink(file1);<br>
>   unlink(file2);<br>
>   unlink(symlink1);<br>
>   unlink(dir1);<br>
>   return;<br>
> }<br>
<br>
> --<br>
> Linux-audit mailing list<br>
> <a href="mailto:Linux-audit@redhat.com">Linux-audit@redhat.com</a><br>
> <a href="https://www.redhat.com/mailman/listinfo/linux-audit" target="_blank">https://www.redhat.com/mailman/listinfo/linux-audit</a><br>
<br>
<br>
- RGB<br>
<br>
--<br>
Richard Guy Briggs <<a href="mailto:rbriggs@redhat.com">rbriggs@redhat.com</a>><br>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada<br>
Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635, Alt: <a href="tel:%2B1.613.693.0684x3545" value="+16136930684">+1.613.693.0684x3545</a><br>
</div></div><br>--<br>
Linux-audit mailing list<br>
<a href="mailto:Linux-audit@redhat.com">Linux-audit@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/linux-audit" target="_blank">https://www.redhat.com/mailman/listinfo/linux-audit</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Please Donate to <a href="http://www.wikipedia.org">www.wikipedia.org</a></div>
</div>