summaryrefslogtreecommitdiff
path: root/sys/src/libc
AgeCommit message (Collapse)Author
2017-12-31libc: constant time implementation for encode(2) routines, fix base32cinap_lenrek
the string encoding functions touch secret key material in a bunch of places (devtls, devcap), so make sure we do not leak information by cache timing side channels, making the encoding and decoding routines constant time. we also expose the alphabets through encXchr()/decXchr() functions so caller can find the end of a encoded string before calling decode function (for libmp). the base32 encoding was broken in several ways. inputs lengths of len%5 == [2,3,4] had output truncated and it was using non-standard alphabet. documenting the alphabet change in the manpage.
2017-10-28libc: improve alignment of QLp structure on amd64, cosmeticscinap_lenrek
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-26libc: wunlock() part 2cinap_lenrek
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-20libc: cleanup atexit and put exits() in its own compilation unitcinap_lenrek
this avoids having to pull in atexit() and its dependencies (lock(), unlock()) into every program. (as exits() is called by _main() from main9.s).
2016-11-05libc: move calloc() into its own compilation unitcinap_lenrek
move calloc() in its own compilation unit to avoid code duplication. also, calloc() is used rarely in plan9 programs.
2016-09-11libc: dont use floating point for portable umuldiv(), use 64 bit uvlongcinap_lenrek
2016-08-27libc: add poolisoverlap() and definitions for Pool *secrmemcinap_lenrek
2016-06-26libc: native _addv() and _subv() routines for armcinap_lenrek
2016-05-04retire the dec alpha portcinap_lenrek
2016-04-13libc: fix out of bounds access in dirpackage(), simplifycinap_lenrek
- 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-13libc: remove unneeded #include <auth.h> for crypt() and netcrypt()cinap_lenrek
2016-03-19libc: trailing whitespace cleanupBurnZeZ
2016-03-16libc: fix runestrecpy() return value (thanks spew)cinap_lenrek
2016-01-07introduce signed intptr and %z format modifier for formating uintptr and intptrcinap_lenrek
2015-10-04libc: add _uv2d()/uv2f() and _vas*d() functions to vlrt.ccinap_lenrek
on 32 bit archs, implement 64 bit vasop with floatingpoint right hand side. also added is uvlong->double conversion function.
2015-09-06libc: remove privfree(), simplify privalloc()cinap_lenrek
2015-08-25fix fuckupglenda
2015-08-25import E script from bell labsmischief
2015-08-25libc: import more endianness fixes (thanks cherry9)mischief
from https://bitbucket.org/cherry9/plan9-loongson/
2015-08-10libc: fix wunlock() libthread deadlockcinap_lenrek
when wunlock() was used by threads running within the same proc, the wunlock() can deadlock as it keeps holding the RWLock.lock spinlock while indirectly calling _threadrendezvous(). when _threadrendezvous() switches to another thread in the same proc, then that thread can hang at rlock()/wlock()/runlock() again waiting for wunlock() to release the spinlock which will never happen as lock() does not schedule threads. wunlock() is changed to release the spinlock during rendezvous wakeup of readers. note that this is a bit dangerous as more readers might queue concurrently now which means that if we cannot keep up with the wakeups, we might keep on waking readers forever. that will be another patch for the future.
2015-08-09libc: fix spim endiannessmischief
2015-08-08fix library mkfiles for objtype=spimcinap_lenrek
2015-08-03libc: make atoi() not parse c-style octal and hex numberscinap_lenrek
interpreting octal breaks parsing of decimal numbers with leading zeros. the manpage listed this in the BUGS section, so we'r going to fix it as this just causes confusion as most callers of atoi() do not expect it.
2015-07-07libc/arm: implement _tas() with LDREX/STREX, execute memory barrier on smp ↵cinap_lenrek
systems (zynq)
2015-05-17libc: use Runemax instead of hardcoded 0x65536 for fmtchar check (thanks qrstuv)cinap_lenrek
2015-04-08pool: avoid triggering assert(b->magic != FREE_MAGIC) in blocksetsize() for ↵cinap_lenrek
mallocalignl() when we trim the front of a block with freefromfront(), the block magic of the back was not initialized which could sometimes trigger the assert in blocksetsize() to fail. fix is to just move the initialization of the magic field before the blocksetsize() call. the second b->magic = UNALLOC_MAGIC isnt really required but just done for consistency with the trim() code above.
2015-02-26pool: maintain Pool.curalloc for poolallocalign() and blockgrow()cinap_lenrek
blockgrow() and poolallocalign() change the size of allocated blocks which needs to be accounted for in Pool.curalloc.
2015-02-11libc: check name in getvent()/putenv()cinap_lenrek
passing "", "." or ".." as name caused a crash in getenv() as it would open the directory; then seek() to determine the file size would fail and return -1. now checking for these special names and set error string when its bad. doing a single read() will not work when /env has a 9p fileserver mounted onto it and the file size is bigger than the i/o unit. so doing incremental reads until we get eof.
2015-01-05pool: more strict checktree() for poolcheckcinap_lenrek
check that Free.next and Free.prev pointers are not nil. check that Free.left and Free.right are Poison in non-tree nodes. check that Free.left and Free.right are *not* Poison in tree nodes. change Poison to 0xffffffffcafebabe for 64bit machines.
2014-12-25getfcr: change getfcr/setfcr to use VFPcinap_lenrek
2014-11-07libc: import cleaned up syslog() function from sourcescinap_lenrek
this fixes a potential format string problem where the error string is passed to werrstr() as fmt. also, the directory comparsion is simplified in this version using a helper function.
2014-11-07libc: improve dial error handlingcinap_lenrek
when dial is called with a generic dialstring, it will try /net and /net.alt in sequence. error out if the /net dial gets interrupted and do not continue dialing /net.alt. reduce stack usage by using the swaping nature of errstr() instead of keeping two error string buffers on the stack.
2014-11-05libc: allow dial to be interruptedmischief
previously, if dial was interrupted by an alarm or other note while connecting to a host that resolved to multiple ips, dial would ignore the interruption and try the next host. now dial properly returns with error when it is interrupted.
2014-05-23libc: avoid static table and supurious reads in nsec()cinap_lenrek
use two per process memory slots, one for the pid and one for the fd instead of a global table avoiding the case when the table gets full. instead of calling pread() on the cached fd (dangerous as it has side effects when the fd was not closed), we check if the cached fd is still good using fd2path() when called the first time in this process.
2014-05-20libc: revert nsec() change, bring back filedescriptor cachingcinap_lenrek
theres big performance regression with this using cwfs. cwfs calls time() to update atime on every read/write which now causes walks on /dev. reverting to the previous version for now. in the long run, we'll use new _nsec() syscall but this has to wait for a later release once new kernels are established.
2014-05-20add _nsec() syscall 53 for binary compatibility with labs distributioncinap_lenrek
the new syscall is added under the symbol _nsec() for binary compatibility. nsec() is still a library function reading /dev/bintime.
2014-05-20libc: dont cache /dev/bintime filedescriptor for nsec()cinap_lenrek
2014-04-09libc: allow announce address of the form #I1/tcp!*!564cinap_lenrek
we allow protocol path to begin with # for dial, so should allow this for announce as well. this is primarily usefull when booting the fileserver to listen on alternate ip stack.
2014-02-25csdial: avoid useless werrstr() call on success (thanks mischief)cinap_lenrek
2014-02-17prof: properly save and restore RARG for amd64cinap_lenrek
amd64 passes first argument in RARG (BP) register which has the be preserved duing _profin() and _profout() calls. to handle this we introduce _saveret() and _savearg(). _saveret() returns AX, _savearg() returns RARG (BP). for archs other and amd64, _saveret() and _savearg() are the same function, doing nothing. restoing works with dummy function: uintptr _restore(uintptr, uintptr ret) { return ret; } ... ret = _saveret(); arg = _savearg(); ... return _restore(arg, ret); as we pass arg as the first argument, RARG (BP) is restored.
2014-02-14libc: remove malloc.acid and pool.acidcinap_lenrek
2014-02-06pool: use uintptr for pool sizecinap_lenrek
note, arenas and blocks still use ulong for sizes. so we have to check for overflow when attempting to merge arenas.
2014-02-02malloctag: only store lower 32bit of malloc tag, fix getrealloctagcinap_lenrek
as erik quanstro suggests, theres not much of a point in storing the full 64bit pc as one cannot get a code segment bigger than 4G and amd64 makes it hard to use a pc that isnt 64bit sign extension of 32bit. instead, we only store ulong (as originally), but sign extend back when returning in getmalloctag() and getrealloctag(). getrealloctag() used to be broken. its now fixed.
2014-02-02mallocalign: make sure alignptr offset is modulo align when -offset > aligncinap_lenrek
2014-02-01libc and ape support for amd64cinap_lenrek
2014-01-20malloc: change malloc and realloc tag types to uintptrcinap_lenrek
2013-12-17pool: update debug log format string for poolallocalign()cinap_lenrek
2013-10-17libc: updated acid files for 21 bit rune changecinap_lenrek
2013-10-08libc: remove doprintcinap_lenrek
2013-09-26reverting semaphore lock changes from sources (r41ccd6d221da, rb28756e5ba29)cinap_lenrek
semaphore locks have much higher overhead than initially presented in the "Semaphores in Plan9" paper. until the reason for it has been found out i will revert the changes.