pdig build failure (works with older version of libs)
Describe the bug
Cannot build pdig. After running the commands to build pdig, it fails.
How to reproduce it
Start an ubuntu machine and run the following commands:
apt install cmake -y
git clone https://github.com/falcosecurity/pdig
git clone https://github.com/falcosecurity/libs
cd pdig
mkdir -p build
cd build
cmake ..
make
Expected behaviour
It should compile the library.
Environment
GCP with Ubuntu 20.04 (did not test others).
Solution
I was able to solve the issue by using a specific libs version. So instead of simply cloning libs I did:
git clone https://github.com/falcosecurity/libs
cd libs && git checkout 9768501685867b2701ea196eb52a8ace9be3d3e1 && cd -
Additional context
If I try to use pdig with Falco 0.31.1, I get the following error:
Mar 25 10:21:44 server kernel: [ 1388.678702] falco: starting capture
Mar 25 10:21:44 server kernel: [ 1388.679198] falco: deallocating consumer 00000000589a3ad1
Mar 25 10:21:44 server kernel: [ 1388.694872] falco: no more consumers, stopping capture
Mar 25 10:21:44 server falco: Runtime error: Kernel module does not support PPM_IOCTL_GET_API_VERSION. Exiting.
However, if I use Falco 0.31.0, it works just fine.
pdig compilation error:
[ 6%] Building C object CMakeFiles/pdig.dir/udig_procs.c.o
/root/pdig/udig_procs.c: In function ‘udig_proc_startupdate’:
/root/pdig/udig_procs.c:496:40: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 252 [-Wformat-truncation=]
496 | snprintf(filename, sizeof(filename), "%sexe", dir_name);
| ^~ ~~~~~~~~
In file included from /usr/include/stdio.h:867,
from /root/pdig/udig_procs.c:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 4 and 259 bytes into a destination of size 252
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/pdig/udig_procs.c:529:40: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 252 [-Wformat-truncation=]
529 | snprintf(filename, sizeof(filename), "%sstatus", dir_name);
| ^~ ~~~~~~~~
In file included from /usr/include/stdio.h:867,
from /root/pdig/udig_procs.c:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 7 and 262 bytes into a destination of size 252
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/pdig/udig_procs.c:556:40: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 252 [-Wformat-truncation=]
556 | snprintf(filename, sizeof(filename), "%scmdline", dir_name);
| ^~ ~~~~~~~~
In file included from /usr/include/stdio.h:867,
from /root/pdig/udig_procs.c:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 8 and 263 bytes into a destination of size 252
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/pdig/udig_procs.c:579:46: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 1024 [-Wformat-truncation=]
579 | snprintf(tinfo->exe, SCAP_MAX_PATH_SIZE, "%s", line);
| ^~ ~~~~
In file included from /usr/include/stdio.h:867,
from /root/pdig/udig_procs.c:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin_snprintf’ output between 1 and 4096 bytes into a destination of size 1024
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/pdig/udig_procs.c:603:40: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 252 [-Wformat-truncation=]
603 | snprintf(filename, sizeof(filename), "%senviron", dir_name);
| ^~ ~~~~~~~~
In file included from /usr/include/stdio.h:867,
from /root/pdig/udig_procs.c:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 8 and 263 bytes into a destination of size 252
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 12%] Building C object CMakeFiles/pdig.dir/root/libs/driver/dynamic_params_table.c.o
[ 18%] Building C object CMakeFiles/pdig.dir/root/libs/driver/event_table.c.o
[ 25%] Building C object CMakeFiles/pdig.dir/root/libs/driver/flags_table.c.o
[ 31%] Building C object CMakeFiles/pdig.dir/root/libs/driver/ppm_events.c.o
/root/libs/driver/ppm_events.c: In function ‘parse_readv_writev_bufs’:
/root/libs/driver/ppm_events.c:1366:15: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1366 | args->fd = (int)val;
| ^~~~~~~~
[ 37%] Building C object CMakeFiles/pdig.dir/root/libs/driver/ppm_fillers.c.o
/root/libs/driver/ppm_fillers.c: In function ‘f_sys_socketpair_x’:
/root/libs/driver/ppm_fillers.c:1630:15: warning: unused variable ‘speer’ [-Wunused-variable]
1630 | struct sock *speer;
| ^~~~~
/root/libs/driver/ppm_fillers.c:1629:20: warning: unused variable ‘us’ [-Wunused-variable]
1629 | struct unix_sock *us;
| ^~
/root/libs/driver/ppm_fillers.c:1628:17: warning: unused variable ‘sock’ [-Wunused-variable]
1628 | struct socket *sock;
| ^~~~
/root/libs/driver/ppm_fillers.c:1627:6: warning: unused variable ‘err’ [-Wunused-variable]
1627 | int err;
| ^~~
/root/libs/driver/ppm_fillers.c:1626:6: warning: unused variable ‘fds’ [-Wunused-variable]
1626 | int fds[2];
| ^~~
/root/libs/driver/ppm_fillers.c:1625:16: warning: unused variable ‘val’ [-Wunused-variable]
1625 | unsigned long val;
| ^~~
/root/libs/driver/ppm_fillers.c: In function ‘f_sys_accept_x’:
/root/libs/driver/ppm_fillers.c:2008:17: warning: unused variable ‘sock’ [-Wunused-variable]
2008 | struct socket *sock;
| ^~~~
/root/libs/driver/ppm_fillers.c:2007:6: warning: unused variable ‘err’ [-Wunused-variable]
2007 | int err = 0;
| ^~~
/root/libs/driver/ppm_fillers.c: In function ‘f_sys_pipe_x’:
/root/libs/driver/ppm_fillers.c:2847:15: warning: unused variable ‘file’ [-Wunused-variable]
2847 | struct file *file;
| ^~~~
/root/libs/driver/ppm_fillers.c: In function ‘f_sys_open_by_handle_at_x’:
/root/libs/driver/ppm_fillers.c:4921:10: warning: implicit declaration of function ‘fget’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
4921 | file = fget(retval);
| ^~~~
| fgets
/root/libs/driver/ppm_fillers.c:4921:8: warning: assignment to ‘struct file *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
4921 | file = fget(retval);
| ^
/root/libs/driver/ppm_fillers.c:4928:14: warning: implicit declaration of function ‘d_path’ [-Wimplicit-function-declaration]
4928 | pathname = d_path(&file->f_path, buf, PAGE_SIZE);
| ^~~~~~
/root/libs/driver/ppm_fillers.c:4928:26: error: dereferencing pointer to incomplete type ‘struct file’
4928 | pathname = d_path(&file->f_path, buf, PAGE_SIZE);
| ^~
/root/libs/driver/ppm_fillers.c: In function ‘f_sys_capset_x’:
/root/libs/driver/ppm_fillers.c:6163:9: warning: implicit declaration of function ‘get_current_cred’; did you mean ‘get_current_dir_name’? [-Wimplicit-function-declaration]
6163 | cred = get_current_cred();
| ^~~~~~~~~~~~~~~~
| get_current_dir_name
/root/libs/driver/ppm_fillers.c:6163:7: warning: assignment to ‘const struct cred *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
6163 | cred = get_current_cred();
| ^
/root/libs/driver/ppm_fillers.c:6165:23: error: dereferencing pointer to incomplete type ‘const struct cred’
6165 | val = ((uint64_t)cred->cap_inheritable.cap[1] << 32) | cred->cap_inheritable.cap[0];
| ^~
/root/libs/driver/ppm_fillers.c:6180:2: warning: implicit declaration of function ‘put_cred’ [-Wimplicit-function-declaration]
6180 | put_cred(cred);
| ^~~~~~~~
make[2]: *** [CMakeFiles/pdig.dir/build.make:206: CMakeFiles/pdig.dir/root/libs/driver/ppm_fillers.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/pdig.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/falcosecurity/community.
/lifecycle stale
/remove-lifecycle stale