Skip to content

Commit fcf23dc

Browse files
authored
Merge pull request #10357 from sameehj/km-fixes
Km fixes
2 parents 4b00525 + 75dc3e1 commit fcf23dc

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

bsdkm/wolfkmod.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,8 @@ static int wolfkdriv_process(device_t dev, struct cryptop * crp, int hint)
10201020
csp->csp_mode, csp->csp_cipher_alg, error);
10211021
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
10221022

1023-
return (error);
1023+
/* opencrypto(9) contract: return 0 after crypto_done(); error is in crp_etype. */
1024+
return (0);
10241025
}
10251026

10261027
/*

linuxkm/linuxkm_wc_port.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@
450450
#define memset my_memset
451451

452452
static inline void *my_memmove(void *dest, const void *src, size_t n) {
453+
if (n == 0)
454+
return dest;
453455
if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n)
454456
& (uintptr_t)(sizeof(uintptr_t) - 1)))
455457
{

linuxkm/x86_vector_register_glue.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,22 @@ static struct wc_thread_fpu_count_ent *wc_linuxkm_fpu_state_assoc_unlikely(int c
162162
__atomic_store_n(&slot->pid, my_pid, __ATOMIC_RELEASE);
163163
return slot;
164164
} else {
165+
struct pid *slot_pid_struct;
166+
165167
/* if the slot is already occupied, that can be benign-ish due to a
166168
* unwanted migration, or due to a process crashing in kernel mode.
167169
* it will require fixup either here, or by the thread that owns the
168170
* slot, which will happen when it releases its lock.
169171
*/
170-
if (find_get_pid(slot_pid) == NULL) {
172+
slot_pid_struct = find_get_pid(slot_pid);
173+
if (slot_pid_struct == NULL) {
171174
if (__atomic_compare_exchange_n(&slot->pid, &slot_pid, my_pid, 0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) {
172175
pr_warn("WARNING: wc_linuxkm_fpu_state_assoc_unlikely fixed up orphaned slot on CPU %d owned by dead PID %d.\n", my_cpu, slot_pid);
173176
return slot;
174177
}
178+
} else {
179+
/* drop the refcount bumped by find_get_pid(). */
180+
put_pid(slot_pid_struct);
175181
}
176182

177183
{

0 commit comments

Comments
 (0)