Skip to content

Commit

Permalink
ROX-5396 - Fix probe compilation on 5.7-5.10 kernels (#21)
Browse files Browse the repository at this point in the history
Adapt upstream sysdig changes (draios/sysdig#1621 and draios/sysdig#1672) to fix compile errors on due to timespec / timeval and kernel module compilation on 5.8
# Conflicts:
#	driver/bpf/fillers.h
#	driver/kernel_hacks.h
#	driver/main.c
#	driver/ppm.h
#	driver/ppm_fillers.c
  • Loading branch information
robbycochran authored and Molter73 committed Sep 17, 2021
1 parent 42b556a commit 198a1d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions driver/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ KERNELDIR ?= /lib/modules/$(shell uname -r)/build
ifeq ($(shell grep -sq "^\s*struct\s\+audit_task_info\s\+\*audit;\s*$$" $(KERNELDIR)/include/linux/sched.h ; echo $$? ), 0)
KBUILD_CPPFLAGS+= -DCOS_73_WORKAROUND
endif
# clang-7 does not support -fmacro-prefix-map
KBUILD_CPPFLAGS:=$(filter-out -fmacro-prefix-map=%,$(KBUILD_CPPFLAGS))
# End StackRox

all:
Expand Down
10 changes: 4 additions & 6 deletions driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int record_event_consumer_for(struct task_struct *task,
struct ppm_consumer_t *consumer,
enum ppm_event_type event_type,
enum syscall_flags drop_flags,
struct timespec *ts,
nanoseconds ns,
struct event_data_t *event_datap);

static void record_event_all_consumers_for(struct task_struct* task,
Expand Down Expand Up @@ -1934,15 +1934,13 @@ static void record_event_all_consumers_for(struct task_struct* task, enum ppm_ev
struct event_data_t *event_datap)
{
struct ppm_consumer_t *consumer;
nanoseconds ns;
nanoseconds ns = ppm_nsecs();

/* Begin StackRox section */
/* Moved this from record_event_consumers_for */
if (!test_bit(event_type, g_events_mask)) return;
/* End StackRox section */

ns = ppm_nsecs();

rcu_read_lock();
list_for_each_entry_rcu(consumer, &g_consumer_list, node) {
record_event_consumer_for(task, consumer, event_type, drop_flags, ns, event_datap);
Expand Down Expand Up @@ -2301,10 +2299,10 @@ static int record_event_consumer_for(struct task_struct* task,
static int record_event_consumer(struct ppm_consumer_t *consumer,
enum ppm_event_type event_type,
enum syscall_flags drop_flags,
struct timespec *ts,
nanoseconds ns,
struct event_data_t *event_datap)
{
return record_event_consumer_for(current, consumer, event_type, drop_flags, ts, event_datap);
return record_event_consumer_for(current, consumer, event_type, drop_flags, ns, event_datap);
}

/* End StackRox Section */
Expand Down
7 changes: 3 additions & 4 deletions driver/ppm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ or GPL2.txt for full copies of the license.
#define ASSERT(expr)
#endif

#include <linux/time.h>
typedef u64 nanoseconds;

/* Begin StackRox Section */
#include <linux/pid_namespace.h>
Expand Down Expand Up @@ -148,8 +148,7 @@ extern const enum ppm_syscall_code g_syscall_ia32_code_routing_table[];
extern void ppm_syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args);
#endif

#define NS_TO_SEC(_ns) ((_ns) / 1000000000)
#define MORE_THAN_ONE_SECOND_AHEAD(_ns1, _ns2) ((_ns1) - (_ns2) > 1000000000)
#define SECOND_IN_NS 1000000000

#define NS_TO_SEC(_ns) ((_ns) / SECOND_IN_NS)
#define MORE_THAN_ONE_SECOND_AHEAD(_ns1, _ns2) ((_ns1) - (_ns2) > SECOND_IN_NS)
#endif /* PPM_H_ */

0 comments on commit 198a1d6

Please sign in to comment.