Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O_CREAT flag missing in File Flow OpenFlags #108

Open
dcarolloz opened this issue Jul 4, 2023 · 1 comment
Open

O_CREAT flag missing in File Flow OpenFlags #108

dcarolloz opened this issue Jul 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@dcarolloz
Copy link

Indicate project
libsysflow

Describe the bug
File Flows OpenFlags sometimes do not report O_CREAT (64) flag

To reproduce
Steps to reproduce the behavior:

  1. Build and run sf-collector example
  2. create a file
  3. copy the file to a new file using cp

Expected behavior
OpenFlags should report O_CREAT flag usage. In the example, OpenFlags is expected to be > 64.

Environment:

  • OS: Ubuntu 20.04.4 LTS
  • kernel: 5.4.0-128-generic
  • SysFlow version: v0.5.1 (from master branch)
  • Configurations: eBPF driver

strace of cp execution

stat("newfile", 0x7fff362a3020)         = -1 ENOENT (No such file or directory)
stat("testfile", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
newfstatat(AT_FDCWD, "newfile", 0x7fff362a2db0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "testfile", O_RDONLY)  = 3
fstat(3, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
openat(AT_FDCWD, "newfile", O_WRONLY|O_CREAT|O_EXCL, 0664) = 4
fstat(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff6fdc3a000
read(3, "", 131072)                     = 0
close(4)                                = 0
close(3)                                = 0

sf-collector example log

****************************************************************
Header: Exporter , IP , File name 
Process: PID 18755 Creation Time, 1688466601525995515, Exe /usr/bin/cp, Exe Args testfile newfile, User Name vagrant, Group Name vagrant, TTY 1
File: Type 102, Path /home/vagrant/newfile
File Flow: TID 18755, OpFlags: 1152, OpenFlags 38, FD 4
****************************************************************
@dcarolloz dcarolloz added the bug Something isn't working label Jul 4, 2023
@gentooise
Copy link

We are now using the new PPM_O_F_CREATED to detect file creations, on our side we don't need this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants