svn commit: r366852 - head/sys/opencrypto

John Baldwin jhb at FreeBSD.org
Mon Oct 19 20:04:04 UTC 2020


Author: jhb
Date: Mon Oct 19 20:04:03 2020
New Revision: 366852
URL: https://svnweb.freebsd.org/changeset/base/366852

Log:
  Fix a couple of bugs for asym crypto introduced in r359374.
  
  - Check for null pointers in the crypto_drivers[] array when checking
    for empty slots in crypto_select_kdriver().
  
  - Handle the case where crypto_kdone() is invoked on a request where
    krq_cap is NULL due to not finding a matching driver.
  
  Reviewed by:	markj
  Sponsored by:	Chelsio Communications
  Differential Revision:	https://reviews.freebsd.org/D26811

Modified:
  head/sys/opencrypto/crypto.c

Modified: head/sys/opencrypto/crypto.c
==============================================================================
--- head/sys/opencrypto/crypto.c	Mon Oct 19 19:51:03 2020	(r366851)
+++ head/sys/opencrypto/crypto.c	Mon Oct 19 20:04:03 2020	(r366852)
@@ -1540,7 +1540,7 @@ again:
 		 * match), then skip.
 		 */
 		cap = crypto_drivers[hid];
-		if (cap->cc_dev == NULL ||
+		if (cap == NULL ||
 		    (cap->cc_flags & match) == 0)
 			continue;
 
@@ -1880,15 +1880,18 @@ crypto_kdone(struct cryptkop *krp)
 
 	if (krp->krp_status != 0)
 		CRYPTOSTAT_INC(cs_kerrs);
-	CRYPTO_DRIVER_LOCK();
 	cap = krp->krp_cap;
-	KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0"));
-	cap->cc_koperations--;
-	if (cap->cc_koperations == 0 && cap->cc_flags & CRYPTOCAP_F_CLEANUP)
-		wakeup(cap);
-	CRYPTO_DRIVER_UNLOCK();
-	krp->krp_cap = NULL;
-	cap_rele(cap);
+	if (cap != NULL) {
+		CRYPTO_DRIVER_LOCK();
+		KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0"));
+		cap->cc_koperations--;
+		if (cap->cc_koperations == 0 &&
+		    cap->cc_flags & CRYPTOCAP_F_CLEANUP)
+			wakeup(cap);
+		CRYPTO_DRIVER_UNLOCK();
+		krp->krp_cap = NULL;
+		cap_rele(cap);
+	}
 
 	ret_worker = CRYPTO_RETW(0);
 


More information about the svn-src-head mailing list