Commit Graph

76 Commits

Author SHA1 Message Date
Giacomo Tesio 1e34cf5efb copyright: update 9front's url (they moved from hg to git) 2021-12-30 00:55:39 +01:00
Giacomo Tesio 0adf1b0431 new build: get rid of Go with few rc scripts. 2021-12-30 00:55:06 +01:00
Giacomo Tesio 922e993c41 libs, kernel and commands: re-enable -Werror 2020-11-15 13:30:09 +01:00
Giacomo Tesio 75b451ea1c kern: move `load` from Mach to Sys 2020-09-17 23:49:26 +02:00
Giacomo Tesio f104c46858 purge syscall macros 2020-09-17 23:45:23 +02:00
Giacomo Tesio 2bf39bf38a kern: rename /dev/swap in /dev/sysmem
Jehanne has no SWAP.

And I do not want to explain to my daughters what SWAP **was**.
2018-01-07 07:14:08 +01:00
Giacomo Tesio d04c776f3c Fix Minnich's Copyrights
As far as I can remember the new `dc` argument added to the `mount`
system call is the only API innovation that I imported from Harvey-OS
in the Jehanne's kernel.

It's a great idea of Ronald G. Minnich, introduced at

	72777a1fab

Since he didn't amended the copyright statements in Harvey, I forgot
to amend it here.

Sorry, my fault.
2018-01-06 01:09:04 +01:00
Giacomo Tesio c7d0f621c9 Clarify Forsyth's and 9front's copyrights
I'm very grateful to Charles Forsyth for creating most of Jehanne's kernel
and to 9front's guys for all the code and ideas they freely share.

Here I make their copyrights explicit as they had been erroneusly omitted
or messed up before. Sorry.
2018-01-05 02:30:45 +01:00
Giacomo Tesio 7f1ba356f1 kern: devproc: forbid open(OWRITE) of notes in Broken proceses 2017-12-15 02:58:09 +01:00
Giacomo Tesio c48d0e46ec kern: do not read wdir size on Broken processes 2017-12-15 02:58:09 +01:00
Giacomo Tesio a3918b108d kern: awake must not interrupt flushes in dev9p
While sending Tflush after a wakeup, we might call sleep.

Since the awake was not yet consumed, the new sleep was interrupted
causing a new Tflush, in an infinite loop that consumes all tags.
2017-12-15 02:58:09 +01:00
Giacomo Tesio 799f99a40f kern: fix pprint on invalid address at syspread 2017-12-15 02:58:09 +01:00
Giacomo Tesio b73c2bce14 kern: awake & dev9p: do not interrupt Tflush to avoid consuming all tags 2017-12-15 02:58:09 +01:00
Giacomo Tesio 3946a06a98 kern: dev9p: Rwrite's count can be greater than Twrite's one 2017-12-15 02:58:09 +01:00
Giacomo Tesio 726217c766 kern: fix proc ref counting in procread 2017-12-15 02:58:09 +01:00
Giacomo Tesio 2b62ed8010 kern: keep reading /proc/n/syscall after process death, to get all messages 2017-12-15 02:58:09 +01:00
Giacomo Tesio 9aea97a51f kern: fix fmtrwdata on nil buffers 2017-12-15 02:58:09 +01:00
Giacomo Tesio 8ea71b1c66 kern: fix very old bug in syscall tracing 2017-12-15 02:58:09 +01:00
Giacomo Tesio 7ae04d282f kern: devproc: add ppid; enable `rm -e noteid` 2017-12-15 02:56:57 +01:00
Giacomo Tesio 26bd1d8dc4 kern: fix working dir after ns clone
After sending the "clone" request to /proc/$pid/ns, the current process
will be moved to the working directory of $pid.

Otherwise the current process could still access the file and folders
on the service providing its dot, even if such service was not visible to $pid.

Also, keeping the original working directory means that the 'cd' line of the
current process's ns file would be different from that of $pid: the two ns
files must match since the command asked for a "clone".

See also https://marc.info/?l=9fans&m=150893734909969&w=2
2017-10-25 02:06:29 +02:00
Giacomo Tesio 2836ae4d66 kern: improve procfdprint and procfds in devproc 2017-10-25 01:35:34 +02:00
Giacomo Tesio c17d5bdb18 kern: cleanup procread for Qnote 2017-10-25 01:33:51 +02:00
Giacomo Tesio 70d5961022 kern: add missing poperror() to awake_gc_proc 2017-10-25 01:30:07 +02:00
Giacomo Tesio 430df16543 kernel: ignore errors on awake_gc_proc
Calling resrcwait in awake_gc_proc (that is called from pexit and thus
from sys_exits) means that we have to ignore errors that could cause
the syscall to return.

The funny part here was that one single test for newlib showed the
issue by faulting in a note handler AFTER completing with success:

	/arch/amd64/qa/lib/newlib/sigchld/213-sigqueue

The fact was that in the executable, the function notifier() was
located just after the exits() function, whose last line was a call
to _exits().

Thus, when the _exits returned, the notifier() code was executed.
2017-10-25 01:22:01 +02:00
Giacomo Tesio 90c3415176 kernel: fix _procfdprint to use chan's flags 2017-10-25 01:17:31 +02:00
Giacomo Tesio ba11888753 kern: proc, dup: _procfdprint OCEXEC and ORCLOSE
In _procfdprint print additional informations in the second column:

	E is printed if the file was open with OCEXEC flag
	D is printed if the file was open with ORCLOSE flag

Example output:
  3  rE  9   46 (0000000000000001 0 00)  8192       13 /dev/cons
2017-10-25 01:16:45 +02:00
Giacomo Tesio 320e6e6f35 kern: clone $pid's namespace writing #p/$pid/ns
Any process X can get a new copy of the namespace of a target
process Y by writing the string "clone" to the ns file of Y.

The same user must own both processes.
The process writing the ns file must be allowed to mount.

The Pgrp of the calling process is then replaced with a new copy of
the Pgrp of the target process.

After the operation, any change done by X to its own namespace does
not affect Y. Also, if mount was forbidden for Y, it will also be
forbidden for X after the clone.
2017-10-24 23:28:14 +02:00
Giacomo Tesio 63b227be55 elf64ldseg: do not pprint warnings on wrong header as it could simply be an rc script 2017-08-21 23:59:40 +02:00
Giacomo Tesio e0e45fba5a kernel: removed unreachable code in fault (CID: 155701)
If the user process does not have a segment holding the required addr
the fault function return early.
2017-08-15 01:07:48 +02:00
Giacomo Tesio 55a8a84d8d kernel: fix potential overflow in updatecpu (CID 155825) 2017-08-15 00:54:15 +02:00
Giacomo Tesio 0b8a66f877 kernel: umem: fix img_get macro
The img_get macro used to subtract 1 to the argument provided before
computing the porinter to the image. I can't remember why it did so.

However the expression was wrong.

Coverity found the issue:

	Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
	CID:	155616, 155606, 155598, 155597, 155596, 155587,
		155580, 155578, 155577, 155576, 155568, 155566

Simply removing the subtraction seems the obvious fix.
2017-08-15 00:38:09 +02:00
Giacomo Tesio b056df2da6 kernel: simplify sysnotify; should fix CID 156151 (Wrong sizeof argument) 2017-08-14 19:52:22 +02:00
Giacomo Tesio 17c9087965 kernel: fix typo in sysexec (CID 156141) 2017-08-14 19:34:34 +02:00
Giacomo Tesio 180da90a06 kernel: fix args crossing page boundaries in sysexec
Should also fix CID 155615 (Operands don't affect result)
2017-08-14 19:25:54 +02:00
Giacomo Tesio 21b5682a43 kernel: syspread: avoid negative offsets in dir reads
Should also fix CID 160109: Dereference after null check
2017-08-14 18:40:25 +02:00
Giacomo Tesio 033744b5be kernel: awake: fix CID 174310: Out-of-bounds read 2017-08-13 21:59:03 +02:00
Giacomo Tesio 93dfad6b0b kernel: print proc info on addbroken 2017-08-12 23:32:35 +02:00
Giacomo Tesio 93dde48355 kernel: deep refactoring and cleanup
This large commit address several issues
- removed 386 directory: Jehanne is 64bit only
- simplified kernel options management
- rewritten boot process
- ported memory related stuff from 9front's 9/pc64
- removed devacpi
- removed old code
- deep refactor of awake syscall
- removed MCACHE support for mount
- fix libc's setjmp/longjmp
2017-08-11 03:18:32 +02:00
Giacomo Tesio 1bc08b7631 kernel: rendezvous(~0, ...) unconditionally blocks
This commit introduce a special rendezvous point at (void*)~0 that
cannot be reached by any process, since it's not added to the
rendezvous group.

This turns the rendezvous syscall to a cheap way to block until
either a note or a wakeup from awake(2) occurs.

This new feature is used in libc's sleep: the test qa/kern/fork_chain
has shown that using a stack address as rendezvous point is not safe enougth
for sleep, since two different process forked from the same function can
call sleep with the same base pointer. This lead the wakeup variable in
jehanne_sleep to have the same address on both process.

TODO add a test that show this behaviour in the old code.
2017-07-21 01:49:00 +02:00
Giacomo Tesio 4b7957a28f kernel: simplify init code 2017-05-20 14:06:26 +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 b08218529d devproc: can't wait for up to stop 2017-05-06 16:03:16 +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 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 19bf511603 kernel: devdup: fix dup(n, 0)
Completes e1a14b49be
2017-01-24 22:24:55 +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