Commit graph

8445 commits

Author SHA1 Message Date
Ori Bernstein 5dd9b370a0 git/merge: correctly preserve permissions when merging
when doing a 3 way merge of a file, we also need to do a
merge of the permission bits to avoid clobberign them.
2022-05-15 16:29:48 +00:00
Sigrid Solveig Haflínudóttir 1470d22cdb icanhasvmx: our vmx requires unrestricted guest too 2022-05-15 16:23:13 +00:00
Jacob Moody 4ee54b1416 fork(2): fix commas in RFNOMNT references 2022-05-15 16:14:36 +00:00
Jacob Moody 9429dd64f7 kernel: disable wstat for devpipe 2022-05-15 05:44:59 +00:00
Jacob Moody 2c67fb9794 fork(2): fix parens in RFNOMNT references (thanks Amavect) 2022-05-15 03:01:49 +00:00
Xiao-Yong Jin 0aa0096066 vt: increase buffer size
This patch increases the buffer sizes in vt(1) to reduce
the latency from the roundtrip between terminal and cpu
server.
2022-05-11 04:02:57 +00:00
Jacob Moody e614e819e3 fork(2): Document RFNOMNT edge cases. 2022-05-12 17:50:08 +00:00
cinap_lenrek 6ca8e6bbaf uartimx: fix interrupts
need to turn off transmitter fifo interrupt when we run out of
data to transmit, and set rx fifo ready fifo threshold to one.
2022-05-09 17:22:00 +00:00
cinap_lenrek 7aa8c6d47e imx8: implement psci calls for system reset and multicore startup 2022-05-08 20:26:56 +00:00
cinap_lenrek cac30a565e remove empty /sys/src/cmd/cpu.c 2022-05-08 17:37:39 +00:00
cinap_lenrek fff070f2cb imx8: add work in progress i.MX8MQ kernel for the mntreform2 laptop
This is a work in progress port to the mntreform2 laptop.

Working so far:

- mmu (same as raspberry pi 3b+)
- arm generic timer
- gicv3
- uart1
- enet

With access to the uart, one can netboot this kernel in u-boot
using the following commands:

> dhcp
> bootm
2022-05-08 16:50:29 +00:00
cinap_lenrek 9126ee3eea kernel: fix noteid change race condition from devproc while forking (thanks joe7)
devproc allows changing the noteid of another process
which opens a race condition in sysrfork(), when deciding
to inherit the noteid of "up" to the child and calling
pidalloc() later to take the reference, the noteid could
have been changed and the childs noteid could have been
freed already in the process.

this bug can only happen when one writes the /proc/n/noteid
file of a another process than your own that is in the
process of forking.

the noteid changing functionality of devproc seems questinable
and seems to be only used by ape's setpgrid() implementation.
2022-05-02 19:34:00 +00:00
umbraticus@prosimetrum.com 641bd4512f sam: ignore autoindent in cmd window 2022-04-29 05:31:30 +00:00
xfnw 0b95092e3d add stats.mono 2022-04-16 22:24:37 -04:00
xfnw ada39fd98c newuser script 2022-04-16 22:17:11 -04:00
xfnw 5e89dcb387 Merge branch 'newpatch' into front 2022-04-16 21:50:35 -04:00
xfnw be4132b248 add patches to git 2022-04-16 21:49:41 -04:00
nature 061ec57021 vncv: allow the use of the Mod4 (Super) key 2022-04-09 10:29:11 +00:00
cinap_lenrek f84cf1e604 /sys/lib/newuser: fix wsys botch, crate bin/arm64 2022-04-13 13:53:12 +00:00
phil9 63f8dc8084 mothra: make scrollbar style consistent with other applications
Scrollbar was drawn using a wide dark gutter over a white background
	whereas other applications (window, sam, ...) use a thinner scrollbar with an
	inverse colorscheme.
	This makes the scrollbar more consistent with other 9front applications.
2022-04-06 16:46:58 +00:00
phil9 aba0c7fcea mothra: enable mousewheel scrolling in history list
In the history list, scrolling was only possible using the scrollbar
	but not the mousewheel like in the text panel.
2022-04-06 15:29:41 +00:00
Ori Bernstein a63472edf5 rc: squelch 'Write error' warning
When writing to a large variable in /env, we
spam 'Write error', in spite of the env var
working. This is new behavior, as of commit
b90036a062.

It produces a lot of scary, noisy warnings,
which are probably bogus.
2022-04-29 01:51:01 +00:00
Ori Bernstein a271f62bf2 git/pull: remove '-b' and '-a' option
we do the right thing by default now, let's not
add knobs that nobody cares about.
2022-04-28 03:35:54 +00:00
Ori Bernstein 3d047ddf03 git/common.rc: create required directories
we forgot a couple of directories when branching.
2022-04-19 14:34:48 +00:00
Ori Bernstein 929b0ff087 git: rename internal 'git/fetch' plumbing to 'git/get'
This caused some confusion, so to make it clear that
it's plumbing and has nothing to do with 'git fetch',
rename it.
2022-04-17 17:03:47 +00:00
Ori Bernstein 08447e5d64 git/send: fill in 'theirs' object, even if we miss it
When pushing, git/send would sometimes decide we had all the
objects that we'd need to update the remote, and would try
to pack and send the entire history of the repository. This
is because we only set the 'theirs' ref when we had the object.

If we didn't have the object, we would set a zero hash,
then when deciding if we needed to force, we would think
that we were updating a new branch and send everything,
which would fail to update the remote.
2022-04-17 01:19:10 +00:00
Ori Bernstein 8319b750ea git/serve: log correct error message
Sending the packet on failure could junk the errstr,
so set it after we send the message.
2022-04-17 00:22:43 +00:00
Ori Bernstein 03e5d9e9e2 git/merge: preserve exec bit correctly
A while ago, qwx noticed that we clobbered the exec
bit when merging files. This is not what we want, so
we changed the operator precedence to avoid merging
dirty files implicitly.

But we do want to merge, because it's convenient for
maintaining permissions. So, instead, we should do a
3 way merge of the exec bit.

This patch does that, as well as reverting the rollback
of that change.

While we're here, we adjust the timestamps correctly
in git/branch.

This requires changes to git/fs, because without an open
handler, lib9p allows opening any file with any mode,
which confuses 'test -x'.
2022-04-16 23:53:19 +00:00
Ori Bernstein 261d1ac0e3 git/pull: fetch all branches (please test)
there was a diff that went in a while ago to improve
this, but it got backed out because it encounters a
bug in upstream git -- the spec says that a single
ACK should be sent when not using multi-ack modes,
but they send back multiple ones.

This commit brings back the functionality, and works
around the upstream git bug in two different ways.

First, it skips the packets up until it finds the
start of a pack header.

Second, it deduplicates the want messages, which
is what seems to trigger the duplicate ACKs that
cause us trouble.
2022-04-16 23:52:10 +00:00
umbraticus@prosimetrum.com d606d83ed8 make = command's output plumbable
This patch makes sam's = cmd output what seems to me a more
useful (plumbable) format: /full/path/to/file:addr , where
addr is line(s) under = and rune(s) under =#.
2022-04-16 06:53:35 +00:00
Michael Forney 798375ad45 git/import: squash leading/trailing/consecutive blanks and strip trailing space
This fixes importing patches with multiline commit messages generated
by git-format-patch.  It also matches commit message sanitation done
by git-am.
2022-04-26 19:06:53 +00:00
cinap_lenrek e0fdebf394 aux/aout2uimage: fix text section size rounding (for data section alignment)
the a.out header is not considered part of the image and
should not be loaded. it also has no contribution to the
rounding of the text section size.
2022-04-23 18:27:31 +00:00
rodri 70e2b4f7ec 9pqueue(2): fix typo 2022-04-19 20:21:37 +00:00
cinap_lenrek 56c86739a8 sol(8): fix example (vncv vs vnc) 2022-04-19 02:09:06 +00:00
cinap_lenrek dfa6b6c670 ip/sol: handle timeout on password entry for digest auth 2022-04-19 02:06:33 +00:00
cinap_lenrek 9993b3909e ip/torrent: fix silly readn() error check (thanks pr) 2022-04-18 21:03:40 +00:00
Michael Forney 909205036d git/branch: remove duplicate assignment of dirtypaths 2022-04-04 23:09:49 +00:00
Michael Forney 331f19ef21 git/branch: fix typo in error message 2022-04-04 22:54:09 +00:00
cinap_lenrek 55a0abdd43 auth/as: fix wrong filesystem permissions due to wrong factotum being attached
to change user, have to (re-)mount factotum under the new user,
so it can authenticate us under the correct user for the filesystems.
2022-04-04 22:25:08 +00:00
cinap_lenrek 90a08cf1fd vncv: some fixes to work with intel amt kvm 2022-04-03 04:23:25 +00:00
cinap_lenrek 1a4e03cf93 ip/sol: kvm (vnc) redirect, bring back plain authentication as a fallback (when unsupported) 2022-04-03 04:19:46 +00:00
cinap_lenrek 8597051d64 uartpci: AMT SOL Redirection interface (x200s) 2022-04-03 04:06:27 +00:00
cinap_lenrek 31294b6c1a ip/sol: use httpdigest authentication
httpdigest authentication allows one to share the key
in factotum with the amt webserver on https://target:16993
2022-04-02 21:47:00 +00:00
Sigrid Solveig Haflínudóttir 4a401e7703 draw(3): add a missing .br 2022-04-02 21:37:51 +00:00
cinap_lenrek fc0eee2980 webfs: do not reuse digest Authorization headers
We must use the digest authorization header only
once for a single request.
2022-04-02 20:29:20 +00:00
cinap_lenrek 8166868375 webfs: implement RFC2617 qop extension for http digest authentication 2022-04-02 19:20:56 +00:00
Sigrid Solveig Haflínudóttir 945fef7ff2 devdraw: printmesg: implement "z" fmt arg (safe since printmesg is disabled) 2022-04-02 11:12:12 +00:00
Sigrid Solveig Haflínudóttir 30f5752710 draw(3): .IR on memlorigin(2), fix wrong "t" param name (should be "top") 2022-04-02 10:37:39 +00:00
cinap_lenrek ca60e03c5b ip/sol: add intel AMT serial-over-lan console program 2022-04-01 21:24:42 +00:00
Sigrid Solveig Haflínudóttir 5ddff68167 libtags: m4a: do not div by zero 2022-03-30 20:55:33 +00:00
Sigrid Solveig Haflínudóttir cb4d441cb8 libtags: wav: do not div by zero (fixup) 2022-03-30 20:54:11 +00:00
Sigrid Solveig Haflínudóttir 2cdd31f8f4 libtags: wav: do not div by zero 2022-03-30 20:51:03 +00:00
Sigrid Solveig Haflínudóttir 7f2e622965 libtags: id3v2: make sure extra id3 tag does not cause infinite loop 2022-03-30 20:28:03 +00:00
cinap_lenrek f05b8af71e devsd: cache SDunit pointer in Chan.aux, improve error handling
Avoid calling sdgetdev() for every I/O. Instead,
put the SDunit pointer for #S/sdXX/* files in Chan.aux
and keep a reference to SDev between sdopen()/sdclose().

This avoids having to do the sdindex() lookup and
qlock(),incref(),decref() on every read/write
operation. Removal of SDev's is quite rare and only
can happen with pcmcia ide controllers, and i assume
that for that we can assume thet fileservers having
been exited properly and closed their files before
we attempt to remove a device.

The rest is improving waserror() codepaths, making
sure we release the locks for any of the interface
callbacks (verify/online).

Also get rid of tas() and instead only change the
unit's rawopen flag while holding raw qlock.
2022-03-30 19:23:26 +00:00
Sigrid Solveig Haflínudóttir 12802b94c6 libtags: flac: check sample rate before dividing by zero; also check number of channels 2022-03-30 16:59:35 +00:00
Sigrid Solveig Haflínudóttir bc5b0254d0 pc: do not access out of bounds array element 2022-03-28 17:23:04 +00:00
cinap_lenrek 89ae389eb6 libsec: fix wrong tls1.0 prf regression
The change 775a4bea43
"libsec: various changes to tls"
...
4. simply prf code...

... broke the TLS1.0 prf function, missing the fact
that the prf ouput for sha1 and md5 need to be
xored together.
2022-03-27 20:28:41 +00:00
cinap_lenrek 00542efd15 devuart: allow serial console on late detected uarts
pci uarts are detected late and usually do not contain
the console= parameter logic.

for these, we can just enable them when devuart is reset,
and replay the boot messages once enabled.

this is usefull as it allows us to use these uarts for
kernel debugging in interrupt context.
2022-03-19 15:53:40 +00:00
Michael Forney 27fe8ee356 games/gb: minor style fixes 2022-03-18 17:32:11 -07:00
Michael Forney d5368b0799 games/gb: various RTC fixes
MBC3 write switches on a>>13, so the RTC register is 5 (0xA000-0xBFFF).

Mask off upper bits of DH register when updating the timer. Only the
lowest bit is part of the day counter.

Use uint for x in timerforward() so that we don't set negative values
for timer registers if it happens to overflow.

Update timer and then latch rather than the other way around.
Otherwise, timer remains static and will overflow after 512 days.
2022-03-18 17:25:43 -07:00
Michael Forney 638b82129e git/fetch: use read for reading packfiles instead of readn 2022-03-18 23:45:43 +00:00
cinap_lenrek 02d1725d71 uartpci: add serial-over-lan uart from x230/AMT 2022-03-18 20:18:19 +00:00
cinap_lenrek e83917a658 ip/dhcpd: ignore ipv6 addresses when looking up static binding 2022-03-18 19:54:23 +00:00
cinap_lenrek 488f378470 sdide: add pci id for AMT IDE-r controller on x230 2022-03-18 19:53:11 +00:00
Michael Forney d55a64c905 git: use commit date as traversal hint instead of author date
Although git9 always uses the same commit date and author date, other
implementation do make a distinction.  Since commit date is more
representative of the commit graph order, use this as a traversal hint
instead of author date.
2022-03-17 01:41:44 +00:00
Michael Forney 8bd5be7c70 git/fetch: improve detection of dumb http protocol
If the server only supports the dumb protocol, the first 4 bytes of
response will be the initial part of the hash of the first ref.

The http-protocol documentation says that we should fall back to the
dumb protocol when we don't see a content-type of
application/x-$servicename-advertisement.  Check this before
attempting to read a smart git packet.
2022-03-17 01:41:09 +00:00
Michael Forney 2e47badb88 git/query: refactor graph painting algorithm (findtwixt, lca)
We now keep track of 3 sets during traversal:
- keep: commits we've reached from head commits
- drop: commits we've reached from tail commits
- skip: ancestors of commits in both 'keep' and 'drop'

Commits in 'keep' and/or 'drop' may be added later to the 'skip' set
if we discover later that they are part of a common subgraph of the
head and tail commits.

From these sets we can calculate the commits we are interested in:
lca commits are those in 'keep' and 'drop', but not in 'skip'.
findtwixt commits are those in 'keep', but not in 'drop' or 'skip'.

The "LCA" commit returned is a common ancestor such that there are no
other common ancestors that can reach that commit.  Although there can
be multiple commits that meet this criteria, where one is technically
lower on the commit-graph than the other, these cases only happen in
complex merge arrangements and any choice is likely a decent merge
base.

Repainting is now done in paint() directly.  When we find a boundary
commit, we switch our paint color to 'skip'.  'skip' painting does
not stop when it hits another color; we continue until we are left
with only 'skip' commits on the queue.

This fixes several mishandled cases in the current algorithm:
1. If we hit the common subgraph from tail commits first (if the tail
   commit was newer than the head commit), we ended up traversing the
   entire commit graph.  This is because we couldn't distinguish
   between 'drop' commits that were part of the common subgraph, and
   those that were still looking for it.
2. If we traversed through an initial part of the common subgraph from
   head commits before reaching it from tail commits, these commits
   were returned from findtwixt even though they were also reachable
   from tail commits.
3. In the same case as 2, we might end up choosing an incorrect
   commit as the LCA, which is an ancestor of the real LCA.
2022-03-16 21:41:59 +00:00
Igor Böhm 873f381e29 acme: fix hiding of top windows when loading a dump file (thanks Xiao-Yong)
When loading an acme dump file that contains a window with only one
tag line, there are cases where acme hides that window (i.e.  not even
its tag is visible).

The following commands reproduce the issue:

 % ed <<EOE
1
i
/tmp
/lib/font/bit/pelm/unicode.8.font
/lib/font/bit/pelm/unicode.8.font
          0
f          0           5         175         175           1
          5          40         175           1           0 /sys/src/cmd/acme/ Del Snarf Get | Look
f          0           4         330         330           3
          4          27         330           1           0 /tmp/ Del Snarf Get | Look
.
,w /tmp/test.dump
Q
EOE
 % window -dx 900 -dy 600  'acme -l /tmp/test.dump'

This issue was introduced in commit 47b7dc5ccd.
2022-03-15 10:49:00 +00:00
cinap_lenrek ca313087c1 ip(3): use flags instead of tag for 8 column route add/remove
This avoids ipconfig having to explicitely specify the tag
when we want to set route type, as the tag can be provided
implicitely thru the "tag" command.
2022-03-14 18:45:27 +00:00
cinap_lenrek d4e89fe76a ape: fix wrong write size for _assert() 2022-03-14 11:16:11 +00:00
cinap_lenrek 263251da75 ip/dhcpd: ignore icmp advice
should ignore advice as we are handling all connections
thru a single udp connection.
2022-03-13 20:43:16 +00:00
cinap_lenrek 5186cb3b99 ip(3): document the trans argument for add/try. 2022-03-13 17:38:06 +00:00
cinap_lenrek c8507f428f ipconfig(8): add -t flag to enable source address translation 2022-03-13 17:29:16 +00:00
cinap_lenrek 6e4a1fda8c devip: allow setting the "trans" flag on a logical interface
This makes the interface route have the "t"-flag,
which causes packets routed to the interface to get
source translated.
2022-03-13 17:16:54 +00:00
cinap_lenrek d2a7d88662 devip: implement network address translation routes
This adds a new route "t"-flag that enables network address translation,
replacing the source address (and local port) of a forwarded packet to
one of the outgoing interface.

The state for a translation is kept in a new Translation structure,
which contains two Iphash entries, so it can be inserted into the
per protocol 4-tuple hash table, requiering no extra lookups.

Translations have a low overhead (~200 bytes on amd64),
so we can have many of them. They get reused after 5 minutes
of inactivity or when the per protocol limit of 1000 entries
is reached (then the one with longest inactivity is reused).

The protocol needs to export a "forward" function that is responsible
for modifying the forwarded packet, and then handle translations in
its input function for iphash hits with Iphash.trans != 0.

This patch also fixes a few minor things found during development:

- Include the Iphash in the Conv structure, avoiding estra malloc
- Fix ttl exceeded check (ttl < 1 -> ttl <= 1)
- Router should not reply with ttl exceeded for multicast flows
- Extra checks for icmp advice to avoid protocol confusions.
2022-03-12 20:53:17 +00:00
cinap_lenrek c14ea9fdd1 awk: fix off-by-one string buffer overflow from gsub
the bug happens when we did the fast exit thru "done" label,
where we would not make sure that theres space in the buffer
for the NUL terminator.

instead, avoid the fast exit and always do the final
adjbuf() that makes sure we have space for the NUL terminator.

remove the pointless pb checks, they'r wrong (should'v
been bp >= buf+bufsz) and adjbuf() already makes sure this
can never happen.
2022-03-12 12:29:15 +00:00
Alex Musolino af6f03e528 hjfs: fix group ownership of home dirs created by newuser command 2022-03-08 13:25:52 +00:00
Michael Forney 0f890140f2 igfx: fix some typos in comments 2022-03-05 01:06:20 +00:00
Michael Forney d52f25ecdc igfx: add TypeILK, since it differs slightly from SNB
ILK's LVDS transcoder select field only has 1 bit, like G45.
2022-03-02 10:26:37 +00:00
Michael Forney a00957efee igfx: maintain single/double-channel LVDS mode from BIOS 2022-03-02 10:26:36 +00:00
Michael Forney 79c7e4514d igfx: fix FDI link training on ironlake
Ironlake uses bits 29:28 in the RX control register to select the
training pattern.
2022-03-02 10:26:38 +00:00
cinap_lenrek 9c02337fc3 merge 2022-03-02 18:54:36 +00:00
Michael Forney 954f9f1fcf aux/vga: return modes according to EDID timing priority order
EDID 1.3 section 5 gives a table describing the priority order of
timing information. Use this ordering when constructing the EDID
mode list.

Since aux/vga selects the first mode in the modelist that matches
the given size, it will now select the mode of that size with the
highest preference. Or, if you set vgasize=auto (or some other
string without an 'x'), aux/vga will select the Preferred Detailed
Timing.

This should make it unnecessary to modify vgadb in many cases.
2022-02-28 21:20:52 +00:00
cinap_lenrek d082a8972f ether82563: add pci id for ethernet on dell optiplex 7090 micro (thanks leimy)
0.31.6: net  02.00.00 8086/15f9 255 0:70900000 131072
         Intel Corporation
2022-02-28 13:18:13 +00:00
cinap_lenrek 5886b999d5 devbridge: fix vlan range parsing 2022-02-27 13:32:58 +00:00
Ori Bernstein 840d16912a git/revert: update modification time on revert
when reverting files, 'cp -x' updates the mtime
to the time the file was committed. this prevents
'mk' from rebuilding the file, leading to stale
builds.

this change touches the file on revert, so that
we rebuild the file.
2022-02-27 04:27:56 +00:00
cinap_lenrek fd1cfc824a snoopy: add vlan protocol (802.1q) 2022-02-27 03:33:01 +00:00
cinap_lenrek 9944e16b16 devbridge: improve locking, unbind ports automatically on read error and more...
Use an RWlock so readers can work in parallel in
the common case (no cache updates).

When a reader needs to update the cache to add
a new learned source mac address, it will drop
the rlock and aquire the wlock to do the update.

When we get a read error, we now unbind the
port to avoid further packets being forwarded
to it.

This is usefull for hotplug ethernet devices
like usb ones or tunnels.

Simplify the unbind, getting rid of the refcount,
by having only the reader proc call freeport().

Avoid holding the bridge lock while opening
and closing ethernet/tunnel device files during
bind and unbind.

Dont use smalloc() (especially when holding locks).

Allocate bridges dynamically, so we do not waste
the memory when we do not need them.

Reject non-hostowner from allocating new bridges.

Use consistent naming: port -> port

Use consistent comment style: // -> /* */
2022-02-26 22:05:32 +00:00
cinap_lenrek be0a80faf3 nusb/disk: use setalt(), print argv0 in prints instead of "disk:" 2022-02-23 18:38:28 +00:00
cinap_lenrek 045936a778 nusb/cam: fix mistake (nil vs -1) 2022-02-23 18:13:00 +00:00
cinap_lenrek 8bf71adc94 nusb/audio: use setalt(), make sure endpoint has right direction. 2022-02-23 18:03:53 +00:00
cinap_lenrek 11e12ea0c0 nusb/cam: use setalt() 2022-02-23 18:02:02 +00:00
cinap_lenrek 67750a093f nusb/ether: use setalt() 2022-02-23 18:01:15 +00:00
cinap_lenrek bea20cd152 nusb/lib: provide a setalt() function to set the interface to its altsetting 2022-02-23 18:00:34 +00:00
cinap_lenrek 9cd55a085d nusb/ether: remove csp check for rndis, already done in nusbrc 2022-02-23 17:59:13 +00:00
Sigrid Solveig Haflínudóttir 0e3a955652 libFLAC: update to 1.3.4 2022-02-21 21:11:19 +00:00
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
cinap_lenrek 14bb9734a6 usbxhci: endpoint address needs to be masked with Epmax from endpoint number 2022-02-21 18:46:47 +00:00
cinap_lenrek 4b637a24f9 devbridge: implement experimental vlan support 2022-02-16 22:38:03 +00:00
cinap_lenrek 7289f371a0 devip: dont hold ifc wlock during medium bind/unbind
Wlock()'ing the ifc causes a deadlock with Medium
bind/unbind as the routine can walk /net, while
ndb/dns or ndb/cs are currently blocked enumerating
/net/ipifc/*.

The fix is to have a fake medium, called "unbound",
that is set temporarily during the call of Medium
bind and unbind.

That way, the interface rwlock can be released while
bind/unbind is in progress.

The ipifcunbind() routine will refuse to unbind a
ifc that is currently assigned to the "unbound"
medium, preventing any accidents.
2022-02-16 22:31:31 +00:00
cinap_lenrek 755880b19f rc: fix globbing with lists (thanks qwx)
Pattern matching with lists no longer works:

	; ls /tmp/*.c
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c
	; ls /tmp/^(*.c)
	ls: /tmp/*.c: '/tmp/*.c' directory entry not found
	; 9fs dump
	; bind /n/dump/2021/1002/amd64/bin/rc /bin/rc
	; rc
	; ls /tmp/^(*.c)
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c

the fix:

we have to propagate the glob attribute thru lists
as well. before it was only handled for single words
and propagated thru concatenations...

the Xglob instruction now works on list, and we
propagate the glob attribute thru PAREN and WORDS
and ARGLIST nodes.

also, avoid using negative numbers for the Tree.glob
field as char might be unsigned on some targets.
2022-02-16 18:07:21 +00:00
Michael Forney 5c96a51f3a nusb/serial: fix pl2303 usbcmd error checks
Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
(excluding the setup packet), so adjust the expected return values
accordingly.
2022-01-01 22:51:18 +00:00
Igor Böhm 5d69d42ee3 git(1): fix quotes in git/conf example 2021-12-15 22:45:59 +00:00
Tobias Heinicke 53fb93e64a delete import, oexportfs src 2021-12-14 19:39:59 +00:00
qwx af561602ea aux/wacom: fix race in read queue
this fixes `no concurrent reads, please' errors when using
aux/wacom with aux/tablet on eg. x61t
2021-12-14 23:54:05 +00:00
Ori Bernstein 7efbea82c6 devssl, cpu, import, oexportfs: delete
SSL is implemented by devssl. It's extremely
obsolete by now, and is not used anywhere but
cpu, import, and oexportfs.

This change strips out the devssl bits, but
does not (yet) remove the code from libsec.
2021-12-13 02:17:02 +00:00
qwx b4d4cf69be vga/igfx: add missing pci did's for hwblank for known mobile models 2021-12-08 09:52:07 +00:00
Ori Bernstein 3710ed60fd git: fully init objq
we were leaving objq.best uninitialized, and
would therefore read garbage if we didn't
find a best match.
2021-12-08 00:20:32 +00:00
cinap_lenrek be0b39f9c5 acmed(8), rsa(8): add role=client attribute to rsa keys 2021-12-06 15:40:18 +00:00
Humm 69249e8313 troff: we are not htmlroff
If we don’t explicitly check for ‘h’ in troff, we can’t reliably check
for non-htmlroff well.

Consider the following:

	.if h \{\
	.	de M
	.		tm m
	..\}

Without this change, this will print m and not define macro M.
2021-11-24 19:56:44 +00:00
Ori Bernstein f0adfb4ded git: improve pack cache heuristics
the pack cache was very stupid: it would close packs
as early as possible, which would prevent packs from
getting reused effectively. It would also select a
bad pack to close.

This picks the oldest pack, refcounts correctly, and
keeps up to Npackcache open at once (though it will
go over if more are in use).
2021-12-05 00:13:54 +00:00
cinap_lenrek d3743d40c2 netaudit, ndb(6): the dom= attribute in ndb should be specified without the trailing period 2021-11-29 20:07:04 +00:00
cinap_lenrek 78c7ad88ff kernel: add extra negative and power-of-two check to pcibarsize() 2021-11-26 21:47:15 +00:00
cinap_lenrek 2a531d444c aux/vga: use vlong for pci bar size 2021-11-26 20:55:58 +00:00
cinap_lenrek 20ea113790 kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TB
This makes vmap()/vunmap() take a vlong size argument,
and change the type of Pci.mem[].size to vlong as well.

Even if vmap() wont support large mappings, it is nice to
get the original unruncated value for error checking.

pc64 needs a bigger VMAP window, as system76 pangolin
puts the framebuffer at a physical address > 512GB.
2021-11-26 20:51:45 +00:00
Sigrid Solveig Haflínudóttir add3a0a4da aescbc: flush before exit and report an error (if any) 2021-11-25 21:42:12 +00:00
Igor Böhm a27afe904d prep(8): fix typos, wording, and formating 2021-11-21 22:45:51 +00:00
Igor Böhm d1a81aa81f rsa(8): fix spelling and adjust macros to fix formating 2021-11-20 22:59:43 +00:00
qwx b5a2fa5e5e audiohda: add support for intel cannon point-lp (t490s) 2021-11-18 17:15:08 +00:00
Humm 05b513a687 snap(4): remove non-existent -s from snapfs 2021-11-17 19:57:03 +00:00
cinap_lenrek fc412aef3d 6c: extern registers must be considered used on return
the peephole optimizer would remove stores to extern
register before a return statement as it would think
they are only set, but not used.
2021-11-17 01:23:57 +00:00
Igor Böhm 3473fa237c nusbrc(8): fix typo in BUGS section 2021-11-16 08:06:50 +00:00
Sigrid Solveig Haflínudóttir 78b55b64c8 mklatin: fix compose sequences starting with a space char (␣ and ı) 2021-11-14 20:16:30 +00:00
Sigrid Solveig Haflínudóttir 0f50c54b5e kbdfs: allow X and x to be used not just for hex composition 2021-11-14 14:27:15 +00:00
qwx 2ab25e3ec0 vgaigfx: add x1 carbon 3rd gen 2021-11-13 23:04:04 +00:00
Kyle Milz 41ac2d80c7 igfx: add x1 carbon 3rd gen (broadwell) 2021-11-12 18:37:33 +00:00
Igor Böhm c7775b365e rc: fix leaking runq->cmdfile
To reproduce run the following on a terminal:
<snip>
cpu% leak -s `{pstree | grep termrc | sed 1q | awk '{print $1}'}
src(0x00209a82); // 12
src(0x0020b2a6); // 1
cpu% acid `{pstree | grep termrc | sed 1q | awk '{print $1}'}
/proc/358/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x0020b2a6)
/sys/src/cmd/rc/plan9.c:169
 164		if(runq->argv->words == 0)
 165			poplist();
 166		else {
 167			free(runq->cmdfile);
 168			int f = open(runq->argv->words->word, 0);
>169			runq->cmdfile = strdup(runq->argv->words->word);
 170			runq->lexline = 1;
 171			runq->pc--;
 172			popword();
 173			if(f>=0) execcmds(openfd(f));
 174		}
acid:
</snap>

Another `runq->cmdfile` leak is present here (captured on a cpu server):
<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002051d2)
/sys/src/cmd/rc/exec.c:1056
 1051
 1052	void
 1053	Xsrcfile(void)
 1054	{
 1055		free(runq->cmdfile);
>1056		runq->cmdfile = strdup(runq->code[runq->pc++].s);
 1057	}
acid:
</snap>

These leaks happen because we do not free cmdfile on all execution paths
where `Xreturn()` is invoked. In `/sys/src/cmd/rc/exec.c:/^Xreturn`

<snip>
void
Xreturn(void)
{
	struct thread *p = runq;
	turfredir();
	while(p->argv) poplist();
	codefree(p->code);
	runq = p->ret;
	free(p);
	if(runq==0)
		Exit(getstatus());
}
</snip>

Note how the function `Xreturn()` frees a heap allocated instance of type
`thread` with its members *except* the `cmdfile` member.

On some code paths where `Xreturn()` is called there is an attempt to free
`cmdfile`, however, there are some code paths where `Xreturn()` is called
where `cmdfile` is not freed, leading to a leak.

The attached patch calls `free(p->cmdfile)` in `Xreturn()` to avoid leaking
memory and handling the free in one place.

After applying the patch this particular leak is removed. There are still
other leaks in rc:

<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x00209a82)
/sys/src/cmd/rc/subr.c:9
 4	#include "fns.h"
 5
 6	void *
 7	emalloc(long n)
 8	{
>9		void *p = malloc(n);
 10		if(p==0)
 11			panic("Can't malloc %d bytes", n);
 12		return p;
 13	}
 14
</snap>

To help fixing those leaks emalloc(…) and erealloc(…) have been amended to use
setmalloctag(…) and setrealloctag(…). The actual fixes for other reported leaks
are *not* part of this merge and will follow.
2021-11-10 13:01:38 +00:00
cinap_lenrek a4c1f3cc18 devtls: reject zero length records (thanks sigrid)
zero length record causes ensure() todo nothing,
while qgrab() assumes there is at least one buffer
in the queue and would dereference the nil buffer.
2021-11-09 01:46:13 +00:00
cinap_lenrek 68572ab451 diff: revert last change, this breaks git/diff 2021-11-09 01:29:30 +00:00
Igor Böhm a7ec6ee4e8 git(1): fix git/add -r spacing and wording in BUGS section 2021-11-08 01:05:51 +00:00
cinap_lenrek a87ce74d60 kernel/rdb: need to reenable polling mode on the uart, remove cruft 2021-11-07 17:58:52 +00:00
cinap_lenrek 9eb192f586 bcm64: parse the emmc2bus/dma-ranges device-tree property and provide *emmc2bus kernel parameter
/*
  * emmc2 has different DMA constraints based on SoC revisions. It was
  * moved into its own bus, so as for RPi4's firmware to update them.
  * The firmware will find whether the emmc2bus alias is defined, and if
  * so, it'll edit the dma-ranges property below accordingly.
  */
 emmc2bus: emmc2bus {
 compatible = "simple-bus";
 ranges = <0x0 0x7e000000  0x0 0xfe000000  0x01800000>;
 dma-ranges = <0x0 0xc0000000  0x0 0x00000000  0x40000000>;
 emmc2: mmc@7e340000 {
 compatible = "brcm,bcm2711-emmc2";
 reg = <0x0 0x7e340000 0x100>;
 interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
 clocks = <&clocks BCM2711_CLOCK_EMMC2>;
 status = "disabled";
 };
 };
2021-11-07 17:51:12 +00:00
cinap_lenrek 80268af29e bcm64/sdhc: add *emmc2bus kernel parameter to set dma dram bus address
On the raspberry pi 4, depending on the chip revision,
the emmc2 controller has different dram bus address window,
so make it configurable.
2021-11-07 17:47:09 +00:00
cinap_lenrek a2baa86348 bcm/emmc: remove unused cardr wakeup(), use MACHP(0) as tick reference 2021-11-07 17:43:36 +00:00
cinap_lenrek 2925fb09a6 sdmmc: do card init in a background process after the first try
Some mmc controllers have no card detect pin, so the only
way to detect card presence is to issue the ACMD41 which will
fail after a pretty long timeout.

To avoid mmconline() blocking, we only try to initialize the
card synchronous once, and then retry in a background process,
while returning immediately from mmconline() while the retry
is in progress.

This speeds up network boot times significantly on a raspi
without a sdcard inserted.
2021-11-07 17:41:57 +00:00
Igor Böhm efa6937460 acme: fix leaking memory allocated by getenv("font")
If the font chosen for acme is retrieved via `getenv("font")` its
memory is leaked:

<snip>
	if(fontnames[0] == nil)
		fontnames[0] = getenv("font");
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> getenv(…) mallocs memory

	if(fontnames[0] == nil)
		fontnames[0] = "/lib/font/bit/vga/unicode.font";
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[0] = estrdup(fontnames[0]);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> if the `getenv("font")` path was taken above, this assignment
> will leak its memory.
</snap>

The following leak/acid session demonstrates the issue:

<snip>
cpu% leak -s 212252
src(0x002000cb); // 1
cpu% acid 212252
/proc/212252/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002000cb)
/sys/src/cmd/acme/acme.c:107
 102			fprint(2, "usage: acme [-aib] [-c ncol] [-f font] [-F fixedfont] [-l loadfile | file...]\n");
 103			exits("usage");
 104		}ARGEND
 105
 106		if(fontnames[0] == nil)
>107			fontnames[0] = getenv("font");
 108		if(fontnames[0] == nil)
 109			fontnames[0] = "/lib/font/bit/vga/unicode.font";
 110		if(access(fontnames[0], 0) < 0){
 111			fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
 112			exits("font open");
acid:
</snap>

The fix tries to first check if a font has been set via
command line options in which case the font string is
malloced via estrdup(…).

If no font has been selected on the command line getenv("font")
is used. If no getenv("font") var is found we malloc a default
font via estrdup(…).

<snip>
	if(fontnames[0] != nil)
		fontnames[0] = estrdup(fontnames[0]);
	else
		if((fontnames[0] = getenv("font")) == nil)
			fontnames[0] = estrdup("/lib/font/bit/vga/unicode.font");
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[1] = estrdup(fontnames[1]);
</snap>

This resolves the memory leak reported by leak(1).
2021-11-05 23:51:55 +00:00
Kyle Milz cd7480f68f diff: fix -u when comparing identical files 2021-11-05 19:03:20 +00:00
Igor Böhm 160e36aaef git(1): fix typo in git/push section 2021-11-06 00:15:28 +00:00
Igor Böhm 775608db7c leak(1): document how to generate pool.$objtype.acid
/sys/lib/acid/leak requires /sys/src/libc/port/pool.$objtype.acid
which is not present by default, describe how to generate it.
2021-11-04 23:11:56 +00:00
qwx 9827a6b178 audiohda: add support for intel comet lake-s, fix typo 2021-11-05 22:26:28 +00:00
cinap_lenrek 6c70026fa4 acme: fix plumb message leaks (thanks igor) 2021-11-05 18:49:40 +00:00
Kyle Milz e2e4a46f26 git/revert: fix empty invocation
git/revert requires a file name argument, but when none is given
it fails in a strange way:

	% git/revert
	usage: cleanname [-d pwd] name...
	/bin/git/revert:15: null list in concatenation
2021-11-04 19:08:02 +00:00
Stuart Morrow 3f49507786 mainly just spelling and typos 2021-11-01 20:49:43 +00:00
cinap_lenrek cdf3be65ea snoopy: dns: add caa record type, fix rrtypestr() 2021-11-03 21:44:24 +00:00
cinap_lenrek c37de33463 ndb/dns: use decimal encoding for txt rr string escapes
rfc883 suggests to use decimal digits to escape txt rr strings,
and unix dig appears to use the same.
so change from octal to decimal.
2021-11-03 20:38:23 +00:00
cinap_lenrek 6285c19b33 snoopy: adjust for new dns txt rr format 2021-11-03 20:21:03 +00:00
cinap_lenrek 5de1f3d9cf ndb/dns: handle txt rr strings as binary, remove nullrr ndb code
txt and caa rr strings might contain binary control characters
such as newlines and double quotes which mess up the output
in ndb(6) format.
so handle them as binary blobs internally and escape special
characters as \DDD where D is a octal digit when printing.

txtrr() will unescape them when reading into internal
binary representation.

remove the undocumented nullrr ndb attribute parsing code.
2021-11-03 20:09:02 +00:00
cinap_lenrek 2899b719ae libndb: move mkptrname() into libndb to avoid duplication 2021-11-03 19:38:36 +00:00
Sigrid Solveig Haflínudóttir 2d56837b2f zuke: fix search function ignoring matching artist name 2021-11-03 14:45:27 +00:00
Noam Preil 4584fbf577 venti(8): change documented behavior to match actual 2021-11-03 03:48:48 +00:00
Kyle Milz ca73f67347 man grep args spacing diff 2021-11-01 17:07:28 +00:00
Igor Böhm 27af159fdc rc-httpd(8): document how to use HTTP basic authentication 2021-10-30 23:59:12 +00:00
cinap_lenrek 498d86b921 ndb/dnsquery: make ! bang work with reverse lookups, document in ndb(8) 2021-11-01 16:31:39 +00:00
Kyle Milz c67593125c man g filetypes diff
g(1): sync filetypes list

the file types list in the 'g' manual was out of date.
this change synchronizes and sorts them.

it looks like the .B macro only accepts 6 args or less,
so observe that limit.
2021-11-01 15:22:41 +00:00
cinap_lenrek 3cd87bc3fb ndb/dns: use correct attribute when serializing caa record in ndb format 2021-11-01 15:12:17 +00:00
cinap_lenrek 5e3ded2242 ndb/dnsdebug: dont duplicate rrfmt()
introduce our own RR* format %P for pretty
printing and call %R format internally,
then use it to print the rest of the line
after the tab, prefixed with the padded
output.
2021-11-01 14:39:18 +00:00
cinap_lenrek 28f67bba84 ndb/dns: fix ndb serialization of RR*
have todo multiple fmtprint() calls for idnname()
as the buffer is shared.

do not idnname() rp->os and rp->cpu, these are symbols.

always quote txt= records.
2021-11-01 14:37:19 +00:00
cinap_lenrek 245bf71e61 /sys/doc/troff.ms: give correct path for -m flag (thanks kyle) 2021-11-01 11:28:52 +00:00
qwx 987d15e7b2 tinc: fix typo in unknown host error message 2021-10-31 22:48:20 +00:00
Sigrid Solveig Haflínudóttir 023882f0a4 libtags: no tags is still fine if format is known 2021-10-31 17:38:18 +00:00
cinap_lenrek 1051b023a8 libc: idn2utf()/utf2idn(): check for < 1 buffer, can't insert terminating NUL. 2021-10-31 12:43:47 +00:00
cinap_lenrek 32665f51c7 libsec: no point in checking for "xn--" marker, just call idn2utf(). 2021-10-31 12:40:47 +00:00
cinap_lenrek 9d15403fda libc: fix overflow of domain component rune buffer for idn2utf()
If the source string has a run of more than 256 runes without
a "." dot, we'd overflow the runebuffer in idn2utf().

The utf2idn() routine had a check in the while loop, but that
is actually wrong too, as it would insert a dot and restart
the loop in the middle of a domain component. Just error
out if a domain component is too long.
2021-10-31 12:39:46 +00:00
Ori Bernstein 7b4e3be27e ape: add missing idn2utf, utf2idn to lib9
this fixes the libsec build under ape.
2021-10-31 04:42:34 +00:00
cinap_lenrek aebf92224f acmed: pass original utf8 subject domain to challengefn, simplify
try to keep everything in utf8 format.
2021-10-31 02:16:17 +00:00
cinap_lenrek 3f2a206151 libsec: decode international domain names in certificat subject, fix overflow botch
this is for consistency, so all certificte subjects
will be returned in utf8.
2021-10-31 01:49:25 +00:00
cinap_lenrek a9e533ad1e acmed: handle international domain names 2021-10-31 00:12:36 +00:00
cinap_lenrek bda0561f45 libsec: handle international domain names in certificate request 2021-10-31 00:10:13 +00:00
Ori Bernstein 7879a3a9a6 acmed(8): ip => auth: missed a reference to the old name 2021-10-29 20:13:53 +00:00
Sigrid Solveig Haflínudóttir 35a8152ebc git/pack: check pf->pack for nil before Bterming it 2021-10-28 15:26:57 +00:00
Sigrid Solveig Haflínudóttir 18521fc8c6 mkplist: add -s option to enable "simple" sort (thanks qwx) 2021-10-28 15:20:13 +00:00
Sigrid Solveig Haflínudóttir a84f3ef581 zuke: simplify volume control logic 2021-10-28 14:59:46 +00:00
Sigrid Solveig Haflínudóttir 4b7e72689d zuke: reset before tokenize, increase player thread stack 2021-10-27 22:02:31 +00:00
Ori Bernstein c5a0909b67 acmed: remove unused define
we don't use or care about the user agent.
2021-10-27 19:34:29 +00:00
Ori Bernstein d8a1437cf4 acmed: move from ip/ to auth/
Getting certs is more tied to authentication than it
is to ip.
2021-10-27 19:33:22 +00:00
cinap_lenrek 8eaec71089 acmed(8): typo... 2021-10-27 17:18:24 +00:00
cinap_lenrek 96560abe44 acmed: reject -t flag when -e is given, dup stderr to stdout of -e cmd 2021-10-27 17:08:20 +00:00
cinap_lenrek ae9918c93e acmed(8): more improvements 2021-10-27 17:06:48 +00:00
cinap_lenrek 854cd42fe1 rootstub: create /sys/lib/tls/acmed directory 2021-10-27 17:05:07 +00:00
cinap_lenrek 463bbddb8d rsa(8): document rsa2jwk 2021-10-27 17:04:13 +00:00
Sigrid Solveig Haflínudóttir e8083eca17 zuke: do not change volume with delta == 0 2021-10-26 15:37:04 +00:00
Sigrid Solveig Haflínudóttir 8c6daa778a zuke: support other volume handles, update volume when /dev/audio is opened 2021-10-26 15:08:35 +00:00
cinap_lenrek de62d32422 /lib/ndb/local: add dnschallenge ndb file for acmed(8) by default 2021-10-25 22:40:36 +00:00
cinap_lenrek c9a20db1f1 acmed(8): fix typo 2021-10-25 21:48:05 +00:00
cinap_lenrek 79c6a0f342 acmed: tokenize domains from subject also with spaces (fixed multidom cert) 2021-10-25 18:15:53 +00:00
cinap_lenrek 87eb9bc2b7 acmed: add external command flag -e, improvements, bugs
- allow for external command to be run to install a challenge using -e flag
- remove the challengedom argument, it is given by the subject in the csr
- fix some filedescriptor leaks in error paths
2021-10-25 16:59:29 +00:00
cinap_lenrek 4efd8575eb ndb(6): add caa 2021-10-25 02:00:22 +00:00
cinap_lenrek 20cff04fd2 ndb/dns: implement caa record type in ndb
this allows the caa records to be specified
in ndb as:

caa=<value> tag=<tag> flags=<flags>

where tag defaults to "issue" and flags to 0
when omited.
2021-10-24 22:15:26 +00:00
Ori Bernstein c2661f86fc git/serve: one more silencing of non-interactive prints 2021-10-24 14:37:36 +00:00
Ori Bernstein a7f6b58d0d git/serve: don't show progress when not interactive
this prevents console spam
2021-10-24 01:36:46 +00:00
cinap_lenrek 5b5f69513a kernel: make growfd(), findfreefd() and newfd2() static 2021-10-23 15:54:30 +00:00
cinap_lenrek 1180631421 devswap: improve setswapchan()
- check for unusable file types like directories and append-only files.
- we should eigther error without any side effects or succeed.
2021-10-23 15:12:27 +00:00
cinap_lenrek db971a6189 kernel: fix stat bugs
In a few places, we where using a fixed buffer of sizeof(Dir)+100
size for stat. This is not correct and fails if the name returned
in stat is long.

This results in being unable to seek to the end of file with a
long filename.

The kernel should do the same thing as dirfstat() from libc;
handling the conversion and buffer allocation and returning a
freeable Dir* pointer.

For this, a new dirchanstat() function was added.

The fstat syscall was not rewriting the name to the last path
element; fix it.

In addition, gracefully handle the mountfix case, reallocating
the buffer to accomidate the required stat length plus
size of the new name so dirsetname() does not fail.
2021-10-23 13:40:06 +00:00
cinap_lenrek e54b6c6cbd libsec: fix wrong assert condition (introduced in 775a4bea43) 2021-10-22 13:37:27 +00:00
Ori Bernstein 5e2bf722c3 acmed(8): missed a spot 2021-10-21 02:11:03 +00:00
Ori Bernstein 72a0886639 acmed(8): fix typos, formatting, and missed name change. 2021-10-21 02:01:43 +00:00
cinap_lenrek ee31c78080 libsec: fix operator precedence bugs (thanks kemal) 2021-10-17 23:35:37 +00:00
cinap_lenrek e0d2453f56 libsec: fix bugs in tls extension handling (thanks kemal)
this patch fixes bugs in tls extension handling:

1. if conn->serverName is an empty string, tlsClientExtensions
will generate a SNI with an empty hostname, which is forbidden
according to RFC 6066:

opaque HostName<1..2^16-1>;

check if conn->serverName has at least one char.

2. checkClientExtensions fail with clients that doesn't have
extensions, because it doesn't check if ext is nil. fix that
up.

3. rewrite checkClientExtensions. some parts of the code does
not check the length properly, and it could be simplified
heavily.
2021-10-17 23:19:33 +00:00
cinap_lenrek 741e943341 acmed(8): add bugs section 2021-10-17 20:19:09 +00:00
cinap_lenrek 2731ae50d3 libaml: resolve refs in ObjectType instruction
The standard states in section 19.5.93:

.... Notice that if this operation is performed
on an obeject reference such as one produced by
the Alias, Index, or RefOf statements, the obect
type of the base object is returned.
2021-10-17 19:52:28 +00:00
cinap_lenrek 31bb950b70 libaml: implement ObjectType instruction (thanks sigrid) 2021-10-17 19:29:09 +00:00
cinap_lenrek d0909089b2 libaml: implement ToString instruction 2021-10-17 18:45:05 +00:00
cinap_lenrek 72d08816ab devtls: implement "hangup" ctl message
This makes devtls connection directories compatible to
hangup function (see dial(2)).
2021-10-16 15:07:39 +00:00
cinap_lenrek bb2357de0c fork(2): document new error behaviour when out of resources 2021-10-16 13:14:53 +00:00
cinap_lenrek 20429fb04f kernel: call freebroken() for kproc() when out of processes 2021-10-16 13:14:14 +00:00
cinap_lenrek a557c515c8 kernel: dont block allocating kstack for new processes
Have newproc() fail returning nil if we can't allocate
the kernel stack instead of locking up in smalloc().
2021-10-16 13:12:59 +00:00
Ori Bernstein 4c7745b202 acmed: import acme (RFC8555) client 2021-10-15 00:32:32 +00:00
cinap_lenrek 5a807265a8 libthread: fix debug prints, simplify
Do the debuglevel check before calling the print
function for _threaddebug, by making it a macro.
Do not waste cycles passing arguments.

Generalize the _threaddebug function into _threadprint()
and add a varargcheck pragma. This function can
also be used from _threadassert().

Fix missing arguments in one case, fix trailing
newlines in _threaddebug().

Make _threadgetproc()/_threadsetproc() a macro,
just dereferencing Proc**_threadprocp.

Simplify the mainjump, just call _threadsetproc()
directly without that mainp dance. Remove the
_schedinit() argument, it uses _threadgetproc() now.
Get rid of Mainarg struct, just have a global variable
for argc.
2021-10-13 17:08:26 +00:00
cinap_lenrek 3fe3e370e3 usbxhci: xhcirecover proc does not need to check status every 10ms
The timing loop is here for the case if the
controller doesnt produce an interrupt when
becoming broken. In normal case, we should
just get worken up from the interrupt.

In any case, 100 times a second polling is
not neccessary here, increase to 1 second.
2021-10-13 16:57:38 +00:00
cinap_lenrek 03d870e028 kernel: return error from sysrfork instead of waiting and retrying
The old strategy of wait and retry doesnt seem to
work very well as it keeps all the forking parents
stuck waiting in the kernel worsening the situation.

The idea with this change is to have rfork() return
error quickly; and without whining; as most callers
would just react with a sysfatal() which might be
better for surviving this.
2021-10-12 11:30:42 +00:00
cinap_lenrek b3c3c3e63d cc: do not expand function-like macros for non-function invocations
It is a bit of a annoyance that kenc will try to expand
function like macros on any symbol with the same name
and then complain when it doesnt see the '(' in the
invocation.

test case below:

void
foo(int)
{
}

struct Bar
{
	int	baz;	/* <- should not conflict */
};

void
main(void)
{
	baz(123);
}
2021-10-12 03:06:20 +00:00
cinap_lenrek 1656782f79 libthread: remove unused _workerdata() prototype from threadimpl.h 2021-10-12 01:09:40 +00:00
cinap_lenrek b474f546f0 libthread: remove more garbage: _threadnotefd, _threadpasserpid. 2021-10-12 00:52:56 +00:00
cinap_lenrek 928b38c7b9 libthread: remove unused skip() function 2021-10-12 00:51:02 +00:00
cinap_lenrek 07608c768f libthread: deal with _schedfork() and _schedexec() returning -1
The current behaviour of the kernel to deadlock itself
instead of returning an error on fork.

This might change in the future, so prepare libthread
to handle this case.

For _schedfork(), we'r going to just retry forking
on every switch, while for _schedexec(), the exec
will fail and send ~0 down the pid channel.
2021-10-12 00:49:12 +00:00
Igor Böhm 24bd67f990 acme: remove superfluous print arguments (patch from plan9port) 2021-10-05 09:40:30 +00:00
Igor Böhm a73f41bf4e sam: fix spurious overwrite message (patch from plan9port)
Fixes:

% sam -d
 -.
w /tmp/foo
/tmp/foo: (new file) #0
w /tmp/foo
?warning: write might change good version of `/tmp/foo'
2021-10-05 09:27:45 +00:00
Igor Böhm 659496081e tweak: add missing return to fix double close(…) on file descriptor…
… and avoid printing conflicting messages.
2021-10-06 13:37:39 +00:00
james palmer a13c5c3dda realemu: fix typo in usage message. 2021-10-11 18:26:14 +00:00
cinap_lenrek b51d7ca3ba devip: improve tcp error handling for ipoput
The ipoput4() and ipoput6() functions can raise an error(),
which means before calling sndrst() or limbo() (from tcpiput()),
we have to get rid of our blist by calling freeblist(bp).

Makse sure to set the Block pointer to nil after freeing in
ipiput() to avoid accidents.

Fix wrong panic string in sndsynack, and make any sending
functions like sndrst(), sndsynack() and tcpsendka()
return the value of ipoput*(), so we can distinguish
"no route" error.

Add a Enoroute[] string constant.

Both htontcp4() and htontcp6() can never return nil,
as they will allocate new or resize the existing block.
Remove the misleading error handling code that assumes
that it can fail.

Unlock proto on error in limborexmit() which can
be raised from sndsynack() -> ipoput*() -> error().

Make sndsynack() pass a Routehint pointer to ipoput*()
as it already did the route lookup, so we dont have todo
it twice.
2021-10-11 15:55:46 +00:00
cinap_lenrek ad1ab7089d devip: add comment to ip.h explaining Routehint struct 2021-10-11 12:16:21 +00:00
cinap_lenrek 5484260b42 kernel: move waserror() macro to port/portfns.h 2021-10-11 11:52:37 +00:00
qwx 3e98132fc6 addpt(2): fix inconsistency in description 2021-10-10 17:13:57 +00:00
cinap_lenrek 365e63b36a devip: properly rlock() the routelock for v4lookup() and v6lookup()
i'm not confident about mutating the route tree
pointers and have concurrent readers walking the
pointer chains.

given that most route lookups are bypassed now
for non-routing case and we are not building a
high performance router here, lets play it safe.
2021-10-10 14:27:08 +00:00
cinap_lenrek e687d25478 devip: use top bit (type) | subnet-id for V6H() route hash macro
theres no structure in the lower 32 bits of an ipv6 address.

use the top bit to distinguish special stuff like multicast
and link-local addresses, and use the 16-bit subnet-id bits
for the rest.
2021-10-10 14:22:14 +00:00
cinap_lenrek 1a6324970d devip: cache arp entry in Routehint
Instead of having to do an arp hash table lookup for each
outgoing ip packet, forward the Routehint pointer to the
medium's bwrite() function and let it cache the arp entry
pointer.

This avoids route and arp hash table lookups for tcp, il
and connection oriented udp.

It also allows us to avoid multiple route and arp table
lookups for the retransmits once an arp/neighbour solicitation
response arrives.
2021-10-09 18:26:16 +00:00
risto.salminen@gmx.com d280f411f6 upas/fs: add missing newline to a debug print
Noticed while doing some debugging.
2021-10-09 10:53:39 +00:00
james palmer a8ad3fb3d0 acme: don't let tag button draw over tag border. 2021-10-06 09:19:58 +00:00
Igor Böhm 0c0ffafb5b sam(1): fix description of ctrl+g 2021-10-05 20:17:33 +00:00
cinap_lenrek 6ebb8b9e35 devip: use better hashipa() macro, use RWlock for arp cache 2021-10-03 15:58:58 +00:00
cinap_lenrek 55c3138c64 kernel: ensure that all accesses to Mhead.mount is done with Mhead.lock acquired
The Mhead structures have two sources of references to them:

- from Pgrp.mnthash hash-table
- from a channels Chan.umh pointer as returned by namec() for a union directory

Unless one holds the Mhead.lock RWLock, the Mhead.mount chain
can be mutated by eigther cmount(), cunmount() or closepgrp().

Readers, skipping acquiering the lock where:

mountfix(): responsible for rewriting directory entries for
union directory reads; was walking the Mhead.mount chain to
detect if the passed channel itself appears in the mount list.

cmount(): had a check and copy when "new" chan was a union itself
and if the MCREATE flag is set and would copy the mount table.
All this needs to be done with Mhead read-locked while copying
the mount entries.

devproc(): in the handler for reading /proc/n/ns file.

namec(): while checking if the Chan->umh should be initialized.

In addition to this, cmount() is changed to do the mountfree()
of the original mount chain when MREPL is done after releasing
the locks.

Also, some cosmetic changes...
2021-10-03 15:56:51 +00:00
Igor Böhm b638114186 vncv: enable connecting to Darwin hosts
Tested on MacOS Catalina and Big Sur releases.

Update man page to highlight weak encryption of vnc, recommending to
tunnel via ssh (thanks unobe).
2021-09-25 20:40:47 +00:00
qwx c9b48aec54 sega(1): fix typo 2021-09-30 14:20:03 +00:00
Sigrid Solveig Haflínudóttir bd63aeb60d libtags: opus: fix duration on truncated files 2021-09-28 01:17:10 +00:00
Noam Preil df25039bb3 venti: fix fprint format string 2021-09-27 04:19:00 +00:00
cinap_lenrek d43d79bda4 devip: implement ipv4 arp timeout with icmp host unreachable notification
The IPv4 ARP cache used to indefinitely buffer packets in the Arpent hold list.
This is bad in case of a router, because it opens a 1 second
(retransmit time) window to leak all the to be forwarded packets.

This change makes the ipv4 arp code path similar to the IPv6 neighbour
solicitation path, using the retransmit process to time out old entries
(after 3 arp retransmits => 3 seconds).

A new function arpcontinue() has been added that unifies the point when
we schedule the (ipv6 sol retransmit) / (ipv4 arp timeout) and reduce
the hold queue to the last packet and unlock the cache.

As a bonus, we also now send a icmp host unreachable notification
for the dropped packets.
2021-09-26 18:43:29 +00:00
cinap_lenrek 1cff923af4 devtls: fix bwrite memory leak when channel stops being open
tlsbwrite() would call checkstate() before calling tlsrecwrite()
to make sure the channel is open. however, because checkstate()
only raises the error, the Block* passed wont be freed and
would result in a memory leak.

move the checkstate() call inside tlsrecwrite() to reuse the
error handling that frees the block on error.
2021-09-25 20:35:04 +00:00
Ori Bernstein 235ef367d7 vmx: update openbsd kernel heuristics
in OpenBSD 6.9 and up, the kernel (bsd, bsd.mp) still has
the ostype symbols, but bsd.rd appears to have lost them,
even when decompressed.

so, as a result, we should use what we have, which isn't
much.
2021-09-25 16:57:58 +00:00
cinap_lenrek 6e8b8c8f1a /sys/lib/acid/pool: format addresses using A format, instead of X (32 bit) 2021-09-25 14:51:23 +00:00
nessabeene@gmail.com 3ac6d894d7 audiohda: Add DID for Intel 200 Series PCH HD Audio 2021-09-11 12:07:16 +00:00
Ori Bernstein 8f4842d346 git: when stealing from the old packs list, keep what we stole.
we were missing a return after stealing, which killed the point
of doing the theft.
2021-09-14 16:13:58 +00:00
Ori Bernstein 390abbd1c7 archacpi: leave acpi enabled with *acpi=
*acpi= was treated the same as *acpi=0, when we
want it to be treated the same as *acpi=1
2021-09-13 23:56:26 +00:00
Sigrid Solveig Haflínudóttir 4f310b8f51 devvmx: skip tsc offset writing if CPU doesn't support it 2021-09-13 22:54:05 +00:00
Ori Bernstein c7dcc82b0b git/query: fix spurious merge requests
Due to the way LCA is defined, a using a strict LCA
on a graph like this:

 <--a--b--c--d--e--f--g
     \               /
       +-----h-------

can lead to spurious requests to merge. This happens
because 'lca(b, g)' would return 'a', since it can be
reached in one step from 'b', and 2 steps from 'g', while
reaching 'b' from 'a' would be a longer path.

As a result, we need to implement an lca variant that
returns the starting node if one is reachable from the
other, even if it's already found the technically correct
least common ancestor.

This replaces our LCA algorithm with one based on the
painting we do while finding a twixt, making it give
the resutls we want.
git/query: fix spurious merge requests

Due to the way LCA is defined, a using a strict LCA
on a graph like this:

 <--a--b--c--d--e--f--g
     \               /
       +-----h-------

can lead to spurious requests to merge. This happens
because 'lca(b, g)' would return 'a', since it can be
reached in one step from 'b', and 2 steps from 'g', while
reaching 'b' from 'a' would be a longer path.

As a result, we need to implement an lca variant that
returns the starting node if one is reachable from the
other, even if it's already found the technically correct
least common ancestor.

This replaces our LCA algorithm with one based on the
painting we do while finding a twixt.
2021-09-11 17:46:26 +00:00
cinap_lenrek 546f8cfeca 9boot: fix isowalk() for directories spanning multiple sectors
directory entries cannot span sector boundaries, meaning
that the end of a sector would be zero padded until the
next sector.

we have to skip over these zero paddings to fully read
the directory.
2021-09-11 12:26:35 +00:00
qwx e279699344 plumber: remove $plumbsrv, add optional srvname, usage check
Plumber both posts a service to /srv and sets a $plumbsrv environment
variable.  Our libplumb no longer uses $plumbsrv and nothing else
does.  It's a silly hack;  rc doesn't update /env immediately, and
scripts, which for instance set up subrios, cannot rely on it to
clean up the plumber at the end.

Instead, add the option to specify a srvname, actually check for some
common errors and print a usage string.

Thanks to Ori for input and a preliminary patch.
2021-09-10 21:03:47 +00:00
cinap_lenrek d1986d8c0e ether82598: add pci device id for ixgbe i52899 (thanks izaki) 2021-09-09 23:13:30 +00:00
cinap_lenrek 084c2e6a65 fix manpage references for dup(2), kproc(9) and panic(9). 2021-09-08 18:22:35 +00:00
cinap_lenrek 33ac896d47 ndb(2): document txt and txtrr attributes. 2021-09-08 18:20:59 +00:00
cinap_lenrek df66e62842 ndb/dns: make dblookup() consistent with cachedb operation, bring back txtrr for compatibility
- enforce same behaviour as cachedb server in dblookup():
	- force Taaaa record type on ipv6= attributes, regardless of value
	- return Taaaa records for ip= attributes containing ipv6 values
	- return Ta records only for ip= attributes containing ipv4 values

- for compatibility, bring back support for txtrr= type, but handle consistently
2021-09-08 17:34:04 +00:00