Commit Graph

95 Commits

Author SHA1 Message Date
Giacomo Tesio 901962f6c9 cmds: avoid duplicated compilation of ip tools 2017-05-19 00:54:23 +02:00
Giacomo Tesio 22d90985a5 kernel: awake() wake up only truly blocking syscalls
If a syscall did not entered sleep(), the pendingWakeup is not consumed.
2017-05-17 02:04:08 +02:00
Giacomo Tesio 1dc8991331 kernel: reset and restore up->cursyscall in trap
This way sleep() knows that it should not interrupt the process
to serve awake().

Also rename Proc.insyscall to Proc.inkernel since that's the meaning
of the flag, which is only read to serve awake()'s mechanics and
to accounttime(). Indeed faultAmd64 was setting insyscall to 1.
2017-05-17 01:16:49 +02:00
Giacomo Tesio 2b1baf8de1 kernel: devpipe: fix error management on writes
The "write on closed pipe" note should be posted only
if the write occurred on a closed pipe.

Before this fix, on any interrupt caused the note to be sent,
despite the pipe being open and fully working.
2017-05-17 00:27:57 +02:00
Giacomo Tesio 031201a1ac kernel: reset process wakeups on exec 2017-05-15 00:35:22 +02:00
Giacomo Tesio f9b2e9aba4 kernel: generalize awake
Awake can now interrupt several blocking syscalls (even
during note handling).

Among others, it can interrupt await, pread and pwrite.

It cannot interrupt several others for different reasons:

- awake cannot be interrupted by awake;
- syscalls like remove and create can be used for kernel comunication
  and it would be hard to know if the effect occurred in the
  receiving fs if they were interrupted;
- other syscalls do not need awake since they just provide access
  to kernel infos (eg seek or fd2path)

NOTE: awakes registered before a note cannot occur during the note
handling and will be deferred till the next call to noted.
2017-05-15 00:05:59 +02:00
Giacomo Tesio 79f8204766 kern: move tsemaquire to userspace (given a generalized awake) 2017-05-12 11:13:19 +02:00
Giacomo Tesio 46664994d4 libposix: fix usleep 2017-05-12 11:13:08 +02:00
Giacomo Tesio aa4172a1de libposix: document timers 2017-05-08 23:46:19 +02:00
Giacomo Tesio a3791c88f7 libposix: add usleep 2017-05-08 23:45:46 +02:00
Giacomo Tesio d62ca1162f Merge branch 'libposix-new-signals' of https://bitbucket.org/tesio/jehanne into libposix-new-signals 2017-05-08 22:54:34 +02:00
Giacomo Tesio edc116ef45 libposix: documented new signal machinery 2017-05-08 00:43:35 +02:00
Giacomo Tesio 333d5dcbcd Merge branch 'master' into libposix-new-signals 2017-05-07 19:44:47 +02:00
Giacomo Tesio b08218529d devproc: can't wait for up to stop 2017-05-06 16:03:16 +02:00
Giacomo Tesio 8d5eb5914f libposix: fix default_signal_disposition 2017-05-06 13:33:08 +02:00
Giacomo Tesio da0381a213 libposix: big refactor of signal handling 2017-05-05 19:01:18 +02:00
Giacomo Tesio d29859684b libposix: complete POSIX_signal_execute 2017-05-03 03:02:56 +02:00
Giacomo Tesio bd5063666f libposix: introduce POSIX_signal_execute and PosixSignalDisposition enum 2017-05-03 01:14:53 +02:00
Giacomo Tesio cf974abe0e libposix: (almost working) waitpid 2017-05-02 00:57:18 +02:00
Giacomo Tesio 8c33c921b4 libposix: draft waitpid (still broken) 2017-05-01 23:57:05 +02:00
Giacomo Tesio 14934ee51f libposix: sleep and pipe 2017-04-30 16:49:50 +02:00
Giacomo Tesio 3707eaece6 libposix: simplify kill 2017-04-30 16:49:01 +02:00
Giacomo Tesio ac33157c37 kern: usbehcipc.c fix CID 155940: Out-of-bounds write 2017-04-25 16:07:47 +02:00
Giacomo Tesio 80a8501c05 kern/ip/gre: fix CID 156224: Uninitialized scalar variable 2017-04-25 15:53:20 +02:00
Giacomo Tesio ea6f34f4f7 kern: mark pexit() as noreturn
Since pexit() calls sched() it wont return to the caller.
Should fix

- CID 155655: Missing break in switch
- CID 155672: Missing break in switch
2017-04-24 09:55:45 +02:00
Giacomo Tesio c2204d83a5 libposix: getppid 2017-04-22 00:40:39 +02:00
Giacomo Tesio d2a0389ae4 fs: no "default" posix library 2017-04-21 23:59:27 +02:00
Giacomo Tesio a1b4085b7b libc: keep __libc_init weak definition private 2017-04-21 23:58:06 +02:00
Giacomo Tesio 4142b70d32 libposix: allow custom translations of exit status 2017-04-21 23:56:43 +02:00
Giacomo Tesio 188a07782d libposix: initial draft 2017-04-19 23:48:54 +02:00
Giacomo Tesio e70feee4a3 libc: introduce "jehanne_" namespace
With this commit all functions declared in libc.h have been renamed
with the "jehanne_" prefix. This is done for several reason:

- it removes conflicts during symbol resolution when linking
  standard C libraries like newlib or musl
- it allows programs depending on a standard C library to directly
  link to a library depending on our non standard libc (eg libsec).

To ease transiction two files are provided:

- sys/include/lib9.h that can be included instead of <libc.h> to use
  the old names (via a simple set of macros)
- sys/src/lib/c/lib9.c that can be compiled with a program where the
  macro provided by lib9.h are too dumb (see for example rc or grep).

In the kernel port/lib.h has been modified accordingly and some of
the functions it directly provides has been renamed too (eg malloc
in qmalloc.c and print in devcons.c).
2017-04-19 23:48:21 +02:00
Giacomo Tesio 64466d840e libc.h: simplify ARGBEGIN macro
Should fix CID 155592 since the idiom:

	argv0 = nil;
	ARGBEGIN{
		...
	}ARGEND

would not produce logically dead code.
2017-02-08 00:19:22 +01:00
Giacomo Tesio 7609abaaf3 libauth: fix potential null deref in auth_proxy
Should fix CID 155820
2017-02-08 00:07:01 +01:00
Giacomo Tesio 1f59502bf5 kernel/boot: #ec/console (from kernel args) defines the console to start 2017-02-04 01:04:51 +01:00
Giacomo Tesio 19bf511603 kernel: devdup: fix dup(n, 0)
Completes e1a14b49be
2017-01-24 22:24:55 +01:00
Giacomo Tesio edd84db070 kernel: import 9front's PCI improvements 2017-01-24 22:24:43 +01:00
Giacomo Tesio c2b06ebf80 kernel: fix out of bound read in trap()
Reported by coverity, CID 155927: if vno == 32 it would access index
32 of excname at trap.c:339.
2017-01-24 22:24:20 +01:00
Giacomo Tesio 6dd0f2e130 kernel: use pprint instead of print in elf64ldseg.
Should also fix CID 156242, CID 156240 and CID 156236 avoiding
access to uninitialized pointers (get64, get32 and get16).
2017-01-24 22:23:17 +01:00
Giacomo Tesio db8aab1a04 kernel: boot: fix more dup() leaks reported by coverity 2017-01-24 22:22:58 +01:00
Giacomo Tesio aa25654232 libsec: improve fix #4: check valid length in TLS (msgRecv)
This commit should complete the work done at 90fe80e73b

Should also fix CID 155874.
2017-01-24 22:22:20 +01:00
Giacomo Tesio 65cdad4317 libc: rewrite putenv and getenv.
These new implementations

- do several validity check on input parameters
- allow a bit larger variable names (127 bytes, aka sizeof(Proc.genbuf)-1)
- preserve nulls in the content (the original version used to replace
  '\0' with ' '). I can't see why they did, actually.
  See also http://marc.info/?l=9fans&m=148475801229908&w=2

Should also fix CID 155718
2017-01-19 00:58:43 +01:00
Giacomo Tesio d43be3861b libc: fix potential nil dereference in system() posix wrapper
Should also fix CID 155750.
2017-01-18 23:36:18 +01:00
Giacomo Tesio b05c21397e libc: rewrite brk() and sbrk()
Also fix Coverity 1 scan defects, CID 155773 and CID 155768, removing
less-than-zero comparisons of unsigned values that were never true.
2017-01-18 23:35:41 +01:00
Giacomo Tesio 6e816b293d libmp: fix #6: mptole takes `p` xor `pp`
See commit 0f82a2c3c3 for further info

Also fix build after typo.
2017-01-18 01:59:44 +01:00
Giacomo Tesio 0f82a2c3c3 libmp: fix #5: mptole takes `p` xor `pp`
According to http://man.cat-v.org/9front/2/mp mptole either take p or pp:

> Mptobe and mptole convert an mpint to a byte array.  The
> former creates a big endian representation, the latter a
> little endian one.  If the destination buf is not nil, it
> specifies the buffer of length blen for the result.  If the
> representation is less than blen bytes, the rest of the
> buffer is zero filled.  **If buf is nil**, then a buffer is
> allocated and a pointer to it is deposited in the location
> pointed to by **bufp**. Sign is ignored in these conversions,
> i.e., the byte array version is always positive.

Assert accordingly.
2017-01-18 01:47:31 +01:00
Giacomo Tesio 90fe80e73b libsec: fix #4: Finished.n can only be 0, 12 or 36
As noted ty Cinap Lenrek Finished.n is only set by setVersion and can only
be either 0 before setVersion() as emalloc() zeros the TlsConnection struct
or SSL3FinishedLen/TLSFinishedLen after when we got the client/server hello.

Introducing FinishedLength enum we make the domain of the field explicit.
2017-01-18 00:24:10 +01:00
Giacomo Tesio 49040ffdaa kernel: boot: fix dup() leaks reported by coverity 2017-01-17 22:01:15 +01:00
Giacomo Tesio e1a14b49be kernel: devdup: fix dup(n, 0)
A successful dup(n, 0) must not return -1L
2017-01-17 21:48:33 +01:00
Giacomo Tesio 207967f9e8 libc: _assert do not return. should fix build 2017-01-17 21:28:56 +01:00
Giacomo Tesio 04962f0637 libsec: fix #3: out-of-bound access in aesXCBCmac (CID 155914) 2017-01-17 21:05:59 +01:00