summaryrefslogtreecommitdiffhomepage
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
commit0aaeecab435c4d89a67e58db729c7acfef4c0e5a (patch)
tree83092156e73a654064d3bbbedd3f9ed886e09cd7
parenta2e40a5e2886955add016c45cff948bebbd712dc (diff)
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. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-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;