Commit graph

8445 commits

Author SHA1 Message Date
Ori Bernstein d457233c70 patch: handle stripped/empty lines mid-hunk
Some programs will strip trailing spaces from hunks;
in this case we want to treat the line as though it
came with a leading space.

This fixes applying some patches, such as

	[PATCH] Permissions for child boards in /srv
2022-07-02 20:13:31 +00:00
xfnw 5506860da5 prevent special characters from breaking riostart 2022-07-01 16:00:37 -04:00
xfnw 4d744454c7 Merge commit '856abd2f7d2a8b4cef547762a0c125a54ca4c366' as 'sys/src/cmd/gopher' 2022-07-01 15:46:23 -04:00
xfnw c97daf119d Merge branch 'front' of git://git.9front.org/plan9front/plan9front into front 2022-06-30 11:42:24 -04:00
akw@oneirism.org 6dbfe8c356 nusb/ptp: increase payload
A silly little patch, but some ptp devices (like the camera I own) use USB3 endpoints and subsequently require the data size of the payload to be 1024(-12 for metadata). This is reflected in libgphoto2's current ptp driver.
2022-06-30 01:58:01 +00:00
Ori Bernstein e6d31c1715 spf: limit recursion depth to prevent ddos (thanks tijay, iashiq5)
An attacker may use an infinite number of SPF referrals in his/her SPF
setting and can send an email to your mail server which would make
your SMTP server make a lot of DNS queries.  By exploiting this
vulnerability, an attacker can block your SMTP queue, flood the
associated recursive resolver, or any DNS authoritative server.

According to RFC recommendations
(https://datatracker.ietf.org/doc/html/rfc7208#section-4.6), a few DNS
lookup limits exist that an SMTP server needs to maintain while
resolving an SPF record.  That is, SPF implementations MUST limit the
total number of query-causing terms to 10 and the number of void
lookups to 2 to avoid unreasonable load on the DNS.

from:

Taejoong “Tijay” Chung (tijay@vt.edu)
Ishtiaq Ashiq (iashiq5@vt.edu)
2022-06-30 01:24:27 +00:00
Jacob Moody 1f95e98ddd skelfs: dont mount if not asked to 2022-06-30 00:56:10 +00:00
Jacob Moody a13aa17e4a aux/9pcon: add assert flag 2022-06-30 00:51:59 +00:00
Jacob Moody cac03f355c kernel: revert /srv/clone 2022-06-29 17:35:27 +00:00
xfnw 58fe4bd42c Merge branch 'front' of git://git.9front.org/plan9front/plan9front into front 2022-06-29 12:08:10 -04:00
Ori Bernstein 10afa189d5 awk: correct incoherent cell in assignment (thanks smj, mpinjr)
In run.c::assign(), assigning to $0 from $F, a field,
where F >= 2, produces an incoherent cell.

The assignment occurs in two steps, first the string value
and then the float. When the string value is assigned to $0,
setsval invalidates the fields. If FS hasn't changed, after
getfval rebuilds the fields, NF = 1 and F >= 2, therefore $F
is definitely uninitialized. The result is a float val of
0.0, producing a boolean false in the pattern expression.

Coercing a string comparison gives the expected result
because the incoherent cell has the correct string
value, which is not empty and evaluates to true.
2022-06-25 20:03:41 +00:00
Ori Bernstein 5579176f4a awk: initialize records fully in recinit()
when using records in BEGIN, we would read
from the field table before we read into it;
this ensures that the fields are an empty
string before we start touching their contents.
2022-06-25 18:58:55 +00:00
Jacob Moody 5ee86cf824 kernel: correct error handling in /srv/clone read
readstr can error, we need to catch the error and unlock.
2022-06-22 15:53:32 +00:00
Jacob Moody fa0c807bfb kernel: add /srv/clone to get seperate /srv bulletin boards. 2022-06-21 13:21:38 +00:00
Ori Bernstein 7ca997bf7e ndb: increase buffer size to allow longer lines
when reading a long line such as a dkim key in a
txt record, ndb calls Brdstr, which is limited
to the size of the buffer. This means we would
fail to parse the line from NDB, and bail out
early.

Increasing the buffer size allows us to read and
parse longer lines.
2022-06-19 23:42:04 +00:00
cinap_lenrek f0fc84aba3 etherimx: fix link negotiation
mdio interrupt command completion handling was broken,
as the interrupt handler would clear the mii status
register before mdiodone() sees it.

handle errors in miistatus() and miiane(), to not get
confused.
2022-06-19 18:07:50 +00:00
cinap_lenrek 990ceeef3b nusb/usbd: retry opendevtata() a few times on attach (work around mnt-reform trackball)
this is a known and already fixed issue with version the following version
of the mnt-reform trackball firmware:

55ca5bf848
2022-06-18 23:37:12 +00:00
cinap_lenrek 2b1ecbe87d imx8/usdhc: work around broken multi-write for now
for unknown reasons, multiwrite is busted in usdhc:

sdhc: write error intr 10 stat ff88858e
usdhccmd: need to reset Datinhibit intr 10 stat ff88858e
usdhc: cmd 193a0027 arg 1e5b6b error intr 18010 stat ff88858f

i'm disabling it for now, adding a flag to the SDio struct.
2022-06-18 20:31:49 +00:00
cinap_lenrek 7bae48c452 generate boot.scr in /sys/src/boot/reform 2022-06-18 18:23:22 +00:00
cinap_lenrek ff7aa0671d /sys/lib/dist/mkfile: add target for mnt-reform image 2022-06-18 18:15:47 +00:00
cinap_lenrek a16d54da37 add /sys/src/boot/reform/mkfile to download official u-boot for the mnt-reform 2022-06-18 18:15:16 +00:00
cinap_lenrek 7d4ffb8684 aux/txt2uimage: helper for generating uimage script files 2022-06-18 18:12:38 +00:00
cinap_lenrek 73b9f7c362 imx8: fix install target 2022-06-18 14:32:51 +00:00
cinap_lenrek e760ded494 imx8/usdhc: implement highspeed mode (50Mhz) 2022-06-18 13:19:55 +00:00
cinap_lenrek 524f8c2d53 imx8/lcd: set iomux pad configuration 2022-06-18 12:49:29 +00:00
cinap_lenrek c14962657c usbxhciimx: set iomux pad configuration 2022-06-18 12:49:04 +00:00
cinap_lenrek a23e9ac65d imx8: add i2c bus driver 2022-06-18 12:48:26 +00:00
cinap_lenrek 476e7341d5 etherimx: set iomux pad configiguration 2022-06-18 12:46:18 +00:00
cinap_lenrek 63092af6a9 imx8/usdhc: cleanup, set pad configuration 2022-06-18 12:45:39 +00:00
Jacob Moody 15140dcce2 kernel: add dev dtracy provider. 2022-06-17 02:25:15 +00:00
Jacob Moody 227a46e47d ip/dhcpd: quiet up syslog
the packet prints can be found
through -d now.
2022-06-16 02:29:36 +00:00
Jacob Moody c12022fd8c skel(3) → skelfs(4)
The original intention was to put devskel in to the
kernel to detach what it provides from devsrv.
That is not a good reason, just move it to userspace.

auth/box has been changed to exec skelfs instead
of relying on '#z'.
2022-06-15 06:42:05 +00:00
cinap_lenrek c7c0ff5db6 merge 2022-06-14 23:55:02 +00:00
cinap_lenrek 28f3dc8224 imx8: port usdhc driver (from bcm/sdhc) for external sdcard
this is a total hack, only works up to 25MHz for now.
2022-06-14 23:53:03 +00:00
Jacob Moody be1789d78b kernel: bootrc: add bootloop= 2022-06-14 08:16:57 +00:00
Jacob Moody 28709be9a6 kernel: devwalk: correct debug print
nc is not yet tied to the device that
called us
2022-06-14 07:22:58 +00:00
Jacob Moody 96cc6335db kernel: devskel: use RWlock 2022-06-14 07:02:44 +00:00
cinap_lenrek 176206fb02 imx8/gpio: use u32int for bit mask 2022-06-13 23:26:14 +00:00
cinap_lenrek 04d1e6ffe9 imx8/gpio: allow 0 as "no-op" gpio pin
as the gpio controller number starts at 1,
we can use 0 to mean "no pin", so passing
0 to gpioout() or gpioin() pin argument
will have no effect.
2022-06-13 23:24:14 +00:00
cinap_lenrek fe033ae816 imx8: add gpio helper gpioout()/gpioin() 2022-06-13 23:00:06 +00:00
cinap_lenrek 8dd05d041e imx8: provide iomuxgpr() function to access iomuxc's gpr's 2022-06-13 19:48:01 +00:00
cinap_lenrek 5388575c14 imx8: better syntax for iomuxpad() options using ~ for negation 2022-06-13 19:18:50 +00:00
cinap_lenrek 90428d0561 imx8: add iomuxpad() helper for pad and mux control 2022-06-13 19:06:00 +00:00
cinap_lenrek d35e41424c imx8: make gpc functionality available with a powerup() function 2022-06-12 21:16:47 +00:00
cinap_lenrek 771a93f3b7 imx8/lcd: reduce flicker
increasing the pixel clock to 80% of the edid clock value
reduces flicker and also seems to not trigger the shifting
issue.
2022-06-12 16:15:55 +00:00
Ori Bernstein 306e7ca618 devsrv: revert 'add /srv/clone'
this leaks /srvs, revert until we can fix it.
2022-06-12 15:23:19 +00:00
cinap_lenrek e1a95f5630 merge 2022-06-12 14:43:50 +00:00
cinap_lenrek f1f5045b2e imx8/usbxhci: bring usb out of reset
do all the magic dwc3 specific initalization as well
as reset the hub and power on the phys.

with this, "usb start" command is not needed anymore
from u-boot.
2022-06-12 14:31:55 +00:00
Jacob Moody c3e1346bbc kernel: add /srv/clone
/srv/clone allows a namespace to get their
own private /srv session.
2022-06-12 00:44:10 +00:00
cinap_lenrek 1d81f7eacb imx8/lcd: silly work around for display instability
running at the actual pixel clock causes the screen
to shift horizontally after a while.

using 60% seems to fix it - for now.
2022-06-12 00:21:28 +00:00
cinap_lenrek 931ae0cfeb imx8: mainscreen turn on!
supports the lcd panel and adds alot of infrastructure
like for the ccm clock module and the i2c controllers.
2022-06-11 21:12:04 +00:00
cinap_lenrek 276f2039a9 devi2c: add generic i2c bus driver 2022-06-11 21:06:39 +00:00
Ori Bernstein 3e176bd975 git/pack: add support for skipping ssh signatures
ssh signatures confused our commit parsing; teach our
commit parsing to skip them.
2022-06-11 17:48:20 +00:00
Ori Bernstein bb33663b40 git/get: keep sending what we have until we get an ack
Git9 was sloppy about telling git what commits we have.

We would list the commits at the tip of the branch, but not
walk down it, which means we would request too much data if
our local branches were ahead of the remote.

This patch changes that, sending the tips *and* the first
256 commits after them, so that git can produce a better
pack for us, with fewer redundant commits.
2022-06-11 16:36:45 +00:00
Benjamin Riefenstahl b3dc2af6d6 man/3/ip (ip): Discuss local IP addresses for "announce" and "bind". 2022-06-11 13:00:05 +00:00
Benjamin Riefenstahl e402fd8340 ape/bsd/bind.c, ape/bsd/listen.c: Use _syserrno. 2022-07-06 03:46:07 +00:00
Benjamin Riefenstahl e01e80c5e7 ape/bsd/listen.c: Drop "bind 0".
There does not seem to be a good reason for this.  The "bind" command
has no practical consequence.
2022-07-06 03:38:17 +00:00
Benjamin Riefenstahl 2ca5abbc2b ape/bsd/bind.c: Do not pretend that the port could be negative.
Ports are filtered through "htons" which returns an "unsigned short".
2022-06-11 12:34:31 +00:00
Benjamin Riefenstahl 25a0d57478 ape/bsd/bind.c, ape/bsd/listen.c: Set local IP.
Despite what the man pages say, local addresses can actually be set so
do that.
2022-06-10 20:39:28 +00:00
Benjamin Riefenstahl d618223086 ape/bsd/listen.c: Do not try to issue "announce *".
"port >= 0" is always true, because the port always gets filtered
through "htons" which returns "unsigned short", so we can just drop
the "else" branch here.

Anyway "announce 0" works fine with the Plan9 API, there is not need
for "announce *" here.
2022-06-10 20:22:39 +00:00
Benjamin Riefenstahl 9fc38d43d4 ape/bsd/bind.c: Do not issue "bind *".
Despite the documentation, "bind *" is invalid and gives the error
"bad numeric port" in devip.c:setladdrport.

"bind 0" OTOH is actually supported fine in the Plan9 API and has the
right sematics.
2022-06-10 16:02:13 +00:00
Jacob Moody 0ec0154bc9 ktrans: don't leak on conflicting jisho lines
Tidy up the hash interface to make cleanup
a bit more explicit vs non cleanup.
2022-07-17 17:51:11 +00:00
Jacob Moody c147614656 ktrans: 你好
This consolidates jisho and map lookups
to use the same structure and removes
the old jisho code.
2022-07-17 14:52:11 +00:00
cinap_lenrek ccbabf1c16 i2c(3): fix typos, thanks quinq 2022-07-17 14:43:46 +00:00
cinap_lenrek 06d7118e94 i2c(3): Add documentation for kernels devi2c 2022-07-17 14:22:47 +00:00
Ori Bernstein 4eeefed7b0 cwfs: fix iounit negotiation
cwfs had an issue with iounit negotiation as a result
of the conversion to 9p2000 -- with the move to variable
size messages, the fixed message overhead decreased, but
the advertised message size was still adding the old
fixed overhead.

This meant that if the kernel negotiated the maximum io
size, cwfs would negotiate something larger than it
supported, and would hang up when an io of that size
was made.

In addition, the size of messages was stored in a short,
which means that negotiating an iounit larger than 16384
bytes would overflow the message count, and cause things
to fall over.

Finally, whle we're here, we clean up some duplicated
and unused constants.
2022-06-07 22:38:04 +00:00
Jacob Moody 13065e16b3 auth/box: don't bother switching to none
Changing the user to none doesn't do much for us
here. For kernel drivers that check the user of the
current proc we'll be none, but anything from devmnt
will still be accessed using creds from the original
attachment. Instead, running with none can be done
by chaining with auth/none:

auth/none auth/box ...
2022-06-10 04:10:54 +00:00
Jacob Moody 1b5ea51ee1 auth/box: bind in the binary by default
This prevents stuttering on the command line by
not having to give a -r flag for the binary itself.
2022-06-08 02:44:35 +00:00
Jacob Moody 056ad652a4 auth/box: build restricted namespaces using components from the parent. 2022-06-07 05:38:08 +00:00
Jacob Moody f4840cdba5 kernel: add devskel for pc and pc64 2022-06-07 05:25:44 +00:00
Jacob Moody df92301d8f ip/ipconfig: refactor plan9 vendor parsing
Unless ip/dhcpd is started with the -6 option,
we only receive v4 addresses. If we do see the
v6 options we should prefer them but should
also make sure we grab the v4 addresses as a fallback.

None of the v6 options should overwrite valid
overrides given at the command line.

Add our custom types to logging.
2022-06-05 20:56:57 +00:00
Jacob Moody 207d124dfe ip/dhcpd: properly skip past ipv6 addresses in addrsopt
If the first address passed happened to be an ipv6
address we would send a malformed option by never including
a ipv4 address.
2022-06-05 18:02:58 +00:00
Jacob Moody d8d433894a kernel: cleanup unused fields from devpipe
We don't need to multiply session path by 2, the definition
for NETQID is:

Meaning we don't need to save room between session paths
for individual Qid paths. This doubles the amount of
pipe sessions we can have before a wrap.
2022-06-05 12:29:50 +00:00
Ori Bernstein 926be5e34e git/import: use patch(1)
we have a new, pretty patch(1), lets use it.
2022-06-04 23:35:49 +00:00
Ori Bernstein 5d37407e3c diff: avoid empty hunks when there are no changes
Currently, diff outputs a file header, even if there are
no changes to the file. This is wonky.

It means that the header chunks are ambiguous, since
not all header chunks are followed by '@@ hunk', and
'--- file', '+++ file' lines can be generated from
file content.

This changes the way that we decide to print the file
header, so we only print it when outputting the first
hunk on flushchanges.

Flushchanges is called once per regular file, at the
end of `diffreg`, so we output a hunk header once per
file.
2022-06-04 02:21:19 +00:00
Ori Bernstein 9eb9c9e560 patch(1): remove options that don't exist
the summary mentions options that existed during
development, but no longer do.
2022-06-04 02:13:58 +00:00
Ori Bernstein 9e547f50d1 patch(1): add the manpage
forgot it in the last commit
2022-06-04 02:12:12 +00:00
Ori Bernstein 07e1620911 patch: implement a new, simpler patch program to replace ape/patch
ape/patch is a giant, ugly ball of code from almost 25 years ago,
which has not and will likely never been updated or maintained.

the world has since settled on unified diffs, and we just need a
simple program that can parse and apply them.
2022-06-04 01:56:01 +00:00
Jacob Moody 1d09995353 kernel: be more careful about argc for /dev/drivers writes
Not crashing on 'chdev &' is important.
2022-05-30 21:55:39 -04:00
Ori Bernstein fe2cbbb402 git: performance enhancements
Inspired by some changes made in game of trees, I've
implemented a number of speedups in git9.

First, hashing the chunks during deltification with
murmurhash instead of sha1 speeds up the delta search
significantly.

The stretch function was micro-optimized a bit as well,
since that was taking a large portion of the time when
chunking.

Finally, the full path is not stored. We only care about
grouping files with the same name and path. We don't care
about the ordering. Therefore, only the hash of the path
xored with the hash of the diretory is kept, which saves
a bunch of mallocs and string munging.

This reduces the time spent repacking some test repos
significantly.

9front:
	% time git/repack
	deltifying 97473 objects: 100%
	writing 97473 objects: 100%
	indexing 97473 objects: 100%
	58.85u 1.39s 61.82r 	 git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 97473 objects: 100%
	writing 97473 objects: 100%
	indexing 97473 objects: 100%
	43.86u 1.29s 47.51r 	 /sys/src/cmd/git/6.repack

openbsd:

	% time git/repack
	deltifying 2092325 objects: 100%
	writing 2092325 objects: 100%
	indexing 2092325 objects: 100%
	1589.48u 45.03s 1729.18r 	 git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 2092325 objects: 100%
	writing 2092325 objects: 100%
	indexing 2092325 objects: 100%
	1238.68u 41.49s 1373.15r 	 /sys/src/cmd/git/6.repack

go:
	% time git/repack
	deltifying 529507 objects: 100%
	writing 529507 objects: 100%
	indexing 529507 objects: 100%
	345.32u 7.71s 369.25r     git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 529507 objects: 100%
	writing 529507 objects: 100%
	indexing 529507 objects: 100%
	248.07u 4.47s 257.59r 	 /sys/src/cmd/git/6.repack
2022-05-30 21:55:39 -04:00
Jacob Moody 674fcda107 aux/listen: Allow per service namespace files 2022-05-30 21:55:39 -04:00
Jacob Moody 9fe925eaa5 kernel: add /rc to devroot
This makes it much easier to run a rc
program without needing to bind in all of '#s/boot'.
2022-05-30 21:55:39 -04:00
Jacob Moody 449fe7d8ed auth/newns: add chdev command 2022-05-30 21:55:39 -04:00
Jacob Moody e6c589312e add chdev(1) 2022-05-30 21:55:39 -04:00
Jacob Moody 00b7d2385a kernel: add chdev command to devcons 2022-05-30 21:55:39 -04:00
Michael Forney 9b19835bd4 tmparse: remove incorrect isalpha definition
Checking the range of c|0x60 incorrectly classifies many characters
as alphabetic (digits, control characters 0x01-0x20, and punctuation
characters '!'-':'). This prevents tmparse from parsing dates with
a timezone bounded by those characters (for example, "12:11:56 (PDT)").

Instead, just reuse the isalpha macro provided by ctype.h.
2022-05-30 21:55:39 -04:00
Ori Bernstein 24e5308c2a kbmap: add latin american keymap (thanks ssf) 2022-05-30 21:55:39 -04:00
Ori Bernstein 7c71da0344 diff: clean up some comments
I did the tidying and fixes. Let's remove those
comments.
2022-05-30 21:55:39 -04:00
Ori Bernstein 8eb33669cd patch(1): remove bell labs patch scripts
bell labs is dead, and nobody is listening; 9front
has our own patch submission proces.
2022-05-30 21:55:39 -04:00
Ori Bernstein 8eedca7656 diff: retain original file names
When diffing non-regular files, like /dev/null,
pipes, and similar, diff will generate a temp
file to diff against. This is the right thing
to do, but the temp file leaks into the diff.

This patch retains the original file name all
the way through to diff output.
2022-05-30 21:55:39 -04:00
Ori Bernstein 1bb7aa60c4 diff: fix style
remove useless macros, bring formatting closer
to regular 9front formatting, and use the
ARGBEGIN/ARGEND macros. No functional change.
2022-05-30 21:55:39 -04:00
Ori Bernstein 9a1428f41a git: improve error on short read
we don't recover from an invalid packet, so just
sysfatal with a useful message.
2022-05-30 21:55:38 -04:00
Jacob Moody 8fbfba1ecf aux/listen: remove Service struct
An announcing process already knows what port
it announced on, we don't need to derive it
from every connection.
2022-05-30 21:55:38 -04:00
Jacob Moody 1da69597bd aux/listen: remove argument clutter
addr and proto are globals. protodir should be
a global. let's also avoid reading the remote
addr more then once.
2022-05-30 21:55:38 -04:00
Jacob Moody a1e3ba1b6d aux/listen: remove unused cpu global 2022-05-30 21:55:38 -04:00
Jacob Moody 9e414386d4 kernel: remove dead case from devpipe
This code is checking the return of devwalk for
a walk resulting in a clone of an open pipe file. However,
devclone ensures that the chan we are cloning is not
currently open.
2022-05-30 21:55:38 -04:00
Jacob Moody 5f49f8ac9c aux/listen: remove special cases for depreciated datakit
The getserv function has remained mostly unchanged since
1ed. These checks are for handling string local ports
or lack thereof. This was used by datakit at the time,
where 'ports' were service strings. This made the default
datakit service 'login' when a connector did not give
a specific service. The checks for directory traversal also
seemed specifically to guard against a connector from providing
a malicious service string. With datakit gone all current protocols
use numerics as ports so these checks and defaults become uneeded.

1ed reference:
https://github.com/plan9foundation/plan9/tree/1e-1992-09-21
2022-05-30 21:55:38 -04:00
Ori Bernstein b360a7c765 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-30 21:55:38 -04:00
Sigrid Solveig Haflínudóttir 2bb988b1e2 icanhasvmx: our vmx requires unrestricted guest too 2022-05-30 21:55:38 -04:00
Jacob Moody 2c7f86e0d4 fork(2): fix commas in RFNOMNT references 2022-05-30 21:55:38 -04:00