Commit Graph

277 Commits

Author SHA1 Message Date
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
knakahara
3fe5189186 restructure locks(2/2): crypto_q_mtx can be adaptive now. 2017-06-06 01:47:23 +00:00
knakahara
bd79c5ac85 restructure locks(1/2): make relation between lock and data explicit.
+ crypto_drv_mtx protects
      -  whole crypto_drivers
    + crypto_drivers[i].cc_lock (new) protects
      - crypto_drivers[i] itself
      - member of crypto_drivers[i]
    + crypto_q_mtx protects
      - crp_q
      - crp_kq
    + crypto_ret_q_mtx protects
      - crp_ret_q
      - crp_ret_kq
      - crypto_exit_flag

I will add locking note later.
2017-06-06 01:45:57 +00:00
knakahara
039014ebf0 fix reading crp_q without holding crypto_q_mtx 2017-06-05 09:09:13 +00:00
knakahara
54c9a772b6 use crypto_checkdriver_uninit() when it may touch uninitialized crypto_drivers. 2017-06-05 09:07:46 +00:00
knakahara
6623cb2c35 rename crypto_mtx to cryptodev_mtx
It is used by cryptodev.c and ocryptodev.c only.
2017-06-02 09:46:57 +00:00
knakahara
993fdeeca1 swcrypto0 was initialized twice. Fix like pseudo network interfaces.
ok by pgoyette@n.o.
2017-06-01 08:49:35 +00:00
knakahara
a54dc18f22 fix: crypto_unregister didn't work. 2017-05-31 02:17:49 +00:00
knakahara
a3f2d30d8e strictly use crypto_checkdriver(i) instead of using crypto_drivers[i] directly. 2017-05-29 09:02:46 +00:00
knakahara
ecc8a11166 add cryptkop alloc/free KPI instead of manipulating cryptkop_pool directly. 2017-05-25 05:24:57 +00:00
knakahara
cce0fc1eef remove obsoleted declarations. 2017-05-25 05:22:55 +00:00