Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/opencrypto fix: crypto_drivers[hid].cc_process() could b...



details:   https://anonhg.NetBSD.org/src/rev/de4de6f3a1da
branches:  trunk
changeset: 823823:de4de6f3a1da
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Wed May 10 09:45:51 2017 +0000

description:
fix: crypto_drivers[hid].cc_process() could be called even if it was null.

If a crypto driver is unregistered before calling cyrptointr(),
the crypto_drivers[hid].cc_process is null in spite of the hid
is less than crypto_drivers_num.

reffered to FreeBSD code.

diffstat:

 sys/opencrypto/crypto.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r 76ea2d713cca -r de4de6f3a1da sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Wed May 10 09:34:51 2017 +0000
+++ b/sys/opencrypto/crypto.c   Wed May 10 09:45:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.62 2017/05/10 03:26:33 knakahara Exp $ */
+/*     $NetBSD: crypto.c,v 1.63 2017/05/10 09:45:51 knakahara Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $   */
 /*     $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.62 2017/05/10 03:26:33 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.63 2017/05/10 09:45:51 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -970,12 +970,10 @@
 
        hid = CRYPTO_SESID2HID(crp->crp_sid);
 
-       if (hid < crypto_drivers_num) {
+       if ((crypto_drivers[hid].cc_flags & CRYPTOCAP_F_CLEANUP) == 0) {
                int (*process)(void *, struct cryptop *, int);
                void *arg;
 
-               if (crypto_drivers[hid].cc_flags & CRYPTOCAP_F_CLEANUP)
-                       crypto_freesession(crp->crp_sid);
                process = crypto_drivers[hid].cc_process;
                arg = crypto_drivers[hid].cc_arg;
 
@@ -992,6 +990,8 @@
                 * Driver has unregistered; migrate the session and return
                 * an error to the caller so they'll resubmit the op.
                 */
+               crypto_freesession(crp->crp_sid);
+
                for (crd = crp->crp_desc; crd->crd_next; crd = crd->crd_next)
                        crd->CRD_INI.cri_next = &(crd->crd_next->CRD_INI);
 



Home | Main Index | Thread Index | Old Index