Commit Graph

295513 Commits

Author SHA1 Message Date
rillig 388550b026 lib: remove CONSTCOND comment
Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
2022-04-19 20:32:14 +00:00
rillig 86c56211f3 lint: do not warn about converting (1234567L & 0xFF) to unsigned char
Due to the '& 0xFF', there is no possible loss of accuracy.
2022-04-19 20:08:52 +00:00
rillig 889169b58b tests/lint: demonstrate wrong warnings for conversion from long to char 2022-04-19 19:56:29 +00:00
skrll a60573591b Typo in comment. avoinds -> avoids 2022-04-19 09:25:38 +00:00
riastradh 2348e3fa22 audio(4): Wait for opens to drain in detach.
Otherwise detach may barge ahead and start freeing things before open
has finished and is about to use them after free.

Reported-by: syzbot+31d2619e72c2c8436cc9@syzkaller.appspotmail.com
2022-04-19 09:19:53 +00:00
riastradh d67e9a1cf0 umcs(4): Avoid using uninitialized data if register read fails.
Reported-by: syzbot+511b32f415150b469250@syzkaller.appspotmail.com
2022-04-19 01:35:28 +00:00
riastradh 958799f7a1 mmap(2): If we fail with a hint, try again without it.
`Hint' here means nonzero addr, but no MAP_FIXED or MAP_TRYFIXED.

This is suboptimal -- we could teach uvm_mmap to do a fancier search
using the address as a hint.  But this should do for now.

Candidate fix for PR kern/55533.

ok chs@
2022-04-19 01:34:52 +00:00
jkoshy b47ec9f9c1 Disconnect 'tools/lib{elf,dwarf}' from the build.
These libraries are now built by 'tools/elftoolchain/lib{elf,dwarf}'
respectively.
2022-04-18 19:46:35 +00:00
jkoshy 6969f6c52d Update 'tools/ctf{merge,convert}' to use the new build locations for
'libelf' and 'libdwarf'.
2022-04-18 19:40:06 +00:00
sjg d3c45bc7c4 Comment on interaction of posix.mk with[out] -r 2022-04-18 16:09:05 +00:00
sjg e5f8f85da5 Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is
Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.
2022-04-18 15:59:39 +00:00
rillig ddac43c43f make: only switch to POSIX mode if '.POSIX:' is the first line
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area.  For NetBSD make, there is no big
difference since it doesn't ship any <posix.mk> file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to <posix.mk> resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.
2022-04-18 15:06:27 +00:00
rillig 3b7543fb74 tests/make: refine documentation of test for .USEBEFORE 2022-04-18 14:41:42 +00:00
rillig 2f92faa198 tests/make: extend tests for .USE and .USEBEFORE 2022-04-18 14:38:24 +00:00
jkoshy 2718af68c3 Build 'libelf' and 'libdwarf' under 'tools/elftoolchain', after
'tools/elftoolchain/common' has been built.

This change aligns the 'tools' build with the regular build.

Subsequent commits will change 'tools/libctf' and
'tools/cft{merge,convert}' to use the new build paths.
2022-04-18 14:11:43 +00:00
jmcneill c1dc8d88d4 Do not attach if the parent bus failed to provide an ISA chipset tag. 2022-04-18 10:09:07 +00:00
kre 21f0086877 Introduce a new macro JNUM to replace the idiom jp-jobtab+1
(the job number, given jp a pointer to a jobs table entry)
used open coded previously in many places (mostly in DEBUG mode
trace messages, so not included in most shells, but there are
a few others).

Make the type of JNUM() be int rather than the ptrdiff_t the
open coded version became ... which when used in some printf()
type function arg list was cast to some other arbitrary (but not
consistent) int type for which there is a standard %Xd type
format conversion.   Now we can (and do) just use %d for this.

If the number of jobs ever exceeds the range of an int, we would
have far more serious problems than the broken output this would
cause.

While here improve a comment or two, and use JOBRUNNING instead
of 0 where the intent is the former (JOBRUNNING is #defined as 0).

NFCI.
2022-04-18 06:02:27 +00:00
andvar e2710f6fc4 fix various typos in comments. 2022-04-17 21:24:52 +00:00
skrll d90e99ab09 Add the missing kpreempt_enable to pmap_deactivate_efirt 2022-04-17 15:20:36 +00:00
riastradh cc0b7b70b6 umb(4): Use memcpy, not potentially unaligned/aliased casts. 2022-04-17 13:17:56 +00:00
riastradh 1b20ed72c9 umb(4): Validate descriptor lengths. 2022-04-17 13:17:40 +00:00
riastradh 0207ad5e9c uvideo(4): Parse descriptors more robustly.
Validate lengths and types before barging ahead.

Not sure exactly which missing validation syzbot tripped on here, but
I'm pretty sure I caught all the cases.

Reported-by: syzbot+60f0a25c077b67547f57@syzkaller.appspotmail.com
2022-04-17 13:17:30 +00:00
riastradh 125fef94f7 uvideo(4): Convert conditional to KASSERT in uvideo_attach.
usb_desc_iter_next_interface no longer returns truncated interface
descriptors, so we no longer have to check for that here.
2022-04-17 13:17:19 +00:00
riastradh c724904f74 uvideo(4): Convert conditional to KASSERT in uvideo_unit_alloc.
The one caller guarantees the condition already.
2022-04-17 13:17:06 +00:00
riastradh 3f890ac7c9 usbdi(9): Make usb_desc_iter_next_interface reject truncated descs.
Currently callers have to check whether the descriptor is truncated,
which is willy.
2022-04-17 13:16:52 +00:00
riastradh 0cbf2210b6 usbdi(9): Minor KNF and tidying in descriptor iteration.
No functional change intended.
2022-04-17 13:16:43 +00:00
riastradh 76c0c016d1 uvideo(4): Use sizeof(*p), not sizeof(T), for kmem_alloc/free.
No functional change intended.
2022-04-17 13:16:11 +00:00
riastradh bb8ca98ecf uvideo(4): KNF comment style.
No functional change intended.
2022-04-17 13:15:48 +00:00
riastradh 1ff81b5206 usbdi(9): Restore usb_descriptor_t to its correct definition.
Descriptors in the USB spec all start with bLength and
bDescriptorType.  bDescriptorSubtype is only for certain
class-specific descriptors.  Many descriptors, such as
usb_device_descriptor_t, _do not_ have bDescriptorSubtype, so using a
structure that has bDescriptorSubtype for such descrpitors is wrong.

There is some history here:

- Back in 1998, when augustss@ introduced the USB stack, the type
  usb_descriptor_t was erroneously defined with a bDescriptorSubtype
  member.

- In 2007, drochner@ removed this member to accurately reflect the
  USB spec.

- In 2018, khorben@ appeared to have accidentally reintroduced it
  while importing the umb(4) driver from OpenBSD, which still has the
  erroneous bDescriptorSubtype member in usb_descriptor_t.

The umb(4) driver has since been adjusted to correctly use
usb_cdc_descriptor_t instead of usb_descriptor_t (and I have now
restored umidi_cs_descriptor_t which I had removed last month before
I realized this history of usb_descriptor_t), so this member is no
longer necessary.
2022-04-17 13:15:37 +00:00
riastradh 94b67f6281 umb(4): Use usb_cdc_descriptor_t for bDescriptorSubtype.
Note: This needs more length validation!  TBD in a separate commit.
2022-04-17 13:15:27 +00:00
riastradh 30981b9459 umidi(4): Restore umidi_cs_descriptor_t type.
Had been previously deleted under the misapprehension that
usb_descriptor_t is appropriate here, but it's not -- it should not
have the bDescriptorSubtype member.
2022-04-17 13:15:15 +00:00
riastradh da1e681497 uvideo(4): Avoid printing off the end of truncated descriptors. 2022-04-17 13:15:05 +00:00
riastradh 89f519024a ucom(4): Make sure rndsource is attached before use and detach.
Reported-by: syzbot+04fb6786e0cf873905e8@syzkaller.appspotmail.com
2022-04-17 09:25:24 +00:00
riastradh 0252e404ef panic(9): Serialize panicstr access and printing `panic:' message.
This isn't riskier than before -- previously we took kprintf_lock
inside each separate printf/vprintf call here.  Now we just take it
once around access to panicstr and printing the message.

With any luck, this should help avoid interleaving panic messages
with each other and with other output -- and maybe cut down on the
number of syzkaller duplicates.
2022-04-17 09:09:13 +00:00
jmcneill b345aafc1f eqos: Freeze counters to prevent unhandled interrupts 2022-04-16 23:20:47 +00:00
rillig 78a8d15996 lint: merge mod_t.m_test_context into m_requires_bool
These two flags mean exactly the same.

No functional change.
2022-04-16 22:21:10 +00:00
rillig b1dadfd56b lint: clean up table with operator properties
Now that lint may use C99, make use of empty macro arguments.

No binary change.
2022-04-16 21:22:12 +00:00
rillig ba92662bc0 lint: rename members of tnode_t to more closely match reality
The flags do not describe the left operand of the node but both, as for
most operators, either none or both operands are in test context or in
value context.

The one exception is the operator '?' from the '?:' conditional, for
which the left operand is in test context and the right operand is in
value context.

No binary change.
2022-04-16 21:14:33 +00:00
rillig 4ffab22634 lint: investigate why lint only warns about some constant conditions
Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.
2022-04-16 20:57:10 +00:00
rillig 82c1f72934 lint: fix instructions for adding a new test 2022-04-16 20:18:51 +00:00
rillig 18adea31f2 lint: remove null marker from keyword table
No functional change.
2022-04-16 20:08:35 +00:00
rillig f8dac4099a lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords.  Instead of
initializing the individual fields separately, merge them by specifying
the year of the standard in which they appeared.

No binary change, except for line numbers in assertions.
2022-04-16 20:02:55 +00:00
rillig f285ea576b lint: migrate gflag to allow_gcc
No functional change.
2022-04-16 19:18:17 +00:00
rillig e22a01f54b tests/lint: fix tests on platforms other than x86_64
In msg_259_ilp32.c 1.6 from 2022-04-15, I removed the option -S from the
test in order to keep the message 259, but I forgot to fix the C99-style
comment as well.

In platform_int.c, the default lint option -S no longer generated
warning 259, so remove that option.
2022-04-16 18:41:21 +00:00
andvar f84252b461 fix various typos in comments and log messages. 2022-04-16 18:15:20 +00:00
rillig 5db2a0cfc6 lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's
"section".  All other keywords passed 0 in that macro argument.

No binary change.
2022-04-16 18:13:54 +00:00
andvar b73e416b78 s/setted/set/ 2022-04-16 17:35:57 +00:00
andvar d9ce09084b s/strickly/strictly/ 2022-04-16 17:34:34 +00:00
andvar 17599227bf Fix mistake in error branch locking caused by previous changes.
vput(vp) also unlocks vp, thus unlocking happens twice in error flow
causing kernel to panic with failed assertion lktype != LK_NONE
in vfs_vnode.c#778. Thanks riastradh with finding the issue.
2022-04-16 16:40:54 +00:00
rillig a14c0654d8 lint: for gnuism and c99ism, calculate severity
Calculating the severity as a simple sum removes the condition sequence
'a && !b, or else a || !b', which can quickly become a brain twister,
especially when negations are involved.

No functional change.
2022-04-16 15:55:10 +00:00