Source-Changes-D archive

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

Re: CVS commit: src/sys/opencrypto



On Sun, 19 Jan 2014, Christos Zoulas wrote:

On Jan 19, 10:22am, paul%whooppee.com@localhost (Paul Goyette) wrote:
-- Subject: Re: CVS commit: src/sys/opencrypto

| How about the following changes?

You need to handle the regular open too, not justthe get (look for the
other fd_clone)

That's covered in cryptoopen() at line 1060

| @@ -143,6 +143,8 @@ static int        cryptoread(dev_t dev, struct
|   static int  cryptowrite(dev_t dev, struct uio *uio, int ioflag);
|   static int  cryptoselect(dev_t dev, int rw, struct lwp *l);
|
| +static int   crypto_refcount = 0;    /* Prevent detaching while in use */
| +
|   /* Declaration of cloned-device (per-ctxt) entrypoints */
|   static int  cryptof_read(struct file *, off_t *, struct uio *,
|       kauth_cred_t, int);
| @@ -262,6 +264,7 @@ cryptof_ioctl(struct file *fp, u_long cm
|                    */
|               criofcr->sesn = 1;
|               criofcr->requestid = 1;
| +             crypto_refcount++;
|               mutex_exit(&crypto_mtx);
|               (void)fd_clone(criofp, criofd, (FREAD|FWRITE),
|                             &cryptofops, criofcr);
| @@ -951,6 +954,7 @@ cryptof_close(struct file *fp)
|       }
|       seldestroy(&fcr->sinfo);
|       fp->f_data = NULL;
| +     crypto_refcount--;
|       mutex_exit(&crypto_mtx);
|
|       pool_put(&fcrpl, fcr);
| @@ -1080,6 +1084,7 @@ cryptoopen(dev_t dev, int flag, int mode
|        */
|       fcr->sesn = 1;
|       fcr->requestid = 1;
| +     crypto_refcount++;
|       mutex_exit(&crypto_mtx);
|       return fd_clone(fp, fd, flag, &cryptofops, fcr);
|   }
| @@ -2109,6 +2114,10 @@ int    crypto_detach(device_t, int);

It is not just the detach we need to handle, it is the module unload too
(look for FINI).

Handled indirectly. The MODULE_CMD_FINI calls config_cfdata_detach() which attempts to detach each device instance. If a detach fails, then config_cfdata_detach fails, and the unload will fail.

|   int
|   crypto_detach(device_t self, int num)
|   {
| +
| +     if (crypto_refcount != 0 || self->dv_unit != 0)
| +             return EBUSY;
| +
|       pool_destroy(&fcrpl);
|       pool_destroy(&csepl);



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index