Commit graph

5624 commits

Author SHA1 Message Date
cinap_lenrek e614cdf02f auth/login: add missing quotefmtinstall(), quote dom attribute 2017-12-03 04:54:34 +01:00
cinap_lenrek f948c402d8 errstr(2): add /sys/src/libc/9sys/rerrstr.c to SOURCE section 2017-12-03 02:22:48 +01:00
cinap_lenrek 2bf642de9d screenlock: blank screen using /dev/mousectl (thanks sl) 2017-12-01 23:13:01 +01:00
cinap_lenrek f03260bf25 libsec: make includes consistent for sha2block*.c 2017-11-30 21:50:52 +01:00
cinap_lenrek 4cdd7049a6 libsec: unroll portable sha1block function
just 6-10% slower than most assembly versions.
20% faster on zynq.
2017-11-30 21:30:03 +01:00
cinap_lenrek c09cd2882c libsec: unroll portable sha2block functions
- unroll the loops
- rotate the taps on each step, avoiding copies
- simplify boolean formulas for Ch() and Maj()

this yields arround 40% throughput increase on 32/64bit
archs for sha2_256 and sha2_512 on amd64.
2017-11-30 02:16:27 +01:00
aiju d51d54442e games/blit: update screen when display address changes (thanks aap) 2017-11-27 20:34:48 +00:00
aiju bea6dcd122 vmx(1): fix openbsd 6.2 amd64 !entrystate bug 2017-11-27 09:30:15 +00:00
cinap_lenrek aa3c0e55f3 libsec: optimize aesCBCencrypt()/aesCBCdecrypt()
- get rid of the temporary copies and memmoves()
- when the data pointer is aligned, do xor and copying inline

speedup for auth/aescbc encryption depends on arch:

- zynq	7%	(arm)
- t23	13%	(386)
- x230	20%	(amd64, aes-ni)
- apu2	25% (amd64, aes-ni)
2017-11-27 01:31:19 +01:00
cinap_lenrek 4898050282 cga: capture cga console contents on boot, make sure cgapos is in range
to capture bios and bootloader messages, convert the contents
on the screen to kmesg.

on machines without legacy cga, the cga registers read out as
0xFF, resuting in out of bounds cgapos. so set cgapos to 0 in
that case.
2017-11-26 17:11:01 +01:00
cinap_lenrek af20ba6746 devvga: re-render text from kmesg after resize 2017-11-26 04:49:30 +01:00
cinap_lenrek 28e9566dc5 spin: Update to most recent version. (thanks Ori_B)
from Ori_B:

There were a small number of changes needed from the tarball
on spinroot.org:

  - The mkfile needed to be updated
  - Memory.h needed to not be included
  - It needed to invoke /bin/cpp instead of gcc -E
  - It depended on `yychar`, which our yacc doesn't
    provide.

I'm still figuring out how to use spin, but it seems to do
the right thing when testing a few of the examples:

	% cd $home/src/Spin/Examples/
	% spin -a peterson.pml
	% pcc pan.c -D_POSIX_SOURCE
	% ./6.out

	(Spin Version 6.4.7 -- 19 August 2017)
		+ Partial Order Reduction

	Full statespace search for:
		never claim         	- (none specified)
		assertion violations	+
		acceptance   cycles 	- (not selected)
		invalid end states	+

	State-vector 32 byte, depth reached 24, errors: 0
	40 states, stored
	27 states, matched
	67 transitions (= stored+matched)
		0 atomic steps
	hash conflicts:         0 (resolved)

	Stats on memory usage (in Megabytes):
	0.002	equivalent memory usage for states (stored*(State-vector + overhead))
	0.292	actual memory usage for states
	128.000	memory used for hash table (-w24)
	0.534	memory used for DFS stack (-m10000)
	128.730	total actual memory usage


	unreached in proctype user
		/tmp/Spin/Examples/peterson.pml:20, state 10, "-end-"
		(1 of 10 states)

	pan: elapsed time 1.25 seconds
	pan: rate        32 states/second
2017-11-22 21:09:31 +01:00
cinap_lenrek 077e719dfb libsec: write optimized _chachablock() function for amd64 / sse2
doing 4 quarterround's in parallel using 128-bit
vector registers. for second round shuffle the columns and
then shuffle back.

code is rather obvious. only trick here is for the first
quaterround PSHUFLW/PSHUFHW is used to swap the halfwords
for the <<<16 rotation.
2017-11-20 00:10:35 +01:00
cinap_lenrek 1eb3739454 libmach: fix format for 8db sse shift ops 2017-11-19 21:11:41 +01:00
cinap_lenrek 15bd341cc3 6l: fix typo in optab table for APSLLQ (0x7e -> 0x73) 2017-11-19 21:10:36 +01:00
cinap_lenrek e3736b8887 kernel: make isaconfig() consistent, not inplace tokenizing the conf string 2017-11-19 17:17:04 +01:00
cinap_lenrek 4a684fc627 6in4: add -m mtu option to specify outer MTU
instead of hardcoding the tunnel interface MTU to 1280,
we calculate the tunnel MTU from the outside MTU, which
can now be specified with the -m mtu option. The deault
outside MTU is 1500 - 8 (PPPoE).
2017-11-18 16:03:44 +01:00
cinap_lenrek 435a9a150e 9pc64: handle special case in fpurestore() for procexec()/procsetup()
when a process does an exec, it calls procsetup() which
unconditionally sets the sets the TS flag and fpstate=FPinit
and fpurestore() should not revert the fpstate.
2017-11-16 23:15:08 +01:00
cinap_lenrek 859d5c9146 audio/flacdec: add eof handler avoiding endless spinning on broken files (thanks deuteron) 2017-11-16 14:15:00 +01:00
cinap_lenrek 753f64a877 pc64: fix mistake fpurestore() mistake
cannot just reenable the fpu in FPactive case as we might have
been procsaved() an rescheduled on another cpu. what was i thinking...
thanks qu7uux for reproducing the problem.
2017-11-14 00:16:21 +01:00
cinap_lenrek f4880742fd igfx: allocate backing memory for framebuffer and hw cursor when not done by bios (from qu7uux)
new approach to graphics memory management:

the kernel driver never really cared about the size of stolen memory
directly. that was only to figure out the maximum allocation
to place the hardware cursor image somewhere at the end of the
allocation done by bios.

qu7uux's gm965 bios however wont steal enougth memory for his
native resolution so we have todo it manually.

the userspace igfx driver will figure out how much the bios
allocated by looking at the gtt only. then extend the memory by
creating a "fixed" physical segment.

the kernel driver allocates the memory for the cursor image
from normal kernel memory, and just maps it into the gtt at the
end of the virtual kernel framebuffer aperture.

thanks to qu7uux for the patch.
2017-11-13 00:48:46 +01:00
cinap_lenrek 3356e0e731 libsec: AES-NI support for amd64
Add assembler versions for aes_encrypt/aes_decrypt and the key
setup using AES-NI instruction set. This makes aes_encrypt and
aes_decrypt into function pointers which get initialized by
the first call to setupAESstate().

Note that the expanded round key words are *NOT* stored in big
endian order as with the portable implementation. For that reason
the AESstate.ekey and AESstate.dkey fields have been changed to
void* forcing an error when someone is accessing the roundkey
words. One offender was aesXCBmac, which doesnt appear to be
used and the code looks horrible so it has been deleted.

The AES-NI implementation is for amd64 only as it requires the
kernel to save/restore the FPU state across syscalls and
pagefaults.
2017-11-12 23:15:15 +01:00
cinap_lenrek 4f27f6a04f pc64: allow using the FPU in syscall and pagefault handlers
The aim is to take advantage of SSE instructions such as AES-NI
in the kernel by lazily saving and restoring FPU state across
system calls and pagefaults. (everything can can do I/O)

This is accomplished by the functions fpusave() and fpurestore().

fpusave() remembers the current state and disables the FPU if it
was active by setting the TS flag. In case the FPU gets used,
the current state gets saved and a new PFPU.fpslot is allocated
by mathemu().

fpurestore() restores the previous FPU state, reenabling the FPU
if fpusave() disabled it.

In the most common case, when userspace is not using the FPU,
then fpusave()/fpurestore() just toggle the FPpush bit in
up->fpstate.

When the FPU was active, but we do not use the FPU, then nothing
needs to be saved or restored. We just switched the TS flag on
and off agaian.

Note, this is done for the amd64 kernel only.
2017-11-12 22:55:54 +01:00
cinap_lenrek 3ccd53549f pc64: set ts flag before schedinit() 2017-11-08 00:34:08 +01:00
cinap_lenrek 24057fd4f4 kernel: introduce per process FPU struct (PFPU) for more flexible machine specific fpu handling
introducing the PFPU structue which allows the machine specific
code some flexibility on how to handle the FPU process state.

for example, in the pc and pc64 kernel, the FPsave structure is
arround 512 bytes. with avx512, it could grow up to 2K. instead
of embedding that into the Proc strucutre, it is more effective
to allocate it on first use of the fpu, as most processes do not
use simd or floating point in the first place. also, the FPsave
structure has special 16 byte alignment constraint, which further
favours dynamic allocation.

this gets rid of the memmoves in pc/pc64 kernels for the aligment.

there is also devproc, which is now checking if the fpsave area
is actually valid before reading it, avoiding debuggers to see
garbage data.

the Notsave structure is gone now, as it was not used on any
machine.
2017-11-04 20:08:22 +01:00
cinap_lenrek 04ce485f1b tinc(8): mash -> mesh 2017-11-02 09:05:03 +01:00
cinap_lenrek efdd6afcd6 tinc(8): more spelling spam 2017-11-01 18:40:17 +01:00
cinap_lenrek ce89017481 tinc(8): spelling, thanks jpm 2017-11-01 18:34:58 +01:00
cinap_lenrek 736c31882f tinc(8): outout -> output 2017-10-31 22:58:55 +01:00
cinap_lenrek daf292ac9d tinc: implement experimental mash peer to peer VPN from http://www.tinc-vpn.org/ 2017-10-31 22:44:25 +01:00
cinap_lenrek 5c1afc882c aes(2): document aes_xts_encrypt() and aes_xts_decrypt() functions 2017-10-30 03:04:05 +01:00
cinap_lenrek 0e68b7551a kernel: pc/pc, fix comment line 2017-10-30 02:08:05 +01:00
cinap_lenrek e436a529cd swap(3): document permissions and encryption behaviour, reference to memory(8) 2017-10-30 01:55:58 +01:00
cinap_lenrek 7e619e59e4 devcons: remove obsolete comment 2017-10-30 01:24:18 +01:00
cinap_lenrek 5a93b4fe2d kernel: track more header dependencies in port/portmkfile 2017-10-30 01:23:48 +01:00
cinap_lenrek b815eaca42 devswap: fix mistake 2017-10-29 23:24:42 +01:00
cinap_lenrek f3f9392517 kernel: introduce devswap #¶ to serve /dev/swap and handle swapfile encryption 2017-10-29 23:09:54 +01:00
cinap_lenrek 93117262c2 devfs: rewrite cryptio()
adjust to new aes_xts routines.

allow optional offset in the 4th argument where the encrypted
sectors start instead of hardcoding the 64K header area for
cryptsetup.

avoid allocating temporary buffer for cryptio() reads, we can
just decrypt in place there.

use sdmalloc() to allocate the temporary buffer for cryptio()
writes so that devsd wont need to allocate and copy in case
it didnt like our alignment.

do not duplicate the error reporting code, just use io()
that is what it is for.

allow 2*256 bit keys in addition to 2*128 bit keys.
2017-10-29 22:01:58 +01:00
cinap_lenrek c021390e21 libsec: rewrite aex_xts_encrypt()/aes_xts_decrypt()
the previous implementation was not portable at all, assuming
little endian in gf_mulx() and that one can cast unaligned
pointers to ulong in xor128(). also the error code is likely
to be ignored, so better abort() when the length is not a
multiple of the AES block size.

we also pass in full AESstate structures now instead of
the expanded key longs, so that we do not need to hardcode
the number of rounds. this allows each indiviaul keys to
be bigger than 128 bit.
2017-10-29 21:49:24 +01:00
cinap_lenrek 77757dbdb1 cwfs: use /dev/swap instead of #c/swap to determine memory size 2017-10-29 21:41:35 +01:00
cinap_lenrek 3794b1c14f libc: improve alignment of QLp structure on amd64, cosmetics
the QLp structure used to occupy 24 bytes on amd64.
with some rearranging the fields we can get it to 16 bytes,
saving 8K in the data section for the 1024 preallocated
structs in the ql arena.

the rest of the changes are of cosmetic nature:

- getqlp() zeros the next pointer, so there is no need to set
  it when queueing the entry.

- always explicitely compare pointers to nil.

- delete unused code from ape's qlock.c
2017-10-28 18:53:27 +02:00
cinap_lenrek 4fc4b0dda7 libc: wunlock() part 2
the initial issue was that wunlock() would wakeup readers while
holding the spinlock causing deadlock in libthread programs where
rendezvous() would do a thread switch within the same process
which then can acquire the RWLock again.

the first fix tried to prevent holding the spinlock, waking up
one reader at a time with releasing an re-acquiering the spinlock.
this violates the invariant that readers can only wakup writers
in runlock() when multiple readers where queued at the time of
wunlock(). at the first wakeup, q->head != nil so runlock() would
find a reader queued on runlock() when it expected a writer.

this (hopefully last) fix unlinks *all* the reader QLp's atomically
and in order while holding the spinlock and then traverses the
dequeued chain of QLp structures again to call rendezvous() so
the invariant described above holds.
2017-10-26 02:42:26 +02:00
cinap_lenrek 83fe7aaa5c upas/smtpd: don't call syslog() from the note handler, this can deadlock
when the alarm hits while the process is currently in syslog(), holding
the sl lock, then calling syslog again will deadlock:

/proc/1729193/text:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
acid: lstk()
sleep()+0x7 /sys/src/libc/9syscall/sleep.s:5
lock(lk=0x394d8)+0xb7 /sys/src/libc/port/lock.c:25
	i=0x3e8
syslog(logname=0x41c64,cons=0x0,fmt=0x41c6a)+0x2d /sys/src/libc/9sys/syslog.c:60
	err=0x79732f27
	d=0x0
	ctim=0x0
	buf=0x0
	p=0x0
	arg=0x0
	n=0x0
catchalarm(msg=0xdfffc854)+0x7a /sys/src/cmd/upas/smtp/smtpd.c:71
notifier+0x30 /sys/src/libc/port/atnotify.c:15
2017-10-23 06:08:18 +02:00
cinap_lenrek e3d8fe9d4a libc: cleanup atexit and put exits() in its own compilation unit
this avoids having to pull in atexit() and its dependencies
(lock(), unlock()) into every program. (as exits() is called
by _main() from main9.s).
2017-10-20 20:58:38 +02:00
cinap_lenrek 67d9c6b2f9 vt: block when sending input to host (fixes truncated paste) 2017-10-20 20:31:30 +02:00
cinap_lenrek 29411f58cf libsec: make sectorNumber argument for aes_xts routines uvlong 2017-10-17 21:36:45 +02:00
cinap_lenrek 45b7d60bf3 libsec: add AES CFB and AES OFB stream ciphers 2017-10-17 21:34:01 +02:00
cinap_lenrek 0db4f40629 aux/wpa: prevent PTK re-installation attack by replaying AP retransmits
this implements the mitigation suggested in section "6.5 Countermeasures" of
"Key Reinstallation Attacks: Forcing Nonce Resuse in WPA2" [1].

[1] https://papers.mathyvanhoef.com/ccs2017.pdf
2017-10-17 20:15:48 +02:00
cinap_lenrek 1d34a855fe ape/libsec: fix the build, bring ape libsec.h in sync with plan9 version 2017-10-16 04:06:17 +02:00
cinap_lenrek 8fdf22d5fb ssh: remove extern declarations for pkcs1padbuf() and asn1encodedigest() (now in libsec.h) 2017-10-06 21:00:08 +02:00