Commit graph

9124 commits

Author SHA1 Message Date
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 5465c4c01a netaudit: simplify 2021-12-01 21:59:22 +00:00
cinap_lenrek efd4d75082 netaudio: fix auth check, can have multiple auth servers! 2021-12-01 21:53:18 +00:00
cinap_lenrek 43eb7eea62 netaudit: check for sys= attribute to be free of periods 2021-11-29 20:26:12 +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
glenda e2a8d3493a /rc/bin/rc-httpd/{rc-httpd, handlers/error}: do some minimal sanitization on $SERVER_NAME before handing it off to select-handler. this prevents malformed Host: headers from retrieving arbitrary files from the file system. (thanks, Lightning) 2021-11-21 23:42:13 +00:00
Igor Böhm a27afe904d prep(8): fix typos, wording, and formating 2021-11-21 22:45:51 +00:00
cinap_lenrek 854a1ab54f vgadb: add 3rd gen intel hd graphics did (thanks mora) 2021-11-21 19:10:52 +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 45a25abc3e keyboard: add ∵ (because) and ∷ (proportion) 2021-11-14 14:44:55 +00:00
Sigrid Solveig Haflínudóttir 18bd1a92e5 keyboard: ++ = ⧺ 2021-11-14 14:36:22 +00:00
Sigrid Solveig Haflínudóttir 1343fcfe15 keyboard: complete double-struck capital set; change SS → Ss for § 2021-11-14 14:30:00 +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
cinap_lenrek 401e166bbc merge 2021-11-09 00:58:26 +00:00
cinap_lenrek fccbc30650 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 00:33:16 +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
glenda 3cf3f5481b /lib/theo: We don't need to make statements people perceive as promises. 2021-11-04 17:31:10 +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