hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/crypto/scompress.c
....@@ -24,6 +24,7 @@
2424 #include <linux/cryptouser.h>
2525 #include <net/netlink.h>
2626 #include <linux/scatterlist.h>
27
+#include <linux/locallock.h>
2728 #include <crypto/scatterwalk.h>
2829 #include <crypto/internal/acompress.h>
2930 #include <crypto/internal/scompress.h>
....@@ -34,6 +35,7 @@
3435 static void * __percpu *scomp_dst_scratches;
3536 static int scomp_scratch_users;
3637 static DEFINE_MUTEX(scomp_lock);
38
+static DEFINE_LOCAL_IRQ_LOCK(scomp_scratches_lock);
3739
3840 #ifdef CONFIG_NET
3941 static int crypto_scomp_report(struct sk_buff *skb, struct crypto_alg *alg)
....@@ -146,7 +148,7 @@
146148 void **tfm_ctx = acomp_tfm_ctx(tfm);
147149 struct crypto_scomp *scomp = *tfm_ctx;
148150 void **ctx = acomp_request_ctx(req);
149
- const int cpu = get_cpu();
151
+ const int cpu = local_lock_cpu(scomp_scratches_lock);
150152 u8 *scratch_src = *per_cpu_ptr(scomp_src_scratches, cpu);
151153 u8 *scratch_dst = *per_cpu_ptr(scomp_dst_scratches, cpu);
152154 int ret;
....@@ -181,7 +183,7 @@
181183 1);
182184 }
183185 out:
184
- put_cpu();
186
+ local_unlock_cpu(scomp_scratches_lock);
185187 return ret;
186188 }
187189