Commit Graph

278083 Commits

Author SHA1 Message Date
jruoho 2ba250a115 After a comedy of errors, move t_mbtowc to its final resting place. 2020-06-30 16:09:40 +00:00
kim f61899471d Remove local domain always, not just when looking up addresses 2020-06-30 15:02:55 +00:00
kim 98df278e6f Compute a value for domain before comparing against it 2020-06-30 14:57:25 +00:00
jruoho 8b2d29b6bf Check that DTrace's execsnoop and opensnoop work (cf. PR kern/53417). 2020-06-30 14:30:49 +00:00
sborrill a39749b012 Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.
Thanks to jmcneill@
2020-06-30 13:14:21 +00:00
jruoho 6d91546d37 Skip a few more nodes, and enable this test for Qemu runs. 2020-06-30 11:49:26 +00:00
jruoho e643f0ea97 Add a couple of tests for sequential ifconfig(8) options, incl. PR kern/41912. 2020-06-30 11:48:20 +00:00
mbalmer 1ad28b1314 www.lua.org uses https. 2020-06-30 07:37:32 +00:00
riastradh 49b86377f2 NetBSD 6.99.69 welcomes you, and hopes you enjoy your new AES API. 2020-06-30 06:25:15 +00:00
sevan 544b2f2613 Lua 5.4.0 is out 2020-06-30 05:19:19 +00:00
riastradh 64af5d547a Missed a spot -- one more 32-bit sign-compare issue. 2020-06-30 04:17:31 +00:00
riastradh 6a40410cdc Fix sign-compare issue on 32-bit systems.
Built fine on amd64, where all unsigned values are representable in
ssize_t, but I didn't try building on i386, where they're not.
2020-06-30 04:15:46 +00:00
riastradh 5766dd4aa9 Rename enc_xform_rijndael128 -> enc_xform_aes.
Update netipsec dependency.
2020-06-30 04:14:55 +00:00
riastradh a296c51503 Note kernel AES rework. 2020-06-30 00:26:12 +00:00
riastradh 96d271ec30 Make padlock(4) compile on amd64. 2020-06-29 23:58:44 +00:00
riastradh a220774a13 Provide hand-written AES NEON assembly for arm32.
gcc does a lousy job at compiling 128-bit NEON intrinsics on arm32;
hand-writing it made it about 12x faster, by avoiding a zillion loads
and stores to spill everything and the kitchen sink onto the stack.
(But gcc does fine on aarch64, presumably because it has twice as
many registers and doesn't have to deal with q2=d4/d5 overlapping.)
2020-06-29 23:57:56 +00:00
riastradh 0a776e17e0 New permutation-based AES implementation using ARM NEON.
Also derived from Mike Hamburg's public-domain vpaes code.
2020-06-29 23:56:30 +00:00
riastradh c41eed1f74 Implement fpu_kern_enter/leave for arm32. 2020-06-29 23:54:05 +00:00
riastradh 9f4370e773 Move aarch64/fpu.h to arm/fpu.h. 2020-06-29 23:53:12 +00:00
riastradh c057901613 New permutation-based AES implementation using SSSE3.
This covers a lot of CPUs -- particularly lower-end CPUs over the
past decade which lack AES-NI.

Derived from Mike Hamburg's public domain vpaes software; see
<https://crypto.stanford.edu/vpaes/> for details.
2020-06-29 23:51:35 +00:00
riastradh 4809cab8b6 Split SSE2 logic into separate units.
Ensure that there are no paths into files compiled with -msse -msse2
at all except via fpu_kern_enter.

I didn't run into a practical problem with this, but let's not leave
a ticking time bomb for subsequent toolchain changes in case the mere
declaration of local __m128i variables causes trouble.
2020-06-29 23:50:05 +00:00
riastradh 336b5650c6 New SSE2-based bitsliced AES implementation.
This should work on essentially all x86 CPUs of the last two decades,
and may improve throughput over the portable C aes_ct implementation
from BearSSL by

(a) reducing the number of vector operations in sequence, and
(b) batching four rather than two blocks in parallel.

Derived from BearSSL'S aes_ct64 implementation adjusted so that where
aes_ct64 uses 64-bit q[0],...,q[7], aes_sse2 uses (q[0], q[4]), ...,
(q[3], q[7]), each tuple representing a pair of 64-bit quantities
stacked in a single 128-bit register.  This translation was done very
naively, and mostly reduces the cost of ShiftRows and data movement
without doing anything to address the S-box or (Inv)MixColumns, which
spread all 64-bit quantities across separate registers and ignore the
upper halves.

Unfortunately, SSE2 -- which is all that is guaranteed on all amd64
CPUs -- doesn't have PSHUFB, which would help out a lot more.  For
example, vpaes relies on that.  Perhaps there are enough CPUs out
there with PSHUFB but not AES-NI to make it worthwhile to import or
adapt vpaes too.

Note: This includes local definitions of various Intel compiler
intrinsics for gcc and clang in terms of their __builtin_* &c.,
because the necessary header files are not available during the
kernel build.  This is a kludge -- we should fix it properly; the
present approach is expedient but not ideal.
2020-06-29 23:47:54 +00:00
riastradh 04a6492d1e New cgd cipher adiantum.
Adiantum is a wide-block cipher, built out of AES, XChaCha12,
Poly1305, and NH, defined in

   Paul Crowley and Eric Biggers, `Adiantum: length-preserving
   encryption for entry-level processors', IACR Transactions on
   Symmetric Cryptology 2018(4), pp. 39--61.

Adiantum provides better security than a narrow-block cipher with CBC
or XTS, because every bit of each sector affects every other bit,
whereas with CBC each block of plaintext only affects the following
blocks of ciphertext in the disk sector, and with XTS each block of
plaintext only affects its own block of ciphertext and nothing else.

Adiantum generally provides much better performance than
constant-time AES-CBC or AES-XTS software do without hardware
support, and performance comparable to or better than the
variable-time (i.e., leaky) AES-CBC and AES-XTS software we had
before.  (Note: Adiantum also uses AES as a subroutine, but only once
per disk sector.  It takes only a small fraction of the time spent by
Adiantum, so there's relatively little performance impact to using
constant-time AES software over using variable-time AES software for
it.)

Adiantum naturally scales to essentially arbitrary disk sector sizes;
sizes >=1024-bytes take the most advantage of Adiantum's design for
performance, so 4096-byte sectors would be a natural choice if we
taught cgd to change the disk sector size.  (However, it's a
different cipher for each disk sector size, so it _must_ be a cgd
parameter.)

The paper presents a similar construction HPolyC.  The salient
difference is that HPolyC uses Poly1305 directly, whereas Adiantum
uses Poly1395(NH(...)).  NH is annoying because it requires a
1072-byte key, which means the test vectors are ginormous, and
changing keys is costly; HPolyC avoids these shortcomings by using
Poly1305 directly, but HPolyC is measurably slower, costing about
1.5x what Adiantum costs on 4096-byte sectors.

For the purposes of cgd, we will reuse each key for many messages,
and there will be very few keys in total (one per cgd volume) so --
except for the annoying verbosity of test vectors -- the tradeoff
weighs in the favour of Adiantum, especially if we teach cgd to do
>>512-byte sectors.

For now, everything that Adiantum needs beyond what's already in the
kernel is gathered into a single file, including NH, Poly1305, and
XChaCha12.  We can split those out -- and reuse them, and provide MD
tuned implementations, and so on -- as needed; this is just a first
pass to get Adiantum implemented for experimentation.
2020-06-29 23:44:01 +00:00
riastradh 1f8a993cb5 VIA AES: Batch AES-XTS computation into eight blocks at a time.
Experimental -- performance improvement is not clearly worth the
complexity.
2020-06-29 23:41:35 +00:00
riastradh 937bd5f179 uvm: Make sure swap encryption IV is 128-bit-aligned on stack.
Will help hardware-assisted AES.
2020-06-29 23:40:28 +00:00
riastradh 7ff94d7a4a Add AES implementation with VIA ACE. 2020-06-29 23:39:30 +00:00
riastradh 4509949ad1 padlock(4): Remove legacy rijndael API use.
This doesn't actually need to compute AES -- it just needs the
standard AES key schedule, so use the BearSSL constant-time key
schedule implementation.

XXX Compile-tested only.
XXX The byte-order business here seems highly questionable.
2020-06-29 23:38:02 +00:00
riastradh 776602aed4 Provide the standard AES key schedule.
Different AES implementations prefer different variations on it, but
some of them -- notably VIA -- require the standard key schedule to
be available and don't provide hardware support for computing it
themselves.  So adapt BearSSL's logic to generate the standard key
schedule (and decryption keys, with InvMixColumns), rather than the
bitsliced key schedule that BearSSL uses natively.
2020-06-29 23:36:59 +00:00
riastradh ab834bda32 cgd(4): Align IVs on the stack.
This will make it easier for some hardware crypto support.
2020-06-29 23:36:06 +00:00
riastradh e4d0ac737c cgd(4): Print which key size is broken when a self-test fails.
Can be gleaned from the test index but this is a little quicker.
2020-06-29 23:35:26 +00:00
riastradh 8835ffd082 opencrypto: Switch from legacy rijndael API to new aes API.
While here, apply various rijndael->aes renames, reduce the size
of aesxcbc_ctx by 480 bytes, and convert some malloc->kmem.

Leave in the symbol enc_xform_rijndael128 for now, though, so this
doesn't break any kernel ABI.
2020-06-29 23:34:48 +00:00
riastradh f2307dc81e uvm(9): Switch from legacy rijndael API to new aes API. 2020-06-29 23:33:46 +00:00
riastradh df3ab5d484 cgd(4): Switch from legacy rijndael API to new aes API. 2020-06-29 23:33:05 +00:00
riastradh fed64b82c2 glxsb(4): Remove rijndael dependency.
This doesn't actually seem to depend on it in any way.

XXX Compile-tested only.
2020-06-29 23:32:24 +00:00
riastradh d4b0170e34 Implement AES in kernel using ARMv8.0-AES on aarch64. 2020-06-29 23:31:41 +00:00
riastradh 99325bb896 Add x86 AES-NI support.
Limited to amd64 for now.  In principle, AES-NI should work in 32-bit
mode, and there may even be some 32-bit-only CPUs that support
AES-NI, but that requires work to adapt the assembly.
2020-06-29 23:29:39 +00:00
riastradh 5dcdae413b Rework AES in kernel to finally address CVE-2005-1797.
1. Rip out old variable-time reference implementation.
2. Replace it by BearSSL's constant-time 32-bit logic.
   => Obtained from commit dda1f8a0c46e15b4a235163470ff700b2f13dcc5.
   => We could conditionally adopt the 64-bit logic too, which would
      likely give a modest performance boost on 64-bit platforms
      without AES-NI, but that's a bit more trouble.
3. Select the AES implementation at boot-time; allow an MD override.
   => Use self-tests to verify basic correctness at boot.
   => The implementation selection policy is rather rudimentary at
      the moment but it is isolated to one place so it's easy to
      change later on.

This (a) plugs a host of timing attacks on, e.g., cgd, and (b) paves
the way to take advantage of CPU support for AES -- both things we
should've done a decade ago.  Downside: Computing AES takes 2-3x the
CPU time.  But that's what hardware support will be coming for.

Rudimentary measurement of performance impact done by:

mount -t tmpfs tmpfs /tmp
dd if=/dev/zero of=/tmp/disk bs=1m count=512
vnconfig -cv vnd0 /tmp/disk
cgdconfig -s cgd0 /dev/vnd0 aes-cbc 256 < /dev/zero
dd if=/dev/rcgd0d of=/dev/null bs=64k
dd if=/dev/zero of=/dev/rcgd0d bs=64k

The AES-CBC encryption performance impact is closer to 3x because it
is inherently sequential; the AES-CBC decryption impact is closer to
2x because the bitsliced AES logic can process two blocks at once.

Discussed on tech-kern:

https://mail-index.NetBSD.org/tech-kern/2020/06/18/msg026505.html
2020-06-29 23:27:52 +00:00
riastradh de89524ae7 Draft fpu_kern_enter/leave on aarch64. 2020-06-29 23:22:27 +00:00
riastradh 65367154cd Nix trailing whitespace. 2020-06-29 23:04:56 +00:00
uwe e78db94ba3 Add quotes around command substitution in the example
so that it works regardless of IFS and buts.
Requested by kre@
2020-06-29 22:50:11 +00:00
jdolecek 44618758bb when using two linked requests for I/O (i.e. when backend doesn't support
INDIRECT segments), make sure to clear req_bp for both of them

fixes a misfired assertion in BLKIF_OP_FLUSH_DISKCACHE - PR port-xen/55431
2020-06-29 21:45:50 +00:00
maya f728d212f0 Avoid copyright issues and name the listed author as the copyright holder.
In a private email, Miloslav had agreed that if they had written the
test, then it can be licensed bsd-2-clause. I am going to assume this
is true as the file names Miloslav as the author.

This test was likely sent to tcsh (not netbsd) that had changed bug
report systems since.
2020-06-29 20:53:40 +00:00
scole f55b16a241 Fix for last checkin, don't try use non-existent register from a (currently) dummy struct 2020-06-29 17:09:33 +00:00
jruoho db34f12f88 Use -Wl,--no-fatal-warnings for the mktemp(3) test. 2020-06-29 14:22:11 +00:00
kim 6a5a56cef1 Use two-letter weekday abbreviations in the heading
This matches output from ncal (a.k.a. cal) as found in FreeBSD and
bsdmainutils. (Why had "T" been found more ambiguous than "S" already?)
2020-06-29 14:01:14 +00:00
fcambus b11e06097c Update Spleen wscons fonts to version 1.8.0, bringing the following
improvements:

- Improve ampersand character, making it more consistent with other
  sizes (5x8 version)
2020-06-29 09:57:46 +00:00
jdolecek ff2d91f148 increase UPAGES (used for lwp kernel stack) for SVS so the the
amount of actually usable kernel stack is the same for SVS and
non-SVS kernels (currently 12 KiB)

discussed with maxv@, part of investigation for PR kern/S55402
2020-06-29 09:56:51 +00:00
fcambus 4b03002cb8 Update Spleen kernel fonts to version 1.8.0, bringing the following
improvements:

- Improve ampersand character, making it more consistent with other
  sizes (5x8 version)
2020-06-29 09:45:35 +00:00
msaitoh 02c4325e89 Check the return value of iic_acquire_bus(). This function may fail.
One of the case is driver's detaching phase on shutdown. mutex_tryenter()
might fail and return with EBUSY. To avoid calling iic_release_bus() without
taking lock, check the return value of iic_acquire_bus().
2020-06-29 09:24:07 +00:00
lukem a0572f97f3 kyua-cli: fix build of .cpp files
Fix assignment of SRCS for C++ sources that use .cpp instead of .cc.
2020-06-29 08:54:58 +00:00