Home | History | Annotate | Download | only in opencrypto
History log of /src/sys/opencrypto/ocryptodev.c
RevisionDateAuthorComments
 1.17  12-Mar-2022  riastradh crypto(4): Refuse count>1 for old CIOCNCRYPTM.

This hasn't worked since it was written in 2009; if anyone cared
surely they would have fixed it by now!

(Fixing this properly -- and putting a more reasonable upper bound
than the maximum that size_t arithmetic allows -- left as an exercise
or the reader.)

Reported-by: syzbot+798d4a16bc15ae88526e@syzkaller.appspotmail.com
 1.16  27-Jan-2020  pgoyette Split the module glue out from the rest of opencrypto/ocryptodev to
make rump happy.

Rump doesn't have compat modules (the compat code is included in the
relevant librump*.so), so there's no module compat_50 listed in
link_set_modules, and thus ocryptodev's MODULE(...) can't "require"
it.

This fixes the problem of "built-in module compat_50 not found" when
starting up rump_allserver (or rump_server with -l rumpdev_opencrypto).

XXX This does not resolve the long-standing "crypto: unable to
XXX register devsw, error 17" message noted at line 78 of
XXX sys/rump/dev/lib/libopencrypto/opencrypto_component.c
 1.15  16-Jan-2020  christos Initialize the session variable to an impossible session to prevent compiler
warnings.
 1.14  12-Dec-2019  pgoyette branches: 1.14.2;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.13  01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.12  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.11  28-Jul-2017  riastradh branches: 1.11.2; 1.11.4;
Avoid another userland-controlled integer overflow.

From Ilja Van Sprundel.
 1.10  28-Jul-2017  riastradh Avert userland-controlled integer overflow.

From Ilja Van Sprundel.
 1.9  28-Jul-2017  riastradh Don't disclose uninitialized 32-bit word if cryptodev_session fails.

From Ilja Van Sprundel.
 1.8  02-Jun-2017  knakahara branches: 1.8.2;
rename crypto_mtx to cryptodev_mtx

It is used by cryptodev.c and ocryptodev.c only.
 1.7  17-May-2017  knakahara opencrypto: cleanup debug messages.
 1.6  05-Sep-2014  matt branches: 1.6.2; 1.6.10;
Try not to use f_data, use f_fcrypt to get a correctly typed pointer.
 1.5  01-Jan-2014  pgoyette Modularize the opencrypto components and link to the build
 1.4  16-May-2011  drochner branches: 1.4.2; 1.4.6; 1.4.16; 1.4.20;
split the "crypto_mtx" spinlock into 3: one spinlock each for
the incoming and outgoing request queues (which can be dealt with
by hardware accelerators) and an adaptive lock for "all the rest"
(mostly driver configuration, but also some unrelated stuff in
cryptodev.c which should be revisited)
The latter one seems to be uneeded at many places, but for now I've
done simple replacements only, except minor fixes (where
softint_schedule() was called without the lock held)
 1.3  19-Feb-2011  drochner make the compatibility code conditional on COMPAT_50
 1.2  26-Mar-2009  mrg branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.14; 1.2.16;
avoid a useless uninitialised use, picked up by gcc -O3.
 1.1  25-Mar-2009  darran Fixes PR kern/41069 and PR kern/41070.

Extends the Opencrypto API to allow the destination buffer size to be
specified when its not the same size as the input buffer (i.e. for
operations like compress and decompress).
The crypto_op and crypt_n_op structures gain a u_int dst_len field.
The session_op structure gains a comp_alg field to specify a compression
algorithm.
Moved four ioctls to new ids; CIOCGSESSION, CIOCNGSESSION, CIOCCRYPT,
and CIOCNCRYPTM.
Added four backward compatible ioctls; OCIOCGSESSION, OCIOCNGSESSION,
OCIOCCRYPT, and OCIOCNCRYPTM.

Backward compatibility is maintained in ocryptodev.h and ocryptodev.c which
implement the original ioctls and set dst_len and comp_alg to 0.

Adds user-space access to compression features.

Adds software gzip support (CRYPTO_GZIP_COMP).

Adds the fast version of crc32 from zlib to libkern. This should be generally
useful and provide a place to start normalizing the various crc32 routines
in the kernel. The crc32 routine is used in this patch to support GZIP.

With input and support from tls@NetBSD.org.
 1.2.16.1  05-Mar-2011  bouyer Sync with HEAD
 1.2.14.1  06-Jun-2011  jruoho Sync with HEAD.
 1.2.12.2  31-May-2011  rmind sync with head
 1.2.12.1  05-Mar-2011  rmind sync with head
 1.2.8.2  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.8.1  26-Mar-2009  jym file ocryptodev.c was added on branch jym-xensuspend on 2009-05-13 17:22:56 +0000
 1.2.6.2  04-May-2009  yamt sync with head.
 1.2.6.1  26-Mar-2009  yamt file ocryptodev.c was added on branch yamt-nfs-mp on 2009-05-04 08:14:24 +0000
 1.2.4.2  03-May-2009  snj Pull up following revision(s) (requested by tls in ticket #611):
sys/lib/libkern/Makefile: patch
sys/lib/libkern/crc32.c: revision 1.1
sys/lib/libkern/crc32.h: revision 1.1
sys/lib/libkern/libkern.h: revision 1.89
sys/lib/libkern/arch/i386/Makefile.inc: revision 1.28
sys/net/zlib.h: revision 1.14 via patch
sys/opencrypto/crypto.c: revision 1.33
sys/opencrypto/cryptodev.c: revision 1.46
sys/opencrypto/cryptodev.h: revision 1.16
sys/opencrypto/cryptosoft.c: revision 1.24
sys/opencrypto/cryptosoft.h: revision 1.6
sys/opencrypto/deflate.h: revision 1.6
sys/opencrypto/cryptosoft_xform.c: revision 1.12
sys/opencrypto/deflate.c: revision 1.13
sys/opencrypto/files.opencrypto: revision 1.20
sys/opencrypto/ocryptodev.c: revision 1.1
sys/opencrypto/ocryptodev.h: revision 1.1
sys/opencrypto/xform.c: revision 1.18
sys/opencrypto/xform.h: revision 1.10
Fixes PR kern/41069 and PR kern/41070.

Extends the Opencrypto API to allow the destination buffer size to be
specified when its not the same size as the input buffer (i.e. for
operations like compress and decompress).
The crypto_op and crypt_n_op structures gain a u_int dst_len field.
The session_op structure gains a comp_alg field to specify a compression
algorithm.
Moved four ioctls to new ids; CIOCGSESSION, CIOCNGSESSION, CIOCCRYPT,
and CIOCNCRYPTM.
Added four backward compatible ioctls; OCIOCGSESSION, OCIOCNGSESSION,
OCIOCCRYPT, and OCIOCNCRYPTM.

Backward compatibility is maintained in ocryptodev.h and ocryptodev.c which
implement the original ioctls and set dst_len and comp_alg to 0.

Adds user-space access to compression features.

Adds software gzip support (CRYPTO_GZIP_COMP).

Adds the fast version of crc32 from zlib to libkern. This should be generally
useful and provide a place to start normalizing the various crc32 routines
in the kernel. The crc32 routine is used in this patch to support GZIP.

With input and support from tls@NetBSD.org.
 1.2.4.1  26-Mar-2009  snj file ocryptodev.c was added on branch netbsd-5 on 2009-05-03 17:24:45 +0000
 1.2.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.2.2.1  26-Mar-2009  skrll file ocryptodev.c was added on branch nick-hppapmap on 2009-04-28 07:37:50 +0000
 1.4.20.1  18-May-2014  rmind sync with head
 1.4.16.2  03-Dec-2017  jdolecek update from HEAD
 1.4.16.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.6.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.2.2  20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.4.2.1  16-May-2011  matt file ocryptodev.c was added on branch matt-nb5-mips64 on 2011-05-20 08:11:32 +0000
 1.6.10.1  19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.6.2.1  28-Aug-2017  skrll Sync with HEAD
 1.8.2.1  05-Aug-2017  snj Pull up following revision(s) (requested by knakahara in ticket #178):
sys/opencrypto/crypto.c: 1.92-1.100
sys/opencrypto/cryptodev.h: 1.38-1.39
sys/opencrypto/ocryptodev.c: 1.9-1.11
sys/opencrypto/xform.c: revision 1.29
sys/opencrypto/xform.h: revision 1.20
KNF
--
Apply C99-style struct initialization to enc_xform, auth_hash and comp_algo
--
make cryptoret() context softint to balance dequeuing crypto_ret_q with enqueuing it.
--
fix panic when using ecryption devices attached earlier than ipi_sysinit().
pointed out and tested by martin@n.o, thanks.
--
fix typo
--
make crp_{,k}q percpu to scale crypto_dispatch().
update locking note later.
--
divide crp_ret_{,k}q by CPU to avoid reordering.
update locking note later.
--
update locking notes of opencrypto(9)
--
Don't disclose uninitialized 32-bit word if cryptodev_session fails.
From Ilja Van Sprundel.
--
Avert userland-controlled integer overflow.
From Ilja Van Sprundel.
--
Avoid another userland-controlled integer overflow.
From Ilja Van Sprundel.
--
refactor: remove glue macros for FreeBSD code.
--
pack crypto_drivers variables to struct and add cacheline_aligned qualifier.
--
use kmem_alloc KPI instead of malloc KPI.
--
use pool_cache(9) instead of pool(9) as they can be called concurrently.
 1.11.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1  10-Jun-2019  christos Sync with HEAD
 1.11.2.8  23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.11.2.7  23-Sep-2018  pgoyette Fix some thinkos/pastos/typos
 1.11.2.6  23-Sep-2018  pgoyette Split the compat_crypto_50 from the rest of the crypto module

Cleanup some stuff left over from similar changes to raid modules.
 1.11.2.5  22-Sep-2018  pgoyette Since the caller passes the address of our mutex, use it rather than
trying to reference it via global symbol (which might not exist).
 1.11.2.4  22-Sep-2018  pgoyette When the compat code needs to callback to the original code, we cannot
call directly via the routines' global symbols, since the original code
might not be built-in. So, the original code that calls compat code
needs to pass in the addresses of the callbacks. This allows for the
compat code to be built whether or not the original (calling) code is
included.

XXX Done for cryptodev, will need to do the same thing for ccd(4) and
XXX vnd(4)
 1.11.2.3  18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.11.2.2  17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.11.2.1  23-Mar-2018  pgoyette Handle the compat_50 stuff for opencrypto/cryptodev
 1.14.2.2  29-Feb-2020  ad Sync with head.
 1.14.2.1  17-Jan-2020  ad Sync with head.

RSS XML Feed