aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-08-06 01:01:32 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-08-06 01:01:32 +0200
commit389acbdc03e9d97b05307d496b78e3468d076830 (patch)
tree9edbae623d407cb4870c5fdfd36ccc7349cbc6a9 /src/compat
parenttimers: do not send out double keepalive (diff)
downloadwireguard-monolithic-historical-389acbdc03e9d97b05307d496b78e3468d076830.tar.xz
wireguard-monolithic-historical-389acbdc03e9d97b05307d496b78e3468d076830.zip
compat: support grsecurity with our compat padata implementation
Some SMP kernels don't have PADATA enabled, which means we actually ship our own copy of it, lifted right out of the kernel. This is completely insane and stupid, but so it goes with really grotesque "compat/" layers such as this one. What this amounts to is having to make this upstream file compile on all kernels back to 3.10. Ouch. It also means making it compile with whatever other kernels people are using, such as Grsecurity. This patch _should_ make this part of the compat layer work with Grsecurity, but unfortunately I really have no way of knowing, since I don't actually have access to their source code. I assume, though, if this doesn't work, I'll receive more complaints and will take another stab in the dark. The general situation saddens me, as I really liked that project and wish I could still play with it. Alas. Fortunately this entire problem with padata will go away, anyway, when we stop using padata, and move to a better form of multicore processing. But for now, we add this to work around the issue.
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/padata/padata.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/compat/padata/padata.c b/src/compat/padata/padata.c
index 25836db..ece0ec7 100644
--- a/src/compat/padata/padata.c
+++ b/src/compat/padata/padata.c
@@ -59,7 +59,11 @@ static int padata_cpu_hash(struct parallel_data *pd)
pd->seq_nr++;
spin_unlock(&pd->seq_lock);
#else
+#ifdef CONFIG_PAX_REFCOUNT
+ unsigned int seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
+#else
unsigned int seq_nr = atomic_inc_return(&pd->seq_nr);
+#endif
cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
#endif
@@ -427,8 +431,12 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
pd->seq_nr = 0;
#else
+#ifdef CONFIG_PAX_REFCOUNT
+ atomic_set_unchecked(&pd->seq_nr, -1);
+#else
atomic_set(&pd->seq_nr, -1);
#endif
+#endif
atomic_set(&pd->reorder_objects, 0);
atomic_set(&pd->refcnt, 0);
pd->pinst = pinst;