diff -Nru sysdig-0.26.4/debian/changelog sysdig-0.26.4/debian/changelog --- sysdig-0.26.4/debian/changelog 2019-10-15 04:50:22.000000000 +0200 +++ sysdig-0.26.4/debian/changelog 2020-10-27 17:49:22.000000000 +0100 @@ -1,3 +1,11 @@ +sysdig (0.26.4-1ubuntu1) focal; urgency=medium + + * Fix build with Linux >= 5.6 (LP: #1901734) + - 0001-Linux-5.6-timespec-changes.patch + - 0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch + + -- Kleber Sacilotto de Souza Tue, 27 Oct 2020 17:49:22 +0100 + sysdig (0.26.4-1) unstable; urgency=medium * New upstream version 0.26.4 (Closes: #927418) diff -Nru sysdig-0.26.4/debian/patches/0001-Linux-5.6-timespec-changes.patch sysdig-0.26.4/debian/patches/0001-Linux-5.6-timespec-changes.patch --- sysdig-0.26.4/debian/patches/0001-Linux-5.6-timespec-changes.patch 1970-01-01 01:00:00.000000000 +0100 +++ sysdig-0.26.4/debian/patches/0001-Linux-5.6-timespec-changes.patch 2020-10-27 17:49:22.000000000 +0100 @@ -0,0 +1,286 @@ +Subject: [PATCH] Fix compile errors on Linux 5.6 due to timespec / timeval + +Several changes have been introduced on Linux 5.6 to fix the y2038 +issue, including making 'struct timespec' obsolete. + +OriginalAuthor: Nathan Baker +(backported from commit 938986890291c126f9b8f3a050bc3edc95fb6f5a https://github.com/draios/sysdig.git) +[ klebers: kept the include to linux/time.h to prevent compilation + warnings. ] +Signed-off-by: Kleber Sacilotto de Souza +--- a/driver/ppm_fillers.c ++++ b/driver/ppm_fillers.c +@@ -47,6 +47,30 @@ + #include + #endif + ++/* ++ * Linux 5.6 kernels no longer include the old 32-bit timeval ++ * structures. But the syscalls (might) still use them. ++ */ ++#include ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++struct compat_timespec { ++ int32_t tv_sec; ++ int32_t tv_nsec; ++}; ++ ++struct timespec { ++ int32_t tv_sec; ++ int32_t tv_nsec; ++}; ++ ++struct timeval { ++ int32_t tv_sec; ++ int32_t tv_usec; ++}; ++#else ++#define timeval64 timeval ++#endif ++ + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) + static inline struct inode *file_inode(struct file *f) + { +@@ -1347,6 +1371,7 @@ + uint64_t val64; + struct timeval tv; + } u; ++ nanoseconds ns = 0; + + if (level == SOL_SOCKET) { + switch (optname) { +@@ -1363,9 +1388,12 @@ + #ifdef SO_SNDTIMEO + case SO_SNDTIMEO: + #endif +- if (unlikely(ppm_copy_from_user(&u.tv, optval, sizeof(u.tv)))) ++ ASSERT(optlen == sizeof(struct timeval)); ++ if (unlikely(ppm_copy_from_user(&u.tv, optval, sizeof(u.tv)))) { + return PPM_FAILURE_INVALID_USER_MEMORY; +- return val_to_ring(args, u.tv.tv_sec * 1000000000 + u.tv.tv_usec * 1000, 0, false, PPM_SOCKOPT_IDX_TIMEVAL); ++ } ++ ns = u.tv.tv_sec * second_in_ns + u.tv.tv_usec * 1000; ++ return val_to_ring(args, ns, 0, false, PPM_SOCKOPT_IDX_TIMEVAL); + + #ifdef SO_COOKIE + case SO_COOKIE: +@@ -2707,7 +2735,7 @@ + #ifdef CONFIG_COMPAT + if (!args->compat) { + #endif +- cfulen = (int)ppm_copy_from_user(targetbuf, (void __user *)val, sizeof(struct timespec)); ++ cfulen = (int)ppm_copy_from_user(targetbuf, (void __user *)val, sizeof(*tts)); + if (unlikely(cfulen != 0)) + return PPM_FAILURE_INVALID_USER_MEMORY; + +--- a/driver/ppm.h ++++ b/driver/ppm.h +@@ -22,6 +22,7 @@ + #endif + + #include ++typedef u64 nanoseconds; + + /* + * Global defines +@@ -50,7 +51,7 @@ + bool capture_enabled; + struct ppm_ring_buffer_info *info; + char *buffer; +- struct timespec last_print_time; ++ nanoseconds last_print_time; + u32 nevents; + atomic_t preempt_count; + char *str_storage; /* String storage. Size is one page. */ +@@ -116,4 +117,10 @@ + + extern void ppm_syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args); + ++extern nanoseconds ppm_nsecs(void); ++ ++#define ns_to_sec(_ns) ((_ns) / 1000000000) ++#define more_than_one_second_ahead(_ns1, _ns2) ((_ns1) - (_ns2) > 1000000000) ++#define second_in_ns 1000000000 ++ + #endif /* PPM_H_ */ +--- a/driver/main.c ++++ b/driver/main.c +@@ -117,7 +117,7 @@ + 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); + static void record_event_all_consumers(enum ppm_event_type event_type, + enum syscall_flags drop_flags, +@@ -216,6 +216,11 @@ + pr_info(fmt, ##__VA_ARGS__); \ + } while (0) + ++nanoseconds ppm_nsecs(void) ++{ ++ return ktime_get_real_ns(); ++} ++ + inline void ppm_syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args) + { + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)) +@@ -823,7 +828,6 @@ + case PPM_IOCTL_DISABLE_DROPPING_MODE: + { + struct event_data_t event_data; +- struct timespec ts; + + vpr_info("PPM_IOCTL_DISABLE_DROPPING_MODE, consumer %p\n", consumer_id); + +@@ -835,12 +839,11 @@ + * Push an event into the ring buffer so that the user can know that dropping + * mode has been disabled + */ +- getnstimeofday(&ts); + event_data.category = PPMC_CONTEXT_SWITCH; + event_data.event_info.context_data.sched_prev = (void *)DEI_DISABLE_DROPPING; + event_data.event_info.context_data.sched_next = (void *)0; + +- record_event_consumer(consumer, PPME_SYSDIGEVENT_E, UF_NEVER_DROP, &ts, &event_data); ++ record_event_consumer(consumer, PPME_SYSDIGEVENT_E, UF_NEVER_DROP, ppm_nsecs(), &event_data); + + ret = 0; + goto cleanup_ioctl; +@@ -1389,11 +1392,11 @@ + } + #endif /* _HAS_SOCKETCALL */ + +-static inline void record_drop_e(struct ppm_consumer_t *consumer, struct timespec *ts) ++static inline void record_drop_e(struct ppm_consumer_t *consumer, nanoseconds ns) + { + struct event_data_t event_data = {0}; + +- if (record_event_consumer(consumer, PPME_DROP_E, UF_NEVER_DROP, ts, &event_data) == 0) { ++ if (record_event_consumer(consumer, PPME_DROP_E, UF_NEVER_DROP, ns, &event_data) == 0) { + consumer->need_to_insert_drop_e = 1; + } else { + if (consumer->need_to_insert_drop_e == 1) +@@ -1403,11 +1406,11 @@ + } + } + +-static inline void record_drop_x(struct ppm_consumer_t *consumer, struct timespec *ts) ++static inline void record_drop_x(struct ppm_consumer_t *consumer, nanoseconds ns) + { + struct event_data_t event_data = {0}; + +- if (record_event_consumer(consumer, PPME_DROP_X, UF_NEVER_DROP, ts, &event_data) == 0) { ++ if (record_event_consumer(consumer, PPME_DROP_X, UF_NEVER_DROP, ns, &event_data) == 0) { + consumer->need_to_insert_drop_x = 1; + } else { + if (consumer->need_to_insert_drop_x == 1) +@@ -1483,7 +1486,7 @@ + static inline int drop_event(struct ppm_consumer_t *consumer, + enum ppm_event_type event_type, + enum syscall_flags drop_flags, +- struct timespec *ts, ++ nanoseconds ns, + struct pt_regs *regs) + { + int maybe_ret = 0; +@@ -1505,10 +1508,11 @@ + return 1; + } + +- if (ts->tv_nsec >= consumer->sampling_interval) { ++ if (consumer->sampling_interval < second_in_ns && ++ (ns % second_in_ns) >= consumer->sampling_interval) { + if (consumer->is_dropping == 0) { + consumer->is_dropping = 1; +- record_drop_e(consumer, ts); ++ record_drop_e(consumer, ns); + } + + return 1; +@@ -1516,7 +1520,7 @@ + + if (consumer->is_dropping == 1) { + consumer->is_dropping = 0; +- record_drop_x(consumer, ts); ++ record_drop_x(consumer, ns); + } + } + +@@ -1528,13 +1532,11 @@ + struct event_data_t *event_datap) + { + struct ppm_consumer_t *consumer; +- struct timespec ts; +- +- getnstimeofday(&ts); ++ nanoseconds ns = ppm_nsecs(); + + rcu_read_lock(); + list_for_each_entry_rcu(consumer, &g_consumer_list, node) { +- record_event_consumer(consumer, event_type, drop_flags, &ts, event_datap); ++ record_event_consumer(consumer, event_type, drop_flags, ns, event_datap); + } + rcu_read_unlock(); + } +@@ -1545,7 +1547,7 @@ + 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) + { + int res = 0; +@@ -1568,11 +1570,11 @@ + + if (event_type != PPME_DROP_E && event_type != PPME_DROP_X) { + if (consumer->need_to_insert_drop_e == 1) +- record_drop_e(consumer, ts); ++ record_drop_e(consumer, ns); + else if (consumer->need_to_insert_drop_x == 1) +- record_drop_x(consumer, ts); ++ record_drop_x(consumer, ns); + +- if (drop_event(consumer, event_type, drop_flags, ts, ++ if (drop_event(consumer, event_type, drop_flags, ns, + event_datap->event_info.syscall_data.regs)) + return res; + } +@@ -1696,7 +1698,7 @@ + #ifdef PPM_ENABLE_SENTINEL + hdr->sentinel_begin = ring->nevents; + #endif +- hdr->ts = timespec_to_ns(ts); ++ hdr->ts = ns; + hdr->tid = current->pid; + hdr->type = event_type; + hdr->nparams = args.nargs; +@@ -1845,7 +1847,7 @@ + } + } + +- if (ts->tv_sec > ring->last_print_time.tv_sec + 1) { ++ if (more_than_one_second_ahead(ns, ring->last_print_time + 1)) { + vpr_info("consumer:%p CPU:%d, use:%d%%, ev:%llu, dr_buf:%llu, dr_pf:%llu, pr:%llu, cs:%llu\n", + consumer->consumer_id, + smp_processor_id(), +@@ -1856,7 +1858,7 @@ + ring_info->n_preemptions, + ring->info->n_context_switches); + +- ring->last_print_time = *ts; ++ ring->last_print_time = ns; + } + + atomic_dec(&ring->preempt_count); +@@ -2214,7 +2216,7 @@ + ring->info->n_drops_pf = 0; + ring->info->n_preemptions = 0; + ring->info->n_context_switches = 0; +- getnstimeofday(&ring->last_print_time); ++ ring->last_print_time = ppm_nsecs(); + } + + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) diff -Nru sysdig-0.26.4/debian/patches/0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch sysdig-0.26.4/debian/patches/0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch --- sysdig-0.26.4/debian/patches/0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch 1970-01-01 01:00:00.000000000 +0100 +++ sysdig-0.26.4/debian/patches/0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch 2020-10-27 17:49:22.000000000 +0100 @@ -0,0 +1,31 @@ +From 0123c82dec547a67449379fc6f03880d8fea3aa9 Mon Sep 17 00:00:00 2001 +From: Paolo Pisati +Date: Wed, 29 Jul 2020 11:23:37 +0000 +Subject: [PATCH] Linux 5.8: replace probe_kernel_read() with + copy_from_kernel_nofault() + +See also commit fe557319aa06c23cffc9346000f119547e0f289a "maccess: rename +probe_kernel_{read,write} to copy_{from,to}_kernel_nofault" upstream. + +Signed-off-by: Paolo Pisati +Signed-off-by: Kleber Sacilotto de Souza +--- + driver/ppm_fillers.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/driver/ppm_fillers.c b/driver/ppm_fillers.c +index d6f82b3..538b5f2 100644 +--- a/driver/ppm_fillers.c ++++ b/driver/ppm_fillers.c +@@ -666,6 +666,8 @@ long probe_kernel_read(void *dst, const void *src, size_t size) + + return ret ? -EFAULT : 0; + } ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++#define probe_kernel_read copy_from_kernel_nofault + #endif + + static int ppm_get_tty(void) +-- +2.27.0 + diff -Nru sysdig-0.26.4/debian/patches/series sysdig-0.26.4/debian/patches/series --- sysdig-0.26.4/debian/patches/series 2019-10-15 02:54:43.000000000 +0200 +++ sysdig-0.26.4/debian/patches/series 2020-10-27 17:49:22.000000000 +0100 @@ -1,2 +1,4 @@ fix-arm64-ftbfs.patch fix-luajit.patch +0001-Linux-5.6-timespec-changes.patch +0001-Linux-5.8-replace-probe_kernel_read-with-copy_from_k.patch