Commit graph

96 commits

Author SHA1 Message Date
Sanchayan Maity 8501cb7ed8 Allow users to request a asynchronous notification
This patch adds functionality to request an asynchronous notification
if some other process has send a message to it. We currently send a
SIGALRM to avoid any changes to core infrastructure of signal handling.
Ideally we should implement a separate signal for this. Currently there
is an obvious disadvantage of not being able to use SIGALRM with alarm,
if we are using this functionality.
2016-03-22 17:51:09 +05:30
Sanchayan Maity 55d341bc54 Allow users to get and set attributes
Currently we only allow users to get and set number of queues. The
operation is always non blocking. There is no provision for non
blocking operation at the moment.

The queue sizes are set to MAX 256 by default. If a user changes the
attributes and sets the queue size or number of messages in a queue
to less than 256, it is the responsibility of the user to close any
queues which were opened with a descriptor greater than the value
currently set.

For example, by default queue sizes are 256. If 150 queues are opened
and then the user sets the number of queues to 32, all open descriptors
and queues from 32 to 150 must be closed. Note that descriptor number
allocation starts with zero and not one.
2016-03-22 15:57:53 +05:30
Sanchayan Maity 6f36b466f3 minix: Prepare for message queue support to Minix kernel
This commit adds preparatory support for forthcoming message
queue implementation to the Minix kernel. The core implementation
will be added with the next commit.
2016-02-29 20:43:07 +05:30
Jean-Baptiste Boric 69eead77ff New image framework generation
The CD now boots directly from the ISO 9660 filesystem instead of using
MBR partitioning with Minix file systems. This saves some space on the
CD and reduces memory requirements by some unknown amount as the root
ramdisk is completely eliminated.

The x86 hard drive image creation is also rewritten in the same
fashion.

The setup is modified to be more NetBSD-like (unpacking sets
tarballs instead of blindly copying the CD contents). Splitting MINIX
into sets is done in another commit due to it being a nightmare to
rebase.

Since MINIX lacks union mounts for now, a bunch of ramdisks are
generated at run-time to make parts of the filesystem writeable for the
CD. This solution isn't ideal, but it's enough for an installation CD.

Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd
2015-10-10 19:09:35 +02:00
Jean-Baptiste Boric 9dfdf6f7ba ramdisk: fix command output to stdout
Change-Id: I58a8cf2cd05b71dbbc1784c7d5770279392e3a8b
2015-10-08 12:11:03 +02:00
Lionel Sambuc ebfedea0ce Importing crypto libraries
- crypto/external/bsd/heimdal
 - crypto/external/bsd/libsaslc
 - crypto/external/bsd/netpgp
 - crypto/external/bsd/openssl

Change-Id: I91dbf05f33e637edf5b9bb408d5baddd7ba8cf75
2015-10-07 23:37:12 +02:00
David van Moolenbroek b7f0178aeb Import NetBSD time(1)
Change-Id: I035d21a926aa82434c24a84b914bd58ac064e66a
2015-09-29 18:16:14 +00:00
David van Moolenbroek bc2d75fa05 Rework getrusage(2) infrastructure
- the userland call is now made to PM only, and PM relays the call to
  other servers as appropriate; this is an ABI change that will
  ultimately allow us to add proper support for wait3() and the like;
  for the moment there is backward compatibility;
- the getrusage-specific kernel subcall has been removed, as it
  provided only redundant functionality, and did not provide the means
  to be extended correctly in the future - namely, allowing the kernel
  to return different values depending on whether resource usage of
  the caller (self) or its children was requested;
- VM is now told whether resource usage of the caller (self) or its
  children is requested, and it refrains from filling in wrong values
  for information it does not have;
- VM now uses the correct unit for the ru_maxrss values;
- VFS is cut out of the loop entirely, since it does not provide any
  values at the moment; a comment explains how it should be readded.

Change-Id: I27b0f488437dec3d8e784721c67b03f2f853120f
2015-09-28 14:06:59 +00:00
David van Moolenbroek b80da2a01d commands: move manpages into command directories
Change-Id: Icf8a2d26629a1822725022c9ee21c587d3c4c3b4
2015-09-28 14:06:06 +00:00
David van Moolenbroek 7c48de6cc4 Resolve more warnings
Change-Id: Ibc1b7f7cd45ad7295285e59c6ce55888266fece8
2015-09-23 12:04:58 +00:00
David van Moolenbroek 875abb8724 swifi: various improvements
- no longer inject fewer faults than instructed;
- no longer apply a limit on the number of injected faults;
- refactory to allow for random faults (type 99);
- also allow for stop faults (type 50);
- massive dead code cleanup;
- move outdated test cruft into tests/ subdirectory; it is kept only
  as an example of how to use swifi.

Change-Id: I8a3cb71902dfaadb7bf785723b917307db83d0d5
2015-09-23 12:03:12 +00:00
David van Moolenbroek 32b187558b Deprivilege some network commands
At the very least, these can be used to test for the existence of
files not normally accessible by unprivileged users.

Change-Id: I054cf6d033a1604bbbc871db37103a67067abe84
2015-09-23 12:03:12 +00:00
David van Moolenbroek d0055759dd commands: resolve compiler warnings
Change-Id: I95f0d0c48f998d4d950a0800eedd5fbbf2e50423
2015-09-23 12:03:11 +00:00
David van Moolenbroek fd962fdd93 Retire decomp16(1)
Change-Id: I455aac47b3efa4ffa5cc8305c6760f92e1e8642a
2015-09-23 12:03:11 +00:00
David van Moolenbroek c0d9ad695c Retire ci(1), co(1), svclog(1)
Change-Id: I1bd1d92b9aacd4dfc4843c423862ae540fe2b557
2015-09-23 12:03:10 +00:00
David van Moolenbroek 33513d60e9 fbdctl(8): move to proper location
- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: I1206b52e8804a68a3a80f6d7f63916e7fcdc9e3f
2015-09-23 12:03:10 +00:00
David van Moolenbroek c175cce5e6 diskctl(8): move to proper location
- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: Iccb4a8b27ae220254bae19e9198478b40706f542
2015-09-23 12:03:09 +00:00
David van Moolenbroek 964427e0ea btrace(8): move to proper location
- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: I08c16998bd499a468799a6587f6fe45f42590461
2015-09-23 12:03:09 +00:00
David van Moolenbroek d8634bad6a Move OpenBSD diff(1) into minix/usr.bin
Editor's note: NetBSD uses GNU diff.

Change-Id: I15d4441c73e0c626d0e5fda8c8683d131fbcbc38
2015-09-23 12:03:08 +00:00
David van Moolenbroek 319e7a6d07 Update, move NetBSD find(1)
Change-Id: Iccda44465d49dba407d1ac1b1ced8aa8b4e6d8aa
2015-09-23 12:03:08 +00:00
David van Moolenbroek e7ca52fbf9 Import NetBSD cmp
Change-Id: I0e7f6c69742db475ddba6a9159f167a53d151169
2015-09-23 12:03:07 +00:00
David van Moolenbroek 93d36fc9d8 Import NetBSD rcmd, rcp, rsh, rshd
Change-Id: I83d908bbe17f04826e9b5c3a220a5bb2c3a51c80
2015-09-23 12:03:06 +00:00
David van Moolenbroek e4d99eb9b0 Basic live rerandomization infrastructure
This commits adds a basic infrastructure to support Address Space
Randomization (ASR).  In a nutshell, using the already imported ASR
LLVM pass, multiple versions can be generated for the same system
service, each with a randomized, different address space layout.
Combined with the magic instrumentation for state transfer, a system
service can be live updated into another ASR-randomized version at
runtime, thus providing live rerandomization.

Since MINIX3 is not yet capable of running LLVM linker passes, the
ASR-randomized service binaries have to be pregenerated during
crosscompilation.  These pregenerated binaries can then be cycled
through at runtime.  This patch provides the basic proof-of-concept
infrastructure for both these parts.

In order to support pregeneration, the clientctl host script has
been extended with a "buildasr" command.  It is to be used after
building the entire system with bitcode and magic support, and will
produce a given number of ASR-randomized versions of all system
services.  These services are placed in /usr/service/asr in the
image that is generated as final step by the "buildasr" command.

In order to support runtime updating, a new update_asr(8) command
has been added to MINIX3.  This command attempts to live-update the
running system services into their next ASR-randomized versions.
For now, this command is not run automatically, and thus must be
invoked manually.

Technical notes:

- For various reasons, magic instrumentation is x86-only for now,
  and ASR functionality is therefore to be used on x86 only as well.
- The ASR-randomized binaries are placed in numbered subdirectories
  so as not to have to change their actual program names, which are
  assumed to be static in various places (system.conf, procfs).
- The root partition is typically too small to contain all the
  produced binaries, which is why we introduce /usr/service.  There
  is a symlink from /service/asr to /usr/service/asr for no other
  reason than to let userland continue to assume that all services
  are reachable through /service.
- The ASR count field (r_asr_count/ASRcount) maintained by RS is not
  used within RS in any way; it is only passed through procfs to
  userland in order to allow update_asr(8) to keep track of which
  version is currently loaded without having to maintain own state.
- Ideally, pre-instrumentation linking of a service would remove all
  its randomized versions.  Currently, the user is assumed not to
  perform ASR instrumentation and then recompile system services
  without performing ASR instrumentation again, as the randomized
  binaries included in the image would then be stale.  This aspect
  has to be improved later.
- Various other issues are flagged in the comments of the various
  parts of this patch.

Change-Id: I093ad57f31c18305591f64b2d491272288aa0937
2015-09-17 17:15:03 +00:00
David van Moolenbroek c0df94ec22 RS: remove support for unsafe updates
This feature should no longer be necessary.

Change-Id: I9bff628be020cf1741bffaeb3bb97e3660a54aea
2015-09-17 14:09:47 +00:00
David van Moolenbroek abf8a7e7b3 RS/VM: proper preparation for multi-VM live update
Due to changed VM internals, more elaborate preparation is required
before a live update with multiple components including VM can take
place.  This patch adds the essential preparation infrastructure to
VM and adapts RS to make use of it.  As a side effect, it is no
longer necessary to supply RS as the last component (if at all)
during the set-up of a multicomponent live update operation.

Change-Id: If069fd3f93f96f9d5433998e4615f861465ef448
2015-09-17 14:01:06 +00:00
Cristiano Giuffrida 3837bb5c0b rs: Add support for RS_FI.
Change-Id: Id8663859accfc4e3587db35dec7000059860fd49
2015-09-17 13:29:47 +00:00
Cristiano Giuffrida fb6bd596bf rs: New RS.
Change-Id: I46e335d5dac49104028d7cb0706b3e85de752bfe
2015-09-16 15:30:48 +00:00
Cristiano Giuffrida d40f735640 service: Extensions for new RS.
Change-Id: Ifb72c7e8c912709edce0fb9ba9efb570901be5fb
2015-09-16 11:22:14 +00:00
David van Moolenbroek e94f856b38 libminixfs/VM: fix memory-mapped file corruption
This patch employs one solution to resolve two independent but related
issues.  Both issues are the result of one fundamental aspect of the
way VM's memory mapping works: VM uses its cache to map in blocks for
memory-mapped file regions, and for blocks already in the VM cache, VM
does not go to the file system before mapping them in.  To preserve
consistency between the FS and VM caches, VM relies on being informed
about all updates to file contents through the block cache.  The two
issues are both the result of VM not being properly informed about
such updates:

 1. Once a file system provides libminixfs with an inode association
    (inode number + inode offset) for a disk block, this association
    is not broken until a new inode association is provided for it.
    If a block is freed and reallocated as a metadata (non-inode)
    block, its old association is maintained, and may be supplied to
    VM's secondary cache.  Due to reuse of inodes, it is possible
    that the same inode association becomes valid for an actual file
    block again.  In that case, when that new file is memory-mapped,
    under certain circumstances, VM may end up using the metadata
    block to satisfy a page fault on the file, due to the stale inode
    association.  The result is a corrupted memory mapping, with the
    application seeing data other than the current file contents
    mapped in at the file block.

 2. When a hole is created in a file, the underlying block is freed
    from the device, but VM is not informed of this update, and thus,
    if VM's cache contains the block with its previous inode
    association, this block will remain there.  As a result, if an
    application subsequently memory-maps the file, VM will map in the
    old block at the position of the hole, rather than an all-zeroes
    block.  Thus, again, the result is a corrupted memory mapping.

This patch resolves both issues by making the file system inform the
minixfs library about blocks being freed, so that libminixfs can
break the inode association for that block, both in its own cache and
in the VM cache.  Since libminixfs does not know whether VM has the
block in its cache or not, it makes a call to VM for each block being
freed.  Thus, this change introduces more calls to VM, but it solves
the correctness issues at hand; optimizations may be introduced
later.  On the upside, all freed blocks are now marked as clean,
which should result in fewer blocks being written back to the device,
and the blocks are removed from the caches entirely, which should
result in slightly better cache usage.

This patch is necessary but not sufficient to resolve the situation
with respect to memory mapping of file holes in general.  Therefore,
this patch extends test 74 with a (rather particular but effective)
test for the first issue, but not yet with a test for the second one.

This fixes #90.

Change-Id: Iad8b134d2f88a884f15d3fc303e463280749c467
2015-08-13 13:46:46 +00:00
David van Moolenbroek 162f54c289 service(8): no need to include kernel headers
Change-Id: I8fb7a1a58457909b7759a74925a12cf9b11261f0
2015-08-13 13:44:57 +00:00
Jacob Adams 7b2da7b2c7 update_bootcfg(8): Add actually useful information
Change-Id: I3f1aa2141827b3dc4072f2e8cedeecb40006e626
2015-07-28 10:03:50 +00:00
Jacob Adams e01448dd84 Close #83 with fix suggested
Change-Id: I83975a0963d09eab73df62adf81ce8027ca41bb0
2015-07-28 09:58:12 +00:00
David van Moolenbroek 3e07920fe2 Import NetBSD syslogd(8)
The primary reason for the import is a likely GPL taint of the
original MINIX3 syslogd.  As a result, this import may still
have some rough edges.

Change-Id: I5c8d26eca10fc2dd50ecc9eab44a1d483cf068a9
2015-07-26 11:57:04 +00:00
David van Moolenbroek da21d85025 Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.

In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well.  Test77 has been extended with new tests, and
no longer needs to run as root.

The new functionality is optional.  To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.

Technical nodes:

o The reason for not implementing the NetBSD /dev/ptm approach is that
  implementing the corresponding ioctl (TIOCPTMGET) would require
  adding a number of extremely hairy exceptions to VFS, including the
  PTY driver having to create new file descriptors for its own device
  nodes.

o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
  driver has to be aware of old-style PTY naming schemes and even has
  to call chmod(2) on a disk-backed file system.  PTY cannot be its
  own PTYFS since a character driver may currently not also be a file
  system.  However, PTYFS may be subsumed into a DEVFS in the future.

o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
  slave nodes are created on ptyfs only upon the first call to
  grantpt(3).  This approach obviates the need to revoke access as
  part of the grantpt(3) call.

o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
  restarted, these leftover slave nodes will be removed before they
  create a security risk.  Unmounting PTYFS will make existing PTY
  slaves permanently unavailable, and absence of PTYFS will block
  allocation of new Unix98 PTYs until PTYFS is (re)mounted.

Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-23 17:43:46 +00:00
Jacob Adams d9494baa34 cawf: Update K&R function declarations
Change-Id: Ib18171089c7b389f7f2643d7298f9659e882f65c
2015-05-18 15:20:39 +02:00
Jacob Adams c6748a4a93 cawf: Fix buffer scope
Change-Id: I03f9066c20da142034626b07d0b07c446075b8af
2015-05-18 15:20:36 +02:00
Jacob Adams c14bb31e67 sprofalyze: Fix minor typo
Change-Id: I0a419833fb2f438808613737680ace7246713ee9
2015-05-18 13:54:19 +02:00
Jacob Adams be4841096d Add manpage for sprofdiff
Change-Id: Ifa98ab133ef818d21921f05db650069448ea52ff
2015-05-18 13:52:13 +02:00
Jacob Adams 2a6b817353 Add manpage for sprofalyze
Change-Id: I206a5878e8f788ea4ff742453148462959263a6a
2015-05-18 13:41:29 +02:00
Jacob Adams c19d619d42 Importing bin/dd
Change-Id: Ibdfed821aa834419c9713dc80f698c8ed74ff269
2015-04-15 13:50:57 +02:00
Jacob Adams 3a1943c1c1 devmand: properly prevent overflow
closes #22

Change-Id: Ia10f352a7ff5b05b1095dbb65d36316f9165a6f0
2015-04-15 08:28:59 +02:00
Thomas Cort 93cdb3a735 mined: move to minix/usr.bin/mined
As suggested in issue #43.

Historic Locations:

Prior to this commit

  minix/commands/mined

Prior to commit 433d6423c3

  commands

Change-Id: I374ab3ff0e3b9e47779fc21e80b47fda87698242
2015-03-28 08:39:10 +01:00
Thomas Cort e6df9032b3 mined: remove !__STDC__ code blocks.
__STDC__ is used to mitigate the differences between K&R C and the
ANSI C standard. Nearly every compiler now supports ANSI C, so
there is no need to support non-standard compilers.

Change-Id: Ifc3381ecf1c43dfde9004bee48552d8b3ac4dcdc
2015-03-28 08:38:56 +01:00
Thomas Cort f3734d6b31 mined.h: use '\a' instead of ascii code for bell.
Makes the code slightly more portable and readable.

Change-Id: I45bbecb6dc1c320c9412eeeaf598116c2ce1aac5
2015-03-28 08:38:48 +01:00
Thomas Cort e978660932 mined: built without UNIX defined.
* Remove undef NULL, EOF, getchar, putchar
* Rename putchar, getchar, _putchar, _getchar to putch, getch, _putch,
  _getch to avoid conflict with libc functions.
* Rename UP() to UP1() (for UP 1 line) to avoid conflict with UP
  definition in termcap.h. Rename DN1 LF1 RT1 for consistency.
* Add termcap.h for prototypes for tputs and friends.
* Add libterminfo references to Makefile
* Add return value to _putch() to make it work as tputs expects.
* Make putch() call _putch()
* Remove UNIX ifdefs and all code in the !UNIX branches.

closes #43

Change-Id: I0a6f7298aa8b12a74225badc88d3c236a02669ea
2015-03-28 08:38:33 +01:00
Thomas Cort fc850d580c man: clean-out man1x category.
Removes the following man pages:

* awk.1x -- for a version of awk we no longer have
* kermit.1x -- seems gone altogether
* macros.1x -- not useful for anyone anymore

Moves the following man pages:

* mined.1x -- Moved to minix/commands/mined/mined.1
and reformatted to use the mdoc macros instead of the
Minix macros so that it displays properly.

Removes /usr/man/man1x from the directory tree.

closes #44

Change-Id: I59b8bd54cf5cba6d188e51e99a92b36e90c275c1
2015-03-25 06:53:44 +01:00
Thomas Cort d1a87c1f64 mined: clean-up trailing whitespace.
Change-Id: Ic27293d7e1d0f830d635b78e7e620dcf0ef3e03f
2015-03-24 14:03:03 +01:00
Thomas Cort d131b58784 mined1.c: remove i386 guard around escape sequences.
The escape sequences for the function keys used to be separated
out in older versions of Minix when they were different for m68k
and intel. Support for m68k was dropped and that code was
removed, leaving the ifdef i386. Since the sequences are the
same for i386 and arm, there is no need to keep the ifdef i386.

Change-Id: Id96a80bcb24da120efa63acc9b248d87fc347eac
2015-03-24 14:03:03 +01:00
Thomas Cort 6a0aa6fb5e mined.h: remove irrlevant comment.
It used to refer to several NIL_* definitions. Those were removed
in commit 6e25ad8b0a leaving the
comment with nothing to comment on.

Change-Id: I52221ae5d2c5216e82391b480cf2038ad723b8f0
2015-03-24 14:03:02 +01:00
Thomas Cort 0cf05b213d mined.h: remove unused definition, MEMORY_SIZE.
Change-Id: I1ae83c427cafb15f1382b7d8ab3871a36b0eec28
2015-03-24 14:03:02 +01:00