Commit graph

3904 commits

Author SHA1 Message Date
ben 0da525ae9a check program size 2016-04-27 19:56:39 -05:00
ben 3bf6ef0196 better memory management of threads (thanks knuth) 2016-04-27 17:36:43 -05:00
ben 86e0099835 merge in master 2016-04-27 08:20:54 -05:00
ben b8986a889d use Beof for awk port 2016-04-27 08:09:16 -05:00
ben 85824350b5 remove ape regexp library, add utility for awk native port 2016-04-27 07:52:41 -05:00
cinap_lenrek d8d47f14b5 libjson: add slack space to literal string buffer to handle bad runes (thanks mischief)
if the input string contains invalid utf-8, runetochar() produces
unicode replacement characters that can overflow the literal buffer.
as the overflow check is done after runetochar(), add UTFmax bytes
of slack space avoiding the issue.
2016-04-27 12:59:06 +02:00
ben 0f8168038a remove old libregexp files; add headers for upas/bayes 2016-04-26 22:26:03 -05:00
ben 0a460e1722 New libregexp and APE ported to native 2016-04-26 22:23:44 -05:00
Matthew Veety 6d2635d5ba made abaco's gui respect $font and made readweb respect most installations 2016-04-25 17:49:31 -04:00
cinap_lenrek 1cf3c46669 rsa: rename getkey() to getrsakey(), document rsa2csr in rsa(8) 2016-04-22 03:41:06 +02:00
cinap_lenrek 17a67eeb65 libsec: implement server side SCSV preventing silly client fallbacks
silly clients (web*) reconnect when the handshake failed with a lower
protocol version, which allows downgrade attacks (POODLE). but instead
of stopping this madness, they invented a new magic TLSID to indicate
to the server that this connection attempt is a retry, and rely on the
server to notice and stop them from sabotaging themselfs.
2016-04-22 02:33:29 +02:00
cinap_lenrek 7b3334775e libsec: order tlshand cipher suits by: keyexchange>=cipher>=hash, ignore client preference
client preference is usualy crazy, so just ignore it.
we always want the diffie hellman suits before static
rsa and prefer chacha over aes-gcm.
2016-04-21 23:29:59 +02:00
cinap_lenrek 0d6a188dde rsagen: increase default key size to 2048 bits 2016-04-21 21:25:33 +02:00
cinap_lenrek 42c4cc75a6 libsec: remove affine coordinate point operations from ecc
we now just do point addtion in jacobian coordinate system, and
convert the result to affine when s->z == nil.
2016-04-21 20:41:19 +02:00
cinap_lenrek 2fa4c8ef66 libsec: implement elliptic curve group operations in jacobian coordinate system 2016-04-20 20:09:59 +02:00
cinap_lenrek ff47cbd464 libsec: implement server side ECDHE key exchange with secp256r1, move DH state in TlsSec structure, simplify
implement ECDHE key exchange with secp256r1 on the server side, providing
perfect forward secrecy (tho slowly).

it is easier to just keep the ECDH/DH state in the TlsSec structure,
which fits better with the grouping of the functions. we do the cleanup
in tlsConnectionFree() now, so a lot of error handling logic could go
away.

reinvestigated some error paths and removed the ones that cannot error.

move functions to fit the logical grouping.

combine the code for signing handshake hashes (for client certs) and
DH parameters. provide digestDHparams() function to be shared between
server and client code.
2016-04-18 19:24:57 +02:00
cinap_lenrek 9ba04fd030 webfs: fix memory leak of serverName in tlswrap() 2016-04-18 19:07:02 +02:00
cinap_lenrek ad6b99359d libsec: massive cleanup of tlshand.c
don't pass or generate sessionID's. this was never used nor
actually implemented and leaks the process pid.

get rid of version and random field duplications, move TlsSec
structure into TlsConnection.

make msgRecv() clear the message first, get rid of unneccesary
msgClear() calls.
2016-04-17 07:20:54 +02:00
cinap_lenrek 54c49284e0 libsec: fix memory leak of RSApub, avoid parsing certificate twice to extract rsa public key
instead of letting factotum_rsa_open() parse the certificate,
we pass in the rsa public key which is then matched against the
factotum keyring. this avoids parsing the x509 certificate
twice.

the sec->rsapub was not freed, so free it in tlsSecClose()
2016-04-16 23:36:55 +02:00
cinap_lenrek 294e08fa1e libsec: recognize and decode PKCS#8 wrapped RSA private keys for auth/asn12rsa
example usage:

auth/pemdecode 'PRIVATE KEY' test.pem | auth/asn12rsa
2016-04-16 04:16:10 +02:00
cinap_lenrek 1628c97d1e webfs: change %H (hostname) format to %N to not collide with encodefmt's %H (hex) 2016-04-15 23:54:00 +02:00
cinap_lenrek 9e08127ba6 libsec: x509: convert to UTF8 from BMPString and UNIString, reject \0 bytes 2016-04-15 23:51:52 +02:00
cinap_lenrek 8fd1aa2626 libc: fix out of bounds access in dirpackage(), simplify
- dirpackage() was not checking if the stat entry lies within
the buffer. fixed.

- simplify dirpackage(), as we process all the bytes from
the buffer, we do not need to track "ss" here as its the same
as "ts".

- zero Dir* array pointer early in dirread() and dirreadall()
and avoid calling dirpackage on <= buffer length.
2016-04-13 22:19:37 +02:00
cinap_lenrek 4ed396d438 kbdfs: add shift+altgr table 7 for polish keymaps 2016-04-13 17:00:20 +02:00
cinap_lenrek a5268a5413 remove unused liboventi 2016-04-13 01:09:45 +02:00
cinap_lenrek ffb0199247 ktrace: sign extend stack dump pc for amd64 2016-04-13 01:08:13 +02:00
cinap_lenrek 68411b98a0 libc: remove unneeded #include <auth.h> for crypt() and netcrypt() 2016-04-13 01:06:34 +02:00
cinap_lenrek 1787584ad8 libdraw: avoid BPSHORT()/BPLONG() expansion, cleanup loadchar(),cachechars()
assigning the expression value to a temporary variable in
BPSHORT() and BPLONG() saves arround 2K of text in rio on
arm and arround 1K on amd64.

loadchar(): use the passed in "h" as the char index instead
of recomputing it from c-f->cache. dont recompute wid.

cachechars(): do cache lookup and find oldest entry in a
single loop pass.
2016-04-13 00:34:48 +02:00
cinap_lenrek 94e39c482e ape: explicitely list the ape libs to build in mkfile 2016-04-11 20:43:48 +02:00
cinap_lenrek 45f3c56a53 ape: removing openssl 2016-04-11 20:39:12 +02:00
cinap_lenrek 4e04698ab6 python: remove openssl support, use ape/libsec for cryptographics hash functions 2016-04-11 20:31:14 +02:00
cinap_lenrek 8f4db30e78 gs: replace openssl aes implementation with ape/libsec 2016-04-11 20:27:50 +02:00
cinap_lenrek 464763202b ape: add libauth, libbio, libmp and libsec as replacements for openssl 2016-04-11 20:23:34 +02:00
cinap_lenrek d71cf7ff1b libauth: remove unneeded includes for authsrv.h, avoid pulling in dependency for rerrstr() 2016-04-10 20:24:20 +02:00
cinap_lenrek 44cbb29308 libsec: make #include headers consistent 2016-04-10 20:23:18 +02:00
cinap_lenrek c3c726a5d0 libsec: dont use mips assembly routines for spim, wrong endianess 2016-04-10 20:22:00 +02:00
cinap_lenrek 1069d018c9 libmp: fix build for spim, reduce by the mips assembly files 2016-04-10 20:20:53 +02:00
cinap_lenrek 3238f124b8 ape: move compatibility libc.h to lib9 directory and incooperate needed functions for ape/mp (wip) 2016-04-10 03:01:37 +02:00
cinap_lenrek ea6910b706 ape: remove broken 9errstr.c 2016-04-10 02:54:29 +02:00
cinap_lenrek 5e37087451 ape: add internal _NSEC() function and make gettimeofday() use it 2016-04-10 02:52:31 +02:00
cinap_lenrek 3ba1197aeb libmp: make includes consistent, make test program compile under ape (work in progress) 2016-04-10 02:35:01 +02:00
cinap_lenrek b47c096c8c libdraw: dont postnote to pid==0 in ekill() 2016-04-10 00:00:37 +02:00
cinap_lenrek 5f28fee620 add missing target for antiword in /sys/src/cmd/aux/mkfile (thanks _sl) 2016-04-09 21:27:25 +02:00
cinap_lenrek acfd092987 ether82563: initial i217 support from http://www.9legacy.org/9legacy/patch/pc-ether82563-i210.diff (thanks k0ga)
This patch is only an adaptation for 9front of the patch located in
http://www.9legacy.org/9legacy/patch/pc-ether82563-i210.diff.  The
major difference is that this patch ignores errors in checksum of
eeprom, because in my system the checksum was wrong.  After 3 months,
I didn't have problems, and I think the patch can be used.  although
it has some things that need to be fixed.  If the link is inactive
when the system boots then it will remain inactive forever.
2016-04-07 21:24:13 +02:00
BurnZeZ 455a0a09ac jpg: fd == 0 is valid, so don't ignore it 2016-04-06 20:22:42 -04:00
cinap_lenrek 796e7b84bd libdraw: fix out of bounds memory access after subfont array reallocation (thanks ray)
/n/bugs/open/libdrawfont.c_buffer_overflow
http://bugs.9front.org/open/libdrawfont.c_buffer_overflow/readme

ray@raylai.com

Hi all,

In plan9port this bug keeps crashing mc when I run lc in a directory with Chinese characters. This is a diff from OpenBSD but it should apply cleanly to the various plan9 sources.

The code is basically trying to do a realloc (I guess realloc wasn't available back then?) but it copies too much from the original buffer.

Since realloc is available, just use it. If realloc isn't available outside plan9port (I haven't checked) the memmove line should be changed from:
	memmove(f->subf, of, (f->nsubf+DSUBF)*sizeof *subf);
to:
	memmove(f->subf, of, f->nsubf*sizeof *subf);

I hope this is helpful.

Ray
2016-04-05 11:24:07 +02:00
cinap_lenrek a74542613d rio: /dev/kbd cleanup
- use free running unsigned indeces for window kbdq
- emalloc() vs malloc() in xfid
2016-04-04 06:47:26 +02:00
cinap_lenrek ce84082205 change /dev/kbd to return multiple messages per read 2016-04-03 22:54:22 +02:00
cinap_lenrek cd9cddf3dd mercurial: CVE-2016-3630
backported the following patches from mercurial 3.7.3:

https://selenic.com/repo/hg/rev/b6ed2505d6cf
https://selenic.com/repo/hg/rev/b9714d958e89
2016-04-03 04:04:56 +02:00
cinap_lenrek 0237b58390 kernel: always clunk closed fids asynchronously, regardless of caching 2016-04-01 14:12:50 +02:00
cinap_lenrek e93f7885da 6in4: ingress filter multicast and link-local, but allow relay traffic 2016-03-31 23:53:10 +02:00
cinap_lenrek 137533bd69 6in4: allow setting the local IPv4 address with -i flag (thanks k0ga) 2016-03-31 20:35:02 +02:00
cinap_lenrek df53b2d69b kernel: remove unused NSMAX, NSLOG, NSCACHE constants from portdat.h 2016-03-31 04:23:27 +02:00
cinap_lenrek 1057a859b8 devsegment: cleanups
- return distinct error message when attempting to create Globalseg with physseg name
- copy directory name to up->genbuf so it stays valid after we unlock(&glogalseglock)
- cleanup wstat() handling, allow changing uid
- make sure global segment size is below SEGMAXSIZE
- move isoverlap() check from globalsegattach() into segattach()
- remove Proc* argument from globalsegattach(), segattach() and isoverlap()
- make Physseg.attr and segattach attr parameter an int for consistency
2016-03-30 22:49:13 +02:00
cinap_lenrek b4e7d8fbf3 zynq: cleanup devarch, flushmmu() after procflushpsecg() 2016-03-29 05:06:32 +02:00
cinap_lenrek e6b30b287c kernel: fix procflushmmu()
fix bug introduced in previous change for zynq, broke
procflushseg() function only flushing the first proc
matching the segment.
2016-03-29 02:09:49 +02:00
cinap_lenrek ce00c68059 kernel: print pid as %lud instead %lux (in tsleep() debug print) 2016-03-28 23:01:54 +02:00
cinap_lenrek fd9560d7d8 libsec: fix tlsid for TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
the previous cipher id's where fore TLS_ECDH_* not TLS_ECDHE_*... sorry :(
2016-03-28 21:58:37 +02:00
cinap_lenrek 89f9966aed devtls: print the path of the underlying chan in status file
to figure out what network connection a particular tls
conversation refers to, we add the path of the underlying
we send the encrypted tls traffic over in the status file,
example:

term% grep -n '^Chan:' '#a'/tls/*/status
#a/tls/0/status:7: Chan: /net/tcp/6/data
#a/tls/1/status:7: Chan: /net/tcp/0/data
2016-03-28 20:12:54 +02:00
cinap_lenrek 38a8af2d72 devip: applying changes for bug: multicasts_and_udp_buffers
/n/bugs/open/multicasts_and_udp_buffers
http://bugs.9front.org/open/multicasts_and_udp_buffers/readme

michal@Lnet.pl

I have ported my small MPEG-TS analisis tool to Plan9.

To allow this application working I had to fix a bug in the kernel IPv4 code and increase UDP input buffer.

Bug is related to listening for IPv4 multicast traffic. There is no problem if you listen for only one group or multiple groups with different UDP ports. This works:

Write to UDP ctl:

anounce PORT
addmulti INTERFACE_ADDR MULTICAST_ADDR
headers

and you can read packets from data file.

You need to set headers option because otherwise every UDP packet for MULTICAST_ADDR!PORT is treat as separate connection. This is a bug and should be fixed too, but I didn't tried it.

There is a problem when you need to receive packets for multiple multicast groups. Usually the same destination port is used by multiple streams and above sequence of commands fails for second group because the port is the same.

Simple and probably non-intrusive fix is adding "|| ipismulticast(addr)" to if statement at /sys/src/9/ip/devip.c:861 line:

if(ipforme(c->p->f, addr) || ipismulticast(addr))

This fixes the problem and now you can use the following sequence to listen for multiple multicast groups even if they all have the same destination port:

announce MULTICAST_ADDR!PORT
addmulti INTERFACE_ADDR MULTICAST_ADDR
headers

After that my application started working but signals packet drops at >2 Mb/s input rate. The same is reported by kernel netlog. Increase capacity of UDP connection input queue fixes this problem /sys/src/9/ip/udp.c:153

c->rq = qopen(512*1024, Qmsg, 0, 0);

--
Michał Derkacz
2016-03-28 16:58:09 +02:00
cinap_lenrek 04c3a6f66e zynq: introduce SG_FAULT to prevent access to AXI segment while PL is not ready
access to the axi segment hangs the machine when the fpga
is not programmed yet. to prevent access, we introduce a
new SG_FAULT flag, that when set on the Segment.type or
Physseg.attr, causes the fault handler to immidiately
return with an error (as if the segment would not be mapped).

during programming, we temporarily set the SG_FAULT flag
on the axi physseg, flush all processes tlb's that have
the segment mapped and when programming is done, we clear
the flag again.
2016-03-27 20:57:01 +02:00
cinap_lenrek bf2195b88c file: deal with negative coordinates in plan9 bitmaps, print image size 2016-03-27 16:38:39 +02:00
cinap_lenrek 9aa6573359 kernel: fix tsleep()/twakeup()/tsemacquire() race
tsleep() used to cancel the timer with:

if(up->tt != nil)
	timerdel(up);

which still can result in twakeup() to fire after tsleep()
returns (because we set Timer.tt to nil *before* we call the tfn).
in most cases, this is not an issue as the Rendez*
usually is just &up->sleep, but when it is dynamically allocated
or on the stack like in tsemacquire(), twakeup() will call
wakeup() on a potentially garbage Rendez structure!

to fix the race, we execute the wakup() with the Timer lock
held, and set p->trend to nil only after we called wakeup().

that way, the timerdel(); which unconditionally locks the Timer;
can act as a proper barrier and use up->trend == nil as the
condition if the timer has already fired.
2016-03-26 02:37:42 +01:00
cinap_lenrek 5c95c50c6c rio: flushimage() before wscrsleep() 2016-03-23 20:17:58 +01:00
cinap_lenrek e7bc98b057 devtls: zero secret information before freeing, cleanup 2016-03-23 13:50:58 +01:00
cinap_lenrek 44b80d48af stats: fix display->locking race 2016-03-23 11:19:36 +01:00
cinap_lenrek aa6673fcfb add portable AES-GCM (Galois/Counter Mode) implementation to libsec and devtls 2016-03-23 02:45:35 +01:00
cinap_lenrek 7ff779ff52 rio: add flushimage() after mb2 menu action 2016-03-22 17:48:08 +01:00
BurnZeZ 9b874fb5cb rio botch 2016-03-19 20:27:09 -04:00
BurnZeZ db7970fa83 file(1): print warnings on /fd/2, remove some duplicate strings, whitespace fixes 2016-03-19 20:09:44 -04:00
BurnZeZ 730578d40c games/life: add -d delay parameter, -b color reversal parameter, and update manpage 2016-03-19 20:03:10 -04:00
BurnZeZ e1f7e472cf lib9p: remove duplicate variable assignment in createfile() 2016-03-19 17:58:35 -04:00
BurnZeZ 18046fd815 rio: fix some spacing, slightly cleaner arg handling 2016-03-19 17:50:33 -04:00
BurnZeZ 8c9d28f4f8 libdraw: have openfont() set error string 2016-03-19 17:47:25 -04:00
BurnZeZ e387915a8f libc: trailing whitespace cleanup 2016-03-19 17:35:36 -04:00
cinap_lenrek d094b7faa1 ip/gping: add main pid to pid list for killall() 2016-03-18 08:59:01 +01:00
cinap_lenrek a2be120ea9 abandon streaming experiment
for queue like non-seekable files, it is impossible to implement an
exportfs because one has to run the kernels devtab read() and write()
in separate processes, and that makes it impossible to maintain 9p message
order as the scheduler can come in and randomly schedule one process before
another.

so as soon as we have a transition from 9p -> syscalls, we'r screwed.

i currently see just two possibilities:

- introduce special file type like QTSEQ with strictly ordered i/o semantics
- fix all fileservers and exportfs to only do one outstanding i/o to QTSEQ files
which means maintaining a queue per fid

this doesnt propagate. so exporting slow 9p mount again will be limited
again by latency of the inner mount.

other option:

- return offset in Rread, so client can bring responses back into order. this
requires changing all fileservers and drivers to maintain such an per fid offset
and change the protocol to include it in the response, and also pass it to userspace
(new syscalls or pass it in TOS)

this only works for read pipelining, write is still screwed.

both options suck.

--
cinap
2016-03-17 17:48:19 +01:00
cinap_lenrek 5aaa7240a2 libc: fix runestrecpy() return value (thanks spew) 2016-03-16 17:27:00 +01:00
cinap_lenrek 7f224a8f6d ppp: fix buffer overflow, set correct state after chap negotiation (thanks k0ga)
(ppp->secret comes from factotum and it can have any size)
This patch also sets the correct state after success and
failure cases in chap negotiation (without them the code was
working because it expected the other point to pass to net
phase or due to the timer).
2016-03-15 22:31:03 +01:00
cinap_lenrek 708178e615 ppp: Small format and log fixes (thanks k0ga) 2016-03-15 22:19:19 +01:00
cinap_lenrek bd0f48b357 ppp: md5 and mschap inside chap, do not request encryption with -c or -C (thanks k0ga)
p2.patch: Do not request encriptation with -c or -C in ppp
(it was a bit annoying request compression, and when the ACK
from the server was received then send a NAK).

p3.patch: Add support for md5 and mschap in in chap
(without this patch ppp was passing to the net stage
without worring about chap).
2016-03-15 22:18:05 +01:00
cinap_lenrek 74d4d8a26e pppoe: Add support for -c and -C to enable/disable header compression (thanks k0ga) 2016-03-15 22:10:54 +01:00
cinap_lenrek 8b9f36dbe2 rio: flushimage() improves your ability to see, i repeat twice. 2016-03-15 22:06:11 +01:00
cinap_lenrek 02f37359b0 rio: remove more unneccesary flushimage() calls 2016-03-15 18:32:05 +01:00
cinap_lenrek 6974a1ecb6 uhtml: dont trust charset=utf-8 attribute, verify.
when the charset is explicitely specified as utf-8, ignore it
for now. we'll assume utf-8 when all bytes have been properly
utf-8 encoded.
2016-03-13 23:47:24 +01:00
cinap_lenrek 394733c17b kbdfs: map Kup/Kdown the same in shift tab (fixes shift-[up]/[down] one-line scroll in rio over drawterm/vncs) 2016-03-13 21:38:28 +01:00
cinap_lenrek 7b8fcd1269 libdraw: don't flush in readmouse() when theres nothing to flush 2016-03-13 00:03:42 +01:00
cinap_lenrek 2dddca9847 ip/gping: ignore advice, fix packet corruption check, remove dead code 2016-03-12 23:27:49 +01:00
cinap_lenrek 8f2d9a139f devip: handle ignoreadvice flag for all protocols 2016-03-12 23:07:58 +01:00
cinap_lenrek 090a404732 vncs: parse screenid as long, not short: BGSHORT() -> BGLONG() 2016-03-12 22:36:00 +01:00
cinap_lenrek 84851b33cf libdraw: remove flushimage calls from fontresize() and loadchar() 2016-03-12 22:01:43 +01:00
cinap_lenrek 31c3941e87 ip/gping: set display->locking before starting mouseproc (race) 2016-03-12 21:44:58 +01:00
cinap_lenrek bf04ac5173 libsec: remove weakCipher[] array check as we do not support any of these weak ciphers 2016-03-12 13:24:46 +01:00
cinap_lenrek 8a2d962570 mothra: dynamically allocate buffer for refresh url (was 20 bytes stack buffer before) (thanks BurnZeZ for reporting) 2016-03-11 21:46:49 +01:00
ftrvxmtrx fb1551e997 libvorbis: update to 1.3.5 2016-03-10 22:43:00 +01:00
cinap_lenrek 0276031c01 make kernel UTFmax and Runemax consistent with libc (21-bit runes) (thanks maurice) 2016-03-10 20:02:36 +01:00
cinap_lenrek 3e52ada202 merge 2016-03-10 19:03:28 +01:00
cinap_lenrek 51115b9214 aan: handle case when reader closes netfd
when netfd is closed and set to -1 by the fromnet()
reader proc, handle it like network failure and try
reconnecting.
2016-03-10 18:50:29 +01:00
cinap_lenrek 28bd8adce7 devcons: nil vs 0 2016-03-10 03:28:36 +01:00
cinap_lenrek 595501b005 kernel: make fversion()/mntversion() types consistent 2016-03-10 03:02:28 +01:00