tech-kern archive

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

Re: swcrypto is initialized twice



On Thu, 1 Jun 2017, Kengo NAKAHARA wrote:

Hi,

Currently(after cryptosoft.c:r1.44), software encryption driver
(swcrypto0) is initialized twice, that is, swcr_init() is called
below two call paths.
   (1) swcrypto_attach()
       <= called from module initialization
   (2) swcryptoattach()
       <= called from autoconf(9) initialization

This is wrong as it leaks struct cryptocap in crypto_drivers[].

Hmm, compare with pseudo interfaces like gif(4), It seems the
swcryptoattach() should do nothing. So, I think bellow patch
is required.
====================
--- a/sys/opencrypto/cryptosoft.c
+++ b/sys/opencrypto/cryptosoft.c
@@ -1325,8 +1325,10 @@ swcr_init(void)
void
swcryptoattach(int num)
{
-
-       swcr_init();
+       /*
+        * Nothing to do here, initialization is handled by the
+        * module initialization code in swcrypto_attach() below).
+        */
}

void   swcrypto_attach(device_t, device_t, void *);
====================

Could you comment this patch?
If there is no objection, I will commit this patch within a few days.

Yes, I believe your analysis and patch are both correct.



+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+


Home | Main Index | Thread Index | Old Index