From f3b9cd8404bd301ed7f960952548b12b7bd7310a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 16 Sep 2021 20:20:02 +0900 Subject: [PATCH] bpf: Add workaround for ubuntu 20.04 --- bpf/reuseport_kern.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bpf/reuseport_kern.c b/bpf/reuseport_kern.c index 25e1102a..a012ee9a 100644 --- a/bpf/reuseport_kern.c +++ b/bpf/reuseport_kern.c @@ -24,6 +24,7 @@ */ #include #include +#include #include @@ -240,7 +241,16 @@ static void InvSubBytes(state_t *state) { __u8 i, j; for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) + /* Ubuntu 20.04 LTS kernel 5.4.0 needs this workaround otherwise + "math between map_value pointer and register with unbounded + min value is not allowed". 5.10.0 is a kernel version that + works but it might not be a minimum version. */ + __u8 k = (*state)[j][i]; + (*state)[j][i] = k ? getSBoxInvert(k) : getSBoxInvert(0); +#else /* !(LINUX_VERSION_CDOE < KERNEL_VERSION(5, 10, 0)) */ (*state)[j][i] = getSBoxInvert((*state)[j][i]); +#endif /* !(LINUX_VERSION_CDOE < KERNEL_VERSION(5, 10, 0)) */ } } }