module: icp: rip out the Solaris loadable module architecture
After progressively folding away null cases, it turns out there's /literally/ nothing there, even if some things are part of the Solaris SPARC DDI/DKI or the seventeen module types (some doubled for 32-bit userland), or the entire modctl syscall definition. Nothing. Initialisation is handled in illumos-crypto.c, which calls all the initialisers directly Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Attila Fülöp <attila@fueloep.org> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12895 Closes #12902
This commit is contained in:
parent
c1d3be19d7
commit
5c8389a8cb
|
@ -29,9 +29,6 @@
|
||||||
int aes_mod_init(void);
|
int aes_mod_init(void);
|
||||||
int aes_mod_fini(void);
|
int aes_mod_fini(void);
|
||||||
|
|
||||||
int edonr_mod_init(void);
|
|
||||||
int edonr_mod_fini(void);
|
|
||||||
|
|
||||||
int sha1_mod_init(void);
|
int sha1_mod_init(void);
|
||||||
int sha1_mod_fini(void);
|
int sha1_mod_fini(void);
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,10 @@ KERNEL_C = \
|
||||||
algs/skein/skein_iv.c \
|
algs/skein/skein_iv.c \
|
||||||
illumos-crypto.c \
|
illumos-crypto.c \
|
||||||
io/aes.c \
|
io/aes.c \
|
||||||
io/edonr_mod.c \
|
|
||||||
io/sha1_mod.c \
|
io/sha1_mod.c \
|
||||||
io/sha2_mod.c \
|
io/sha2_mod.c \
|
||||||
io/skein_mod.c \
|
io/skein_mod.c \
|
||||||
os/modhash.c \
|
os/modhash.c \
|
||||||
os/modconf.c \
|
|
||||||
core/kcf_sched.c \
|
core/kcf_sched.c \
|
||||||
core/kcf_prov_lib.c \
|
core/kcf_prov_lib.c \
|
||||||
core/kcf_callprov.c \
|
core/kcf_callprov.c \
|
||||||
|
|
|
@ -26,12 +26,10 @@ $(MODULE)-objs += core/kcf_mech_tabs.o
|
||||||
$(MODULE)-objs += core/kcf_prov_lib.o
|
$(MODULE)-objs += core/kcf_prov_lib.o
|
||||||
$(MODULE)-objs += spi/kcf_spi.o
|
$(MODULE)-objs += spi/kcf_spi.o
|
||||||
$(MODULE)-objs += io/aes.o
|
$(MODULE)-objs += io/aes.o
|
||||||
$(MODULE)-objs += io/edonr_mod.o
|
|
||||||
$(MODULE)-objs += io/sha1_mod.o
|
$(MODULE)-objs += io/sha1_mod.o
|
||||||
$(MODULE)-objs += io/sha2_mod.o
|
$(MODULE)-objs += io/sha2_mod.o
|
||||||
$(MODULE)-objs += io/skein_mod.o
|
$(MODULE)-objs += io/skein_mod.o
|
||||||
$(MODULE)-objs += os/modhash.o
|
$(MODULE)-objs += os/modhash.o
|
||||||
$(MODULE)-objs += os/modconf.o
|
|
||||||
$(MODULE)-objs += algs/modes/cbc.o
|
$(MODULE)-objs += algs/modes/cbc.o
|
||||||
$(MODULE)-objs += algs/modes/ccm.o
|
$(MODULE)-objs += algs/modes/ccm.o
|
||||||
$(MODULE)-objs += algs/modes/ctr.o
|
$(MODULE)-objs += algs/modes/ctr.o
|
||||||
|
|
|
@ -29,6 +29,12 @@
|
||||||
* Portions copyright (c) 2013, Saso Kiselkov, All rights reserved
|
* Portions copyright (c) 2013, Saso Kiselkov, All rights reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unlike sha2 or skein, we won't expose edonr via the Kernel Cryptographic
|
||||||
|
* Framework (KCF), because Edon-R is *NOT* suitable for general-purpose
|
||||||
|
* cryptographic use. Users of Edon-R must interface directly to this module.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <sys/strings.h>
|
#include <sys/strings.h>
|
||||||
#include <sys/edonr.h>
|
#include <sys/edonr.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
|
|
|
@ -776,12 +776,6 @@ kcf_get_mech_entry(crypto_mech_type_t mech_type, kcf_mech_entry_t **mep)
|
||||||
* If there are no hardware or software providers for the mechanism,
|
* If there are no hardware or software providers for the mechanism,
|
||||||
* but there is an unloaded software provider, this routine will attempt
|
* but there is an unloaded software provider, this routine will attempt
|
||||||
* to load it.
|
* to load it.
|
||||||
*
|
|
||||||
* If the MOD_NOAUTOUNLOAD flag is not set, a software provider is
|
|
||||||
* in constant danger of being unloaded. For consumers that call
|
|
||||||
* crypto_mech2id() only once, the provider will not be reloaded
|
|
||||||
* if it becomes unloaded. If a provider gets loaded elsewhere
|
|
||||||
* without the MOD_NOAUTOUNLOAD flag being set, we set it now.
|
|
||||||
*/
|
*/
|
||||||
crypto_mech_type_t
|
crypto_mech_type_t
|
||||||
crypto_mech2id_common(char *mechname, boolean_t load_module)
|
crypto_mech2id_common(char *mechname, boolean_t load_module)
|
||||||
|
|
|
@ -61,16 +61,15 @@
|
||||||
* the future it may make sense to have encryption algorithms that are
|
* the future it may make sense to have encryption algorithms that are
|
||||||
* loadable into the ICP at runtime via separate kernel modules.
|
* loadable into the ICP at runtime via separate kernel modules.
|
||||||
* However, considering that this code will probably not see much use
|
* However, considering that this code will probably not see much use
|
||||||
* outside of zfs and zfs encryption only requires aes and sha256
|
* outside of zfs and zfs encryption only requires a select few
|
||||||
* algorithms it seemed like more trouble than it was worth to port over
|
* algorithms it seemed like more trouble than it was worth to port over
|
||||||
* Illumos's kernel module structure to a Linux kernel module. In
|
* Illumos's kernel module structure to a Linux kernel module. In
|
||||||
* addition, The Illumos code related to keeping track of kernel modules
|
* addition, The Illumos code related to keeping track of kernel modules
|
||||||
* is very much tied to the Illumos OS and proved difficult to port to
|
* is very much tied to the Illumos OS and proved difficult to port.
|
||||||
* Linux. Therefore, the structure of the ICP was simplified to work
|
* Therefore, the structure of the ICP was simplified to work
|
||||||
* statically and several pieces of code responsible for keeping track
|
* statically and all the Illumos kernel module loading subsystem was removed.
|
||||||
* of Illumos kernel modules were removed and simplified. All module
|
* All module initialization and destruction is now called in this file
|
||||||
* initialization and destruction is now called in this file during
|
* during kernel module loading and unloading.
|
||||||
* Linux kernel module loading and unloading.
|
|
||||||
*
|
*
|
||||||
* 4) Adding destructors: The Illumos Crypto Layer is built into
|
* 4) Adding destructors: The Illumos Crypto Layer is built into
|
||||||
* the Illumos kernel and is not meant to be unloaded. Some destructors
|
* the Illumos kernel and is not meant to be unloaded. Some destructors
|
||||||
|
@ -112,7 +111,6 @@ icp_fini(void)
|
||||||
skein_mod_fini();
|
skein_mod_fini();
|
||||||
sha2_mod_fini();
|
sha2_mod_fini();
|
||||||
sha1_mod_fini();
|
sha1_mod_fini();
|
||||||
edonr_mod_fini();
|
|
||||||
aes_mod_fini();
|
aes_mod_fini();
|
||||||
kcf_sched_destroy();
|
kcf_sched_destroy();
|
||||||
kcf_prov_tab_destroy();
|
kcf_prov_tab_destroy();
|
||||||
|
@ -141,7 +139,6 @@ icp_init(void)
|
||||||
|
|
||||||
/* initialize algorithms */
|
/* initialize algorithms */
|
||||||
aes_mod_init();
|
aes_mod_init();
|
||||||
edonr_mod_init();
|
|
||||||
sha1_mod_init();
|
sha1_mod_init();
|
||||||
sha2_mod_init();
|
sha2_mod_init();
|
||||||
skein_mod_init();
|
skein_mod_init();
|
||||||
|
|
|
@ -1,477 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_MODCTL_H
|
|
||||||
#define _SYS_MODCTL_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* loadable module support.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct modlmisc;
|
|
||||||
struct modlinkage;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following structure defines the operations used by modctl
|
|
||||||
* to load and unload modules. Each supported loadable module type
|
|
||||||
* requires a set of mod_ops.
|
|
||||||
*/
|
|
||||||
struct mod_ops {
|
|
||||||
int (*modm_install)(struct modlmisc *, struct modlinkage *);
|
|
||||||
int (*modm_remove)(struct modlmisc *, struct modlinkage *);
|
|
||||||
int (*modm_info)(void *, struct modlinkage *, int *);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The defined set of mod_ops structures for each loadable module type
|
|
||||||
* Defined in modctl.c
|
|
||||||
*/
|
|
||||||
extern struct mod_ops mod_brandops;
|
|
||||||
#if defined(__i386) || defined(__amd64)
|
|
||||||
extern struct mod_ops mod_cpuops;
|
|
||||||
#endif
|
|
||||||
extern struct mod_ops mod_cryptoops;
|
|
||||||
extern struct mod_ops mod_driverops;
|
|
||||||
extern struct mod_ops mod_execops;
|
|
||||||
extern struct mod_ops mod_fsops;
|
|
||||||
extern struct mod_ops mod_miscops;
|
|
||||||
extern struct mod_ops mod_schedops;
|
|
||||||
extern struct mod_ops mod_strmodops;
|
|
||||||
extern struct mod_ops mod_syscallops;
|
|
||||||
extern struct mod_ops mod_sockmodops;
|
|
||||||
#ifdef _SYSCALL32_IMPL
|
|
||||||
extern struct mod_ops mod_syscallops32;
|
|
||||||
#endif
|
|
||||||
extern struct mod_ops mod_dacfops;
|
|
||||||
extern struct mod_ops mod_ippops;
|
|
||||||
extern struct mod_ops mod_pcbeops;
|
|
||||||
extern struct mod_ops mod_devfsops;
|
|
||||||
extern struct mod_ops mod_kiconvops;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definitions for the module specific linkage structures.
|
|
||||||
* The first two fields are the same in all of the structures.
|
|
||||||
* The linkinfo is for informational purposes only and is returned by
|
|
||||||
* modctl with the MODINFO cmd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* For cryptographic providers */
|
|
||||||
struct modlcrypto {
|
|
||||||
struct mod_ops *crypto_modops;
|
|
||||||
char *crypto_linkinfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* For misc */
|
|
||||||
struct modlmisc {
|
|
||||||
struct mod_ops *misc_modops;
|
|
||||||
char *misc_linkinfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Revision number of loadable modules support. This is the value
|
|
||||||
* that must be used in the modlinkage structure.
|
|
||||||
*/
|
|
||||||
#define MODREV_1 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The modlinkage structure is the structure that the module writer
|
|
||||||
* provides to the routines to install, remove, and stat a module.
|
|
||||||
* The ml_linkage element is an array of pointers to linkage structures.
|
|
||||||
* For most modules there is only one linkage structure. We allocate
|
|
||||||
* enough space for 3 linkage structures which happens to be the most
|
|
||||||
* we have in any sun supplied module. For those modules with more
|
|
||||||
* than 3 linkage structures (which is very unlikely), a modlinkage
|
|
||||||
* structure must be kmem_alloc'd in the module wrapper to be big enough
|
|
||||||
* for all of the linkage structures.
|
|
||||||
*/
|
|
||||||
struct modlinkage {
|
|
||||||
int ml_rev; /* rev of loadable modules system */
|
|
||||||
#ifdef _LP64
|
|
||||||
void *ml_linkage[7]; /* more space in 64-bit OS */
|
|
||||||
#else
|
|
||||||
void *ml_linkage[4]; /* NULL terminated list of */
|
|
||||||
/* linkage structures */
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* commands. These are the commands supported by the modctl system call.
|
|
||||||
*/
|
|
||||||
#define MODLOAD 0
|
|
||||||
#define MODUNLOAD 1
|
|
||||||
#define MODINFO 2
|
|
||||||
#define MODRESERVED 3
|
|
||||||
#define MODSETMINIROOT 4
|
|
||||||
#define MODADDMAJBIND 5
|
|
||||||
#define MODGETPATH 6
|
|
||||||
#define MODREADSYSBIND 7
|
|
||||||
#define MODGETMAJBIND 8
|
|
||||||
#define MODGETNAME 9
|
|
||||||
#define MODSIZEOF_DEVID 10
|
|
||||||
#define MODGETDEVID 11
|
|
||||||
#define MODSIZEOF_MINORNAME 12
|
|
||||||
#define MODGETMINORNAME 13
|
|
||||||
#define MODGETPATHLEN 14
|
|
||||||
#define MODEVENTS 15
|
|
||||||
#define MODGETFBNAME 16
|
|
||||||
#define MODREREADDACF 17
|
|
||||||
#define MODLOADDRVCONF 18
|
|
||||||
#define MODUNLOADDRVCONF 19
|
|
||||||
#define MODREMMAJBIND 20
|
|
||||||
#define MODDEVT2INSTANCE 21
|
|
||||||
#define MODGETDEVFSPATH_LEN 22
|
|
||||||
#define MODGETDEVFSPATH 23
|
|
||||||
#define MODDEVID2PATHS 24
|
|
||||||
#define MODSETDEVPOLICY 26
|
|
||||||
#define MODGETDEVPOLICY 27
|
|
||||||
#define MODALLOCPRIV 28
|
|
||||||
#define MODGETDEVPOLICYBYNAME 29
|
|
||||||
#define MODLOADMINORPERM 31
|
|
||||||
#define MODADDMINORPERM 32
|
|
||||||
#define MODREMMINORPERM 33
|
|
||||||
#define MODREMDRVCLEANUP 34
|
|
||||||
#define MODDEVEXISTS 35
|
|
||||||
#define MODDEVREADDIR 36
|
|
||||||
#define MODDEVNAME 37
|
|
||||||
#define MODGETDEVFSPATH_MI_LEN 38
|
|
||||||
#define MODGETDEVFSPATH_MI 39
|
|
||||||
#define MODRETIRE 40
|
|
||||||
#define MODUNRETIRE 41
|
|
||||||
#define MODISRETIRED 42
|
|
||||||
#define MODDEVEMPTYDIR 43
|
|
||||||
#define MODREMDRVALIAS 44
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sub cmds for MODEVENTS
|
|
||||||
*/
|
|
||||||
#define MODEVENTS_FLUSH 0
|
|
||||||
#define MODEVENTS_FLUSH_DUMP 1
|
|
||||||
#define MODEVENTS_SET_DOOR_UPCALL_FILENAME 2
|
|
||||||
#define MODEVENTS_GETDATA 3
|
|
||||||
#define MODEVENTS_FREEDATA 4
|
|
||||||
#define MODEVENTS_POST_EVENT 5
|
|
||||||
#define MODEVENTS_REGISTER_EVENT 6
|
|
||||||
|
|
||||||
/*
|
|
||||||
* devname subcmds for MODDEVNAME
|
|
||||||
*/
|
|
||||||
#define MODDEVNAME_LOOKUPDOOR 0
|
|
||||||
#define MODDEVNAME_DEVFSADMNODE 1
|
|
||||||
#define MODDEVNAME_NSMAPS 2
|
|
||||||
#define MODDEVNAME_PROFILE 3
|
|
||||||
#define MODDEVNAME_RECONFIG 4
|
|
||||||
#define MODDEVNAME_SYSAVAIL 5
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data structure passed to modconfig command in kernel to build devfs tree
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct aliases {
|
|
||||||
struct aliases *a_next;
|
|
||||||
char *a_name;
|
|
||||||
int a_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAXMODCONFNAME 256
|
|
||||||
|
|
||||||
struct modconfig {
|
|
||||||
char drvname[MAXMODCONFNAME];
|
|
||||||
char drvclass[MAXMODCONFNAME];
|
|
||||||
int major;
|
|
||||||
int flags;
|
|
||||||
int num_aliases;
|
|
||||||
struct aliases *ap;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(_SYSCALL32)
|
|
||||||
|
|
||||||
struct aliases32 {
|
|
||||||
caddr32_t a_next;
|
|
||||||
caddr32_t a_name;
|
|
||||||
int32_t a_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct modconfig32 {
|
|
||||||
char drvname[MAXMODCONFNAME];
|
|
||||||
char drvclass[MAXMODCONFNAME];
|
|
||||||
int32_t major;
|
|
||||||
int32_t flags;
|
|
||||||
int32_t num_aliases;
|
|
||||||
caddr32_t ap;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
/* flags for modconfig */
|
|
||||||
#define MOD_UNBIND_OVERRIDE 0x01 /* fail unbind if in use */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Max module path length
|
|
||||||
*/
|
|
||||||
#define MOD_MAXPATH 256
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default search path for modules ADDITIONAL to the directory
|
|
||||||
* where the kernel components we booted from are.
|
|
||||||
*
|
|
||||||
* Most often, this will be "/platform/{platform}/kernel /kernel /usr/kernel",
|
|
||||||
* but we don't wire it down here.
|
|
||||||
*/
|
|
||||||
#define MOD_DEFPATH "/kernel /usr/kernel"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default file name extension for autoloading modules.
|
|
||||||
*/
|
|
||||||
#define MOD_DEFEXT ""
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Parameters for modinfo
|
|
||||||
*/
|
|
||||||
#define MODMAXNAMELEN 32 /* max module name length */
|
|
||||||
#define MODMAXLINKINFOLEN 32 /* max link info length */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Module specific information.
|
|
||||||
*/
|
|
||||||
struct modspecific_info {
|
|
||||||
char msi_linkinfo[MODMAXLINKINFOLEN]; /* name in linkage struct */
|
|
||||||
int msi_p0; /* module specific information */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure returned by modctl with MODINFO command.
|
|
||||||
*/
|
|
||||||
#define MODMAXLINK 10 /* max linkages modinfo can handle */
|
|
||||||
|
|
||||||
struct modinfo {
|
|
||||||
int mi_info; /* Flags for info wanted */
|
|
||||||
int mi_state; /* Flags for module state */
|
|
||||||
int mi_id; /* id of this loaded module */
|
|
||||||
int mi_nextid; /* id of next module or -1 */
|
|
||||||
caddr_t mi_base; /* virtual addr of text */
|
|
||||||
size_t mi_size; /* size of module in bytes */
|
|
||||||
int mi_rev; /* loadable modules rev */
|
|
||||||
int mi_loadcnt; /* # of times loaded */
|
|
||||||
char mi_name[MODMAXNAMELEN]; /* name of module */
|
|
||||||
struct modspecific_info mi_msinfo[MODMAXLINK];
|
|
||||||
/* mod specific info */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(_SYSCALL32)
|
|
||||||
|
|
||||||
#define MODMAXNAMELEN32 32 /* max module name length */
|
|
||||||
#define MODMAXLINKINFOLEN32 32 /* max link info length */
|
|
||||||
#define MODMAXLINK32 10 /* max linkages modinfo can handle */
|
|
||||||
|
|
||||||
struct modspecific_info32 {
|
|
||||||
char msi_linkinfo[MODMAXLINKINFOLEN32]; /* name in linkage struct */
|
|
||||||
int32_t msi_p0; /* module specific information */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct modinfo32 {
|
|
||||||
int32_t mi_info; /* Flags for info wanted */
|
|
||||||
int32_t mi_state; /* Flags for module state */
|
|
||||||
int32_t mi_id; /* id of this loaded module */
|
|
||||||
int32_t mi_nextid; /* id of next module or -1 */
|
|
||||||
caddr32_t mi_base; /* virtual addr of text */
|
|
||||||
uint32_t mi_size; /* size of module in bytes */
|
|
||||||
int32_t mi_rev; /* loadable modules rev */
|
|
||||||
int32_t mi_loadcnt; /* # of times loaded */
|
|
||||||
char mi_name[MODMAXNAMELEN32]; /* name of module */
|
|
||||||
struct modspecific_info32 mi_msinfo[MODMAXLINK32];
|
|
||||||
/* mod specific info */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _SYSCALL32 */
|
|
||||||
|
|
||||||
/* Values for mi_info flags */
|
|
||||||
#define MI_INFO_ONE 1
|
|
||||||
#define MI_INFO_ALL 2
|
|
||||||
#define MI_INFO_CNT 4
|
|
||||||
#define MI_INFO_LINKAGE 8 /* used internally to extract modlinkage */
|
|
||||||
/*
|
|
||||||
* MI_INFO_NOBASE indicates caller does not need mi_base. Failure to use this
|
|
||||||
* flag may lead 32-bit apps to receive an EOVERFLOW error from modctl(MODINFO)
|
|
||||||
* when used with a 64-bit kernel.
|
|
||||||
*/
|
|
||||||
#define MI_INFO_NOBASE 16
|
|
||||||
|
|
||||||
/* Values for mi_state */
|
|
||||||
#define MI_LOADED 1
|
|
||||||
#define MI_INSTALLED 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to vector to the appropriate module specific routine.
|
|
||||||
*/
|
|
||||||
#define MODL_INSTALL(MODL, MODLP) \
|
|
||||||
(*(MODL)->misc_modops->modm_install)(MODL, MODLP)
|
|
||||||
#define MODL_REMOVE(MODL, MODLP) \
|
|
||||||
(*(MODL)->misc_modops->modm_remove)(MODL, MODLP)
|
|
||||||
#define MODL_INFO(MODL, MODLP, P0) \
|
|
||||||
(*(MODL)->misc_modops->modm_info)(MODL, MODLP, P0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definitions for stubs
|
|
||||||
*/
|
|
||||||
struct mod_stub_info {
|
|
||||||
uintptr_t mods_func_adr;
|
|
||||||
struct mod_modinfo *mods_modinfo;
|
|
||||||
uintptr_t mods_stub_adr;
|
|
||||||
int (*mods_errfcn)(void);
|
|
||||||
int mods_flag; /* flags defined below */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definitions for mods_flag.
|
|
||||||
*/
|
|
||||||
#define MODS_WEAK 0x01 /* weak stub (not loaded if called) */
|
|
||||||
#define MODS_NOUNLOAD 0x02 /* module not unloadable (no _fini()) */
|
|
||||||
#define MODS_INSTALLED 0x10 /* module installed */
|
|
||||||
|
|
||||||
struct mod_modinfo {
|
|
||||||
char *modm_module_name;
|
|
||||||
struct modctl *mp;
|
|
||||||
struct mod_stub_info modm_stubs[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct modctl_list {
|
|
||||||
struct modctl_list *modl_next;
|
|
||||||
struct modctl *modl_modp;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure to manage a loadable module.
|
|
||||||
* Note: the module (mod_mp) structure's "text" and "text_size" information
|
|
||||||
* are replicated in the modctl structure so that mod_containing_pc()
|
|
||||||
* doesn't have to grab any locks (modctls are persistent; modules are not.)
|
|
||||||
*/
|
|
||||||
typedef struct modctl {
|
|
||||||
struct modctl *mod_next; /* &modules based list */
|
|
||||||
struct modctl *mod_prev;
|
|
||||||
int mod_id;
|
|
||||||
void *mod_mp;
|
|
||||||
kthread_t *mod_inprogress_thread;
|
|
||||||
struct mod_modinfo *mod_modinfo;
|
|
||||||
struct modlinkage *mod_linkage;
|
|
||||||
char *mod_filename;
|
|
||||||
char *mod_modname;
|
|
||||||
|
|
||||||
char mod_busy; /* inprogress_thread has locked */
|
|
||||||
char mod_want; /* someone waiting for unlock */
|
|
||||||
char mod_prim; /* primary module */
|
|
||||||
|
|
||||||
int mod_ref; /* ref count - from dependent or stub */
|
|
||||||
|
|
||||||
char mod_loaded; /* module in memory */
|
|
||||||
char mod_installed; /* post _init pre _fini */
|
|
||||||
char mod_loadflags;
|
|
||||||
char mod_delay_unload; /* deferred unload */
|
|
||||||
|
|
||||||
struct modctl_list *mod_requisites; /* mods this one depends on. */
|
|
||||||
void *____unused; /* NOTE: reuse (same size) is OK, */
|
|
||||||
/* deletion causes mdb.vs.core issues */
|
|
||||||
int mod_loadcnt; /* number of times mod was loaded */
|
|
||||||
int mod_nenabled; /* # of enabled DTrace probes in mod */
|
|
||||||
char *mod_text;
|
|
||||||
size_t mod_text_size;
|
|
||||||
|
|
||||||
int mod_gencount; /* # times loaded/unloaded */
|
|
||||||
struct modctl *mod_requisite_loading; /* mod circular dependency */
|
|
||||||
} modctl_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mod_loadflags
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MOD_NOAUTOUNLOAD 0x1 /* Auto mod-unloader skips this mod */
|
|
||||||
#define MOD_NONOTIFY 0x2 /* No krtld notifications on (un)load */
|
|
||||||
#define MOD_NOUNLOAD 0x4 /* Assume EBUSY for all _fini's */
|
|
||||||
|
|
||||||
#define MOD_BIND_HASHSIZE 64
|
|
||||||
#define MOD_BIND_HASHMASK (MOD_BIND_HASHSIZE-1)
|
|
||||||
|
|
||||||
typedef int modid_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* global function and data declarations
|
|
||||||
*/
|
|
||||||
extern kmutex_t mod_lock;
|
|
||||||
|
|
||||||
extern char *systemfile;
|
|
||||||
extern char **syscallnames;
|
|
||||||
extern int moddebug;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* this is the head of a doubly linked list. Only the next and prev
|
|
||||||
* pointers are used
|
|
||||||
*/
|
|
||||||
extern modctl_t modules;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Only the following are part of the DDI/DKI
|
|
||||||
*/
|
|
||||||
extern int mod_install(struct modlinkage *);
|
|
||||||
extern int mod_remove(struct modlinkage *);
|
|
||||||
extern int mod_info(struct modlinkage *, struct modinfo *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bit definitions for moddebug.
|
|
||||||
*/
|
|
||||||
#define MODDEBUG_LOADMSG 0x80000000 /* print "[un]loading..." msg */
|
|
||||||
#define MODDEBUG_ERRMSG 0x40000000 /* print detailed error msgs */
|
|
||||||
#define MODDEBUG_LOADMSG2 0x20000000 /* print 2nd level msgs */
|
|
||||||
#define MODDEBUG_RETIRE 0x10000000 /* print retire msgs */
|
|
||||||
#define MODDEBUG_BINDING 0x00040000 /* driver/alias binding */
|
|
||||||
#define MODDEBUG_FINI_EBUSY 0x00020000 /* pretend fini returns EBUSY */
|
|
||||||
#define MODDEBUG_NOAUL_IPP 0x00010000 /* no Autounloading ipp mods */
|
|
||||||
#define MODDEBUG_NOAUL_DACF 0x00008000 /* no Autounloading dacf mods */
|
|
||||||
#define MODDEBUG_KEEPTEXT 0x00004000 /* keep text after unloading */
|
|
||||||
#define MODDEBUG_NOAUL_DRV 0x00001000 /* no Autounloading Drivers */
|
|
||||||
#define MODDEBUG_NOAUL_EXEC 0x00000800 /* no Autounloading Execs */
|
|
||||||
#define MODDEBUG_NOAUL_FS 0x00000400 /* no Autounloading File sys */
|
|
||||||
#define MODDEBUG_NOAUL_MISC 0x00000200 /* no Autounloading misc */
|
|
||||||
#define MODDEBUG_NOAUL_SCHED 0x00000100 /* no Autounloading scheds */
|
|
||||||
#define MODDEBUG_NOAUL_STR 0x00000080 /* no Autounloading streams */
|
|
||||||
#define MODDEBUG_NOAUL_SYS 0x00000040 /* no Autounloading syscalls */
|
|
||||||
#define MODDEBUG_NOCTF 0x00000020 /* do not load CTF debug data */
|
|
||||||
#define MODDEBUG_NOAUTOUNLOAD 0x00000010 /* no autounloading at all */
|
|
||||||
#define MODDEBUG_DDI_MOD 0x00000008 /* ddi_mod{open,sym,close} */
|
|
||||||
#define MODDEBUG_MP_MATCH 0x00000004 /* dev_minorperm */
|
|
||||||
#define MODDEBUG_MINORPERM 0x00000002 /* minor perm modctls */
|
|
||||||
#define MODDEBUG_USERDEBUG 0x00000001 /* bpt after init_module() */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_MODCTL_H */
|
|
|
@ -32,27 +32,10 @@
|
||||||
#include <sys/crypto/spi.h>
|
#include <sys/crypto/spi.h>
|
||||||
#include <sys/crypto/icp.h>
|
#include <sys/crypto/icp.h>
|
||||||
#include <modes/modes.h>
|
#include <modes/modes.h>
|
||||||
#include <sys/modctl.h>
|
|
||||||
#define _AES_IMPL
|
#define _AES_IMPL
|
||||||
#include <aes/aes_impl.h>
|
#include <aes/aes_impl.h>
|
||||||
#include <modes/gcm_impl.h>
|
#include <modes/gcm_impl.h>
|
||||||
|
|
||||||
#define CRYPTO_PROVIDER_NAME "aes"
|
|
||||||
|
|
||||||
extern struct mod_ops mod_cryptoops;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Module linkage information for the kernel.
|
|
||||||
*/
|
|
||||||
static struct modlcrypto modlcrypto = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"AES Kernel SW Provider"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlinkage modlinkage = {
|
|
||||||
MODREV_1, { (void *)&modlcrypto, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mechanism info structure passed to KCF during registration.
|
* Mechanism info structure passed to KCF during registration.
|
||||||
*/
|
*/
|
||||||
|
@ -199,20 +182,13 @@ static crypto_data_t null_crypto_data = { CRYPTO_DATA_RAW };
|
||||||
int
|
int
|
||||||
aes_mod_init(void)
|
aes_mod_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Determine the fastest available implementation. */
|
/* Determine the fastest available implementation. */
|
||||||
aes_impl_init();
|
aes_impl_init();
|
||||||
gcm_impl_init();
|
gcm_impl_init();
|
||||||
|
|
||||||
if ((ret = mod_install(&modlinkage)) != 0)
|
|
||||||
return (ret);
|
|
||||||
|
|
||||||
/* Register with KCF. If the registration fails, remove the module. */
|
/* Register with KCF. If the registration fails, remove the module. */
|
||||||
if (crypto_register_provider(&aes_prov_info, &aes_prov_handle)) {
|
if (crypto_register_provider(&aes_prov_info, &aes_prov_handle))
|
||||||
(void) mod_remove(&modlinkage);
|
|
||||||
return (EACCES);
|
return (EACCES);
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +204,7 @@ aes_mod_fini(void)
|
||||||
aes_prov_handle = 0;
|
aes_prov_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mod_remove(&modlinkage));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://opensource.org/licenses/CDDL-1.0.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2013 Saso Kiselkov. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/modctl.h>
|
|
||||||
#include <sys/crypto/common.h>
|
|
||||||
#include <sys/crypto/icp.h>
|
|
||||||
#include <sys/crypto/spi.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <sys/edonr.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unlike sha2 or skein, we won't expose edonr via the Kernel Cryptographic
|
|
||||||
* Framework (KCF), because Edon-R is *NOT* suitable for general-purpose
|
|
||||||
* cryptographic use. Users of Edon-R must interface directly to this module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static struct modlmisc modlmisc = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"Edon-R Message-Digest Algorithm"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlinkage modlinkage = {
|
|
||||||
MODREV_1, {&modlmisc, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
edonr_mod_init(void)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = mod_install(&modlinkage)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
edonr_mod_fini(void)
|
|
||||||
{
|
|
||||||
return (mod_remove(&modlinkage));
|
|
||||||
}
|
|
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
#include <sys/modctl.h>
|
|
||||||
#include <sys/crypto/common.h>
|
#include <sys/crypto/common.h>
|
||||||
#include <sys/crypto/icp.h>
|
#include <sys/crypto/icp.h>
|
||||||
#include <sys/crypto/spi.h>
|
#include <sys/crypto/spi.h>
|
||||||
|
@ -33,25 +32,6 @@
|
||||||
#include <sha1/sha1.h>
|
#include <sha1/sha1.h>
|
||||||
#include <sha1/sha1_impl.h>
|
#include <sha1/sha1_impl.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* The sha1 module is created with two modlinkages:
|
|
||||||
* - a modlmisc that allows consumers to directly call the entry points
|
|
||||||
* SHA1Init, SHA1Update, and SHA1Final.
|
|
||||||
* - a modlcrypto that allows the module to register with the Kernel
|
|
||||||
* Cryptographic Framework (KCF) as a software provider for the SHA1
|
|
||||||
* mechanisms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static struct modlcrypto modlcrypto = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"SHA1 Kernel SW Provider 1.1"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlinkage modlinkage = {
|
|
||||||
MODREV_1, { &modlcrypto, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
|
* Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
|
||||||
* by KCF to one of the entry points.
|
* by KCF to one of the entry points.
|
||||||
|
@ -189,9 +169,6 @@ sha1_mod_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = mod_install(&modlinkage)) != 0)
|
|
||||||
return (ret);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register with KCF. If the registration fails, log an
|
* Register with KCF. If the registration fails, log an
|
||||||
* error but do not uninstall the module, since the functionality
|
* error but do not uninstall the module, since the functionality
|
||||||
|
@ -208,7 +185,7 @@ sha1_mod_init(void)
|
||||||
int
|
int
|
||||||
sha1_mod_fini(void)
|
sha1_mod_fini(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (sha1_prov_handle != 0) {
|
if (sha1_prov_handle != 0) {
|
||||||
if ((ret = crypto_unregister_provider(sha1_prov_handle)) !=
|
if ((ret = crypto_unregister_provider(sha1_prov_handle)) !=
|
||||||
|
@ -221,7 +198,7 @@ sha1_mod_fini(void)
|
||||||
sha1_prov_handle = 0;
|
sha1_prov_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mod_remove(&modlinkage));
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
#include <sys/modctl.h>
|
|
||||||
#include <sys/crypto/common.h>
|
#include <sys/crypto/common.h>
|
||||||
#include <sys/crypto/spi.h>
|
#include <sys/crypto/spi.h>
|
||||||
#include <sys/crypto/icp.h>
|
#include <sys/crypto/icp.h>
|
||||||
|
@ -33,24 +32,6 @@
|
||||||
#include <sys/sha2.h>
|
#include <sys/sha2.h>
|
||||||
#include <sha2/sha2_impl.h>
|
#include <sha2/sha2_impl.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* The sha2 module is created with two modlinkages:
|
|
||||||
* - a modlmisc that allows consumers to directly call the entry points
|
|
||||||
* SHA2Init, SHA2Update, and SHA2Final.
|
|
||||||
* - a modlcrypto that allows the module to register with the Kernel
|
|
||||||
* Cryptographic Framework (KCF) as a software provider for the SHA2
|
|
||||||
* mechanisms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static struct modlcrypto modlcrypto = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"SHA2 Kernel SW Provider"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlinkage modlinkage = {
|
|
||||||
MODREV_1, {&modlcrypto, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros to access the SHA2 or SHA2-HMAC contexts from a context passed
|
* Macros to access the SHA2 or SHA2-HMAC contexts from a context passed
|
||||||
* by KCF to one of the entry points.
|
* by KCF to one of the entry points.
|
||||||
|
@ -216,9 +197,6 @@ sha2_mod_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = mod_install(&modlinkage)) != 0)
|
|
||||||
return (ret);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register with KCF. If the registration fails, log an
|
* Register with KCF. If the registration fails, log an
|
||||||
* error but do not uninstall the module, since the functionality
|
* error but do not uninstall the module, since the functionality
|
||||||
|
@ -235,7 +213,7 @@ sha2_mod_init(void)
|
||||||
int
|
int
|
||||||
sha2_mod_fini(void)
|
sha2_mod_fini(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (sha2_prov_handle != 0) {
|
if (sha2_prov_handle != 0) {
|
||||||
if ((ret = crypto_unregister_provider(sha2_prov_handle)) !=
|
if ((ret = crypto_unregister_provider(sha2_prov_handle)) !=
|
||||||
|
@ -248,7 +226,7 @@ sha2_mod_fini(void)
|
||||||
sha2_prov_handle = 0;
|
sha2_prov_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mod_remove(&modlinkage));
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
* Copyright 2013 Saso Kiselkov. All rights reserved.
|
* Copyright 2013 Saso Kiselkov. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/modctl.h>
|
|
||||||
#include <sys/crypto/common.h>
|
#include <sys/crypto/common.h>
|
||||||
#include <sys/crypto/icp.h>
|
#include <sys/crypto/icp.h>
|
||||||
#include <sys/crypto/spi.h>
|
#include <sys/crypto/spi.h>
|
||||||
|
@ -31,25 +30,6 @@
|
||||||
#define SKEIN_MODULE_IMPL
|
#define SKEIN_MODULE_IMPL
|
||||||
#include <sys/skein.h>
|
#include <sys/skein.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Like the sha2 module, we create the skein module with two modlinkages:
|
|
||||||
* - modlmisc to allow direct calls to Skein_* API functions.
|
|
||||||
* - modlcrypto to integrate well into the Kernel Crypto Framework (KCF).
|
|
||||||
*/
|
|
||||||
static struct modlmisc modlmisc = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"Skein Message-Digest Algorithm"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlcrypto modlcrypto = {
|
|
||||||
&mod_cryptoops,
|
|
||||||
"Skein Kernel SW Provider"
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct modlinkage modlinkage = {
|
|
||||||
MODREV_1, {&modlmisc, &modlcrypto, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static crypto_mech_info_t skein_mech_info_tab[] = {
|
static crypto_mech_info_t skein_mech_info_tab[] = {
|
||||||
{CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE,
|
{CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE,
|
||||||
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
|
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
|
||||||
|
@ -214,11 +194,6 @@ skein_get_digest_bitlen(const crypto_mechanism_t *mechanism, size_t *result)
|
||||||
int
|
int
|
||||||
skein_mod_init(void)
|
skein_mod_init(void)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = mod_install(&modlinkage)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to register with KCF - failure shouldn't unload us, since we
|
* Try to register with KCF - failure shouldn't unload us, since we
|
||||||
* still may want to continue providing misc/skein functionality.
|
* still may want to continue providing misc/skein functionality.
|
||||||
|
@ -231,7 +206,7 @@ skein_mod_init(void)
|
||||||
int
|
int
|
||||||
skein_mod_fini(void)
|
skein_mod_fini(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (skein_prov_handle != 0) {
|
if (skein_prov_handle != 0) {
|
||||||
if ((ret = crypto_unregister_provider(skein_prov_handle)) !=
|
if ((ret = crypto_unregister_provider(skein_prov_handle)) !=
|
||||||
|
@ -244,7 +219,7 @@ skein_mod_fini(void)
|
||||||
skein_prov_handle = 0;
|
skein_prov_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mod_remove(&modlinkage));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
|
||||||
#include <sys/modctl.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Null operations; used for uninitialized and "misc" modules.
|
|
||||||
*/
|
|
||||||
static int mod_null(struct modlmisc *, struct modlinkage *);
|
|
||||||
static int mod_infonull(void *, struct modlinkage *, int *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cryptographic Modules
|
|
||||||
*/
|
|
||||||
struct mod_ops mod_cryptoops = {
|
|
||||||
.modm_install = mod_null,
|
|
||||||
.modm_remove = mod_null,
|
|
||||||
.modm_info = mod_infonull
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Null operation; return 0.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
mod_null(struct modlmisc *modl, struct modlinkage *modlp)
|
|
||||||
{
|
|
||||||
(void) modl, (void) modlp;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Status for User modules.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
mod_infonull(void *modl, struct modlinkage *modlp, int *p0)
|
|
||||||
{
|
|
||||||
(void) modl, (void) modlp;
|
|
||||||
*p0 = -1; /* for modinfo display */
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Install a module.
|
|
||||||
* (This routine is in the Solaris SPARC DDI/DKI)
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mod_install(struct modlinkage *modlp)
|
|
||||||
{
|
|
||||||
int retval = -1; /* No linkage structures */
|
|
||||||
struct modlmisc **linkpp;
|
|
||||||
struct modlmisc **linkpp1;
|
|
||||||
|
|
||||||
if (modlp->ml_rev != MODREV_1) {
|
|
||||||
cmn_err(CE_WARN, "mod_install: "
|
|
||||||
"modlinkage structure is not MODREV_1\n");
|
|
||||||
return (EINVAL);
|
|
||||||
}
|
|
||||||
linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
|
|
||||||
|
|
||||||
while (*linkpp != NULL) {
|
|
||||||
if ((retval = MODL_INSTALL(*linkpp, modlp)) != 0) {
|
|
||||||
linkpp1 = (struct modlmisc **)&modlp->ml_linkage[0];
|
|
||||||
|
|
||||||
while (linkpp1 != linkpp) {
|
|
||||||
MODL_REMOVE(*linkpp1, modlp); /* clean up */
|
|
||||||
linkpp1++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
linkpp++;
|
|
||||||
}
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *reins_err =
|
|
||||||
"Could not reinstall %s\nReboot to correct the problem";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove a module. This is called by the module wrapper routine.
|
|
||||||
* (This routine is in the Solaris SPARC DDI/DKI)
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mod_remove(struct modlinkage *modlp)
|
|
||||||
{
|
|
||||||
int retval = 0;
|
|
||||||
struct modlmisc **linkpp, *last_linkp;
|
|
||||||
|
|
||||||
linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
|
|
||||||
|
|
||||||
while (*linkpp != NULL) {
|
|
||||||
if ((retval = MODL_REMOVE(*linkpp, modlp)) != 0) {
|
|
||||||
last_linkp = *linkpp;
|
|
||||||
linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
|
|
||||||
while (*linkpp != last_linkp) {
|
|
||||||
if (MODL_INSTALL(*linkpp, modlp) != 0) {
|
|
||||||
cmn_err(CE_WARN, reins_err,
|
|
||||||
(*linkpp)->misc_linkinfo);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
linkpp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
linkpp++;
|
|
||||||
}
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get module status.
|
|
||||||
* (This routine is in the Solaris SPARC DDI/DKI)
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mod_info(struct modlinkage *modlp, struct modinfo *modinfop)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int retval = 0;
|
|
||||||
struct modspecific_info *msip;
|
|
||||||
struct modlmisc **linkpp;
|
|
||||||
|
|
||||||
modinfop->mi_rev = modlp->ml_rev;
|
|
||||||
|
|
||||||
linkpp = (struct modlmisc **)modlp->ml_linkage;
|
|
||||||
msip = &modinfop->mi_msinfo[0];
|
|
||||||
|
|
||||||
for (i = 0; i < MODMAXLINK; i++) {
|
|
||||||
if (*linkpp == NULL) {
|
|
||||||
msip->msi_linkinfo[0] = '\0';
|
|
||||||
} else {
|
|
||||||
(void) strlcpy(msip->msi_linkinfo,
|
|
||||||
(*linkpp)->misc_linkinfo, MODMAXLINKINFOLEN);
|
|
||||||
retval = MODL_INFO(*linkpp, modlp, &msip->msi_p0);
|
|
||||||
if (retval != 0)
|
|
||||||
break;
|
|
||||||
linkpp++;
|
|
||||||
}
|
|
||||||
msip++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modinfop->mi_info == MI_INFO_LINKAGE) {
|
|
||||||
/*
|
|
||||||
* Slight kludge used to extract the address of the
|
|
||||||
* modlinkage structure from the module (just after
|
|
||||||
* loading a module for the very first time)
|
|
||||||
*/
|
|
||||||
modinfop->mi_base = (void *)modlp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retval == 0)
|
|
||||||
return (1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
Loading…
Reference in New Issue