Commit Graph

287 Commits

Author SHA1 Message Date
hikaru
0055ef443e crypto(4): accept CRYPTO_SHA2_384_HMAC and CRYPTO_SHA2_512_HMAC. 2019-11-29 08:30:30 +00:00
hikaru
f83e13c51c HMAC-SHA-512 has 32 bytes MAC. 2019-11-29 07:20:03 +00:00
christos
4ce1278ac8 add (void *) intermediate casts to elide gcc function cast warnings. This
is the simplest solution; choices:
- add pragmas, complex and ugly (need to be gcc-specific)
- add -Wno to COPTS. Needs to be done in many makefiles because of rump
- add intermediate functions: slows down things
2019-10-12 00:49:30 +00:00
uwe
edcef67ec2 xc_barrier - convenience function to xc_broadcast() a nop.
Make the intent more clear and also avoid a bunch of (xcfunc_t)nullop
casts that gcc 8 -Wcast-function-type is not happy about.
2019-10-06 15:11:16 +00:00
chs
02991323a4 in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
2019-10-01 18:00:07 +00:00
christos
803a9f2a2b relinguish our lock while we are autoloading. 2019-07-11 23:28:17 +00:00
christos
d40a55d19d Disable unloading until we keep track of references 2019-07-11 23:27:24 +00:00
christos
075ea18915 Try to load swcrypto if we we did not find any software drivers. 2019-06-13 02:07:31 +00:00
christos
cb94f55012 don't always panic when modunload crypto (int the pool destroy code, because
the pools are busy). XXX: this is still racy; we need to prevent creating
more sessions while destroying.
2019-06-13 02:02:45 +00:00
pgoyette
8c2f80f160 Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
2019-03-01 11:06:55 +00:00
pgoyette
d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
maya
a50c06709e Remove duplicate ; 2018-06-06 01:49:07 +00:00
dholland
32cded6cc9 Typos. 2018-02-08 09:05:16 +00:00
knakahara
8a37362ba6 Fix PR kern/52910. Reported and implemented a patch by Sevan Janiyan, thanks. 2018-01-08 23:34:56 +00:00
knakahara
d88bfb301b Committed debugging logs by mistake, sorry. Revert cryoto.c:r.1.103 and ip6_flow.c:r.1.37. 2018-01-08 23:33:40 +00:00
knakahara
f2516b4ae6 Fix PR kern/52910. Reported and implemented a patch by Sevan Janiyan, thanks. 2018-01-08 23:23:25 +00:00
christos
ea05286d92 add fo_name so we can identify the fileops in a simple way. 2017-11-30 20:25:54 +00:00
christos
de48dcba3d check results of pool_prime. 2017-11-14 14:29:33 +00:00
christos
0fddc7f03d use PR_NOWAIT. 2017-11-09 22:20:25 +00:00
knakahara
d33bbbcb19 fix opencrypto(9) part of PR kern/52515
percpu data use pointers to TAILQ instead of TAILQ itself.
2017-09-22 03:04:06 +00:00
knakahara
aeb50172c9 use pool_cache(9) instead of pool(9) as they can be called concurrently. 2017-07-31 04:25:45 +00:00
knakahara
a70fedd6ab use kmem_alloc KPI instead of malloc KPI. 2017-07-31 04:23:48 +00:00
knakahara
cd14ce8c20 pack crypto_drivers variables to struct and add cacheline_aligned qualifier. 2017-07-31 04:21:59 +00:00
knakahara
82f82d0b94 refactor: remove glue macros for FreeBSD code. 2017-07-31 04:19:26 +00:00
riastradh
0090c87fd5 Avoid another userland-controlled integer overflow.
From Ilja Van Sprundel.
2017-07-28 17:14:04 +00:00
riastradh
027f8447ce Avert userland-controlled integer overflow.
From Ilja Van Sprundel.
2017-07-28 14:16:29 +00:00
riastradh
0633411db6 Don't disclose uninitialized 32-bit word if cryptodev_session fails.
From Ilja Van Sprundel.
2017-07-28 14:13:56 +00:00
knakahara
41820201a7 update locking notes of opencrypto(9) 2017-07-26 06:44:50 +00:00
knakahara
b608202910 divide crp_ret_{,k}q by CPU to avoid reordering.
update locking note later.
2017-07-26 06:44:01 +00:00
knakahara
100d04813c make crp_{,k}q percpu to scale crypto_dispatch().
update locking note later.
2017-07-26 06:40:42 +00:00
knakahara
21f43ca35a fix typo 2017-07-20 23:07:12 +00:00
knakahara
f2a05a61c3 fix panic when using ecryption devices attached earlier than ipi_sysinit().
pointed out and tested by martin@n.o, thanks.
2017-07-20 09:31:36 +00:00
knakahara
024c43682a make cryptoret() context softint to balance dequeuing crypto_ret_q with enqueuing it. 2017-07-18 06:01:36 +00:00
ozaki-r
8e371e73e6 Apply C99-style struct initialization to enc_xform, auth_hash and comp_algo 2017-07-06 08:27:07 +00:00
ozaki-r
6f18d82dd5 KNF 2017-07-06 08:22:45 +00:00
knakahara
fb94c95efb simplify mutex_enter/exit(crypto_q_mtx), and fix missing exit. 2017-06-26 05:34:48 +00:00
knakahara
80c7310999 fix cryptosoft.c:r1.51 mistake. swcrypto_attach() must not be called from module_init_class().
swcrypto_attach() will call softint_establish(), it must be called after cpus
attached. module_init_class() is too early to call softint_establish().
2017-06-23 11:41:58 +00:00
knakahara
d5274e1aa6 Reduce crypto_ret_q_mtx lock regions.
crypto.c does not access the members of crp when the crp is in crp_q or
crp_ret_q. Furthermore, crp_q and crp_ret_q are protected by each mutex,
so the members of crp is not shared. That means crp_flags is not required
mutex in crypto.c.
2017-06-15 12:45:10 +00:00
knakahara
2b0e5418a0 Divide crp_devflags from crp_flags to write exclusively.
CRYPTO_F_DQRETQ(new name is CRYPTODEV_F_RET) is used by cryptodev.c only.
It should be divided to other member.
2017-06-15 12:41:18 +00:00
knakahara
a15414e502 support multiple encryption drivers (port from FreeBSD). 2017-06-14 07:38:24 +00:00
knakahara
ad7b969ce5 refactor crypto_newsession() like FreeBSD. 2017-06-14 07:36:24 +00:00
knakahara
ed8aa5b4aa must release cap->cc_lock before calling cap->cc_newsession() because of spinlock. 2017-06-14 07:32:19 +00:00
knakahara
f38224b062 sanitize in CIOCNCRYPTM and initialize comp_alg in CIOCNGSESSION 2017-06-08 09:49:46 +00:00
knakahara
d7b8965d35 sanitize count used for kmem_alloc size.
Hmm, who uses CIOCNGSESSION, CIOCNFSESSION, CIOCNCRYPTM or CIOCNFKEYM?
2017-06-08 03:02:26 +00:00
christos
da7de9a430 Put back crypto_checkdriver(); use it when we need to make sure that we
get back a cryptocap that has been initialized.
2017-06-08 00:17:02 +00:00
christos
8bbf9e0cc7 - acquire lock
- use c99 loop indexes
- initialize featp
2017-06-06 18:08:23 +00:00
knakahara
2c01b23ab6 apply the same fix as crypto.c:r1.83 for crypto_dispatch to crypto_kdispatch. 2017-06-06 04:11:41 +00:00
knakahara
239ae8baa7 avoid crp_q reordering as hardware interrupts.
crypto_{,k}invoke() can be called with holding crp_q_mtx now.
2017-06-06 01:51:39 +00:00
knakahara
15bd7242d4 add locking notes. 2017-06-06 01:48:33 +00:00