Skip to content

Commit 2974725

Browse files
minipli-osszx2c4
authored andcommitted
compat: account for grsecurity backports and changes
grsecurity kernels tend to carry additional backports and changes, like commit b60b87fc2996 ("netlink: add ethernet address policy types") or the SYM_FUNC_* changes. RAP nowadays hooks the latter, therefore no diversion to RAP_ENTRY is needed any more. Instead of relying on the kernel version test, also test for the macros we're about to define to not already be defined to account for these additional changes in the grsecurity patch without breaking compatibility to the older public ones. Also test for CONFIG_PAX instead of RAP_PLUGIN for the timer API related changes as these don't depend on the RAP plugin to be enabled but just a PaX/grsecurity patch to be applied. While there is no preprocessor knob for the latter, use CONFIG_PAX as this will likely be enabled in every kernel that uses the patch. Signed-off-by: Mathias Krause <minipli@grsecurity.net> [zx2c4: small changes to include a header nearby a macro def test] Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 50dda8c commit 2974725

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/compat/compat-asm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif
2323

2424
/* PaX compatibility */
25-
#if defined(RAP_PLUGIN)
25+
#if defined(RAP_PLUGIN) && defined(RAP_ENTRY)
2626
#undef ENTRY
2727
#define ENTRY RAP_ENTRY
2828
#endif
@@ -51,7 +51,7 @@
5151
#undef pull
5252
#endif
5353

54-
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 76) && !defined(ISCENTOS8S)
54+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 76) && !defined(ISCENTOS8S) && !defined(SYM_FUNC_START)
5555
#define SYM_FUNC_START ENTRY
5656
#define SYM_FUNC_END ENDPROC
5757
#endif

src/compat/compat.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,16 @@ static inline void skb_mark_not_on_list(struct sk_buff *skb)
831831
#endif
832832

833833
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) && !defined(ISRHEL8)
834+
#include <net/netlink.h>
835+
#ifndef NLA_POLICY_EXACT_LEN
834836
#define NLA_POLICY_EXACT_LEN(_len) { .type = NLA_UNSPEC, .len = _len }
835837
#endif
838+
#endif
836839
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) && !defined(ISRHEL8)
840+
#include <net/netlink.h>
841+
#ifndef NLA_POLICY_MIN_LEN
837842
#define NLA_POLICY_MIN_LEN(_len) { .type = NLA_UNSPEC, .len = _len }
843+
#endif
838844
#define COMPAT_CANNOT_INDIVIDUAL_NETLINK_OPS_POLICY
839845
#endif
840846

@@ -1127,7 +1133,7 @@ static const struct header_ops ip_tunnel_header_ops = { .parse_protocol = ip_tun
11271133
#undef __read_mostly
11281134
#define __read_mostly
11291135
#endif
1130-
#if (defined(RAP_PLUGIN) || defined(CONFIG_CFI_CLANG)) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
1136+
#if (defined(CONFIG_PAX) || defined(CONFIG_CFI_CLANG)) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
11311137
#include <linux/timer.h>
11321138
#define wg_expired_retransmit_handshake(a) wg_expired_retransmit_handshake(unsigned long timer)
11331139
#define wg_expired_send_keepalive(a) wg_expired_send_keepalive(unsigned long timer)

0 commit comments

Comments
 (0)