All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: linux-audit@redhat.com
Subject: Re: open record looks like openat
Date: Fri, 27 Jul 2007 10:59:12 -0400	[thread overview]
Message-ID: <200707271059.12571.sgrubb@redhat.com> (raw)
In-Reply-To: <ogtps2eym2e.fsf@oolong.mitre.org>

On Friday 27 July 2007 10:10:17 John D. Ramsdell wrote:
> Notice this event has two PATH records, whereas all of the many other
> open events I studied in my logs have one PATH record.  It's as if the
> open system call can behave as the openat system call.  I changed my
> analysis program to use the last PATH record to find the file name, so
> that the same code can be used to analyze open and openat system
> calls.

But openat does give a different output:

type=PATH msg=audit(07/27/2007 10:42:17.954:153) : item=0 name=test inode=6131 
dev=08:06 mode=file,sgid,451 ouid=root ogid=root rdev=00:00 
obj=user_u:object_r:tmp_t:s0 
type=CWD msg=audit(07/27/2007 10:42:17.954:153) :  cwd=/root 
type=SYSCALL msg=audit(07/27/2007 10:42:17.954:153) : arch=i386 syscall=openat 
success=yes exit=4 a0=3 a1=80485d5 a2=42 a3=8048529 items=1 ppid=6310 
pid=6312 auid=sgrubb uid=root gid=root euid=root suid=root fsuid=root 
egid=root sgid=root fsgid=root tty=pts0 comm=test 
exe=/home/sgrubb/test/openat/test subj=user_u:system_r:unconfined_t:s0 
key=(null)

Now, the out put changes if I do not include <sys/stat.h> and do not define  
__USE_ATFILE !  When I compile the test program I get a warning: implicit 
declaration of function ‘openat’. Low and behold the record changes to this:

type=PATH msg=audit(07/27/2007 10:33:59.030:81) : item=1 name=test inode=6131 
dev=08:06 mode=file,sgid,451 ouid=root ogid=root rdev=00:00 
obj=user_u:object_r:tmp_t:s0 
type=PATH msg=audit(07/27/2007 10:33:59.030:81) : item=0  name=/root inode=2 
dev=08:06 mode=dir,sticky,777 ouid=root ogid=root rdev=00:00 
obj=system_u:object_r:tmp_t:s0 
type=CWD msg=audit(07/27/2007 10:33:59.030:81) :  cwd=/root 
type=SYSCALL msg=audit(07/27/2007 10:33:59.030:81) : arch=i386 syscall=openat 
success=yes exit=4 a0=3 a1=80485d5 a2=42 a3=8048529 items=2 ppid=4148 
pid=4150 auid=sgrubb uid=root gid=root euid=root suid=root fsuid=root 
egid=root sgid=root fsgid=root tty=pts0 comm=test 
exe=/home/sgrubb/test/openat/test subj=user_u:system_r:unconfined_t:s0 
key=(null) 

The call in both cases was this:

int main(void)
{
        int dir_fd, fd;
        DIR *d = opendir("/tmp");
        dir_fd = dirfd(d);
        fd = openat(dir_fd, "test", O_CREAT|O_RDWR);
        close (fd);
        closedir(d);

        return 0;
}

In neither record for openat did I get the "/tmp" directory which I thought I 
should get. I don't understand why it mutates between the two forms, nor do I 
get what I think I should. I suspect the *at functions should have the 
referenced directory recorded just as open records the cwd so paths can be 
reassembled. It seems like we need a AUDIT_DIR aux record for path recreation 
when something relative is used as in the example program.

Any kernel people want to chime in?

-Steve

  reply	other threads:[~2007-07-27 14:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 20:21 audit 1.5.6 released Steve Grubb
2007-07-27 12:25 ` [PATCH] Add auparse_version John D. Ramsdell
2007-07-27 14:10 ` open record looks like openat John D. Ramsdell
2007-07-27 14:59   ` Steve Grubb [this message]
2007-07-27 15:15     ` John D. Ramsdell
2007-07-27 17:41   ` Wieprecht, Karen M.
2007-07-27 17:57     ` John D. Ramsdell
2007-07-27 18:14   ` John D. Ramsdell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200707271059.12571.sgrubb@redhat.com \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.