Commit Graph

274326 Commits

Author SHA1 Message Date
jmcneill
65d0cc155b Add BCM54213PE 2020-02-22 18:56:57 +00:00
thorpej
fd6e085f9e Make it clear that the pfn argument to alpha_init() is no longer used. 2020-02-22 17:33:42 +00:00
fox
819b6be2db common/lib/libc/stdlib: Fix possible signed integer overflow.
common/lib/libc/stdlib/random.c:482:6 can result in signed integer overflow.

This bug was reported by UBSan runs.

The change has been tested using the following program to generate random numbers
in both the old and the new library and can be used to verify the correctness of the
library after the change.

#include <stdio.h>
#include <stdlib.h>

#define COUNT 1000 * 1000

int
main(void)
{
        int i;
        FILE *fp = fopen("numbers.txt", "w");

        srandom(0xdeadbeef);

        for(i = 0; i < COUNT; i++) {
                fprintf(fp, "%ld\n", random());
        }

        fclose(fp);

        return 0;
}

Reviewed by: riastradh@ , kamil@
2020-02-22 14:47:29 +00:00
pgoyette
9a34b1cfc9 Clarify that the -k option only provides the address of the module's
text segment.  The addresses of any other segments are not available.
2020-02-22 14:26:18 +00:00
kamil
6aee95b41f Avoid undefined behavior in the rand48(3) implementation
Instead of implicid promotion to signed int,
explicitly cast the arguments to unsigned int.

_rand48.c:53:27, signed integer overflow:
58989 * 58970 cannot be represented in type 'int'

_rand48.c:53:38, signed integer overflow:
-2093025904 + -1496809120 cannot be represented in type 'int'

_rand48.c:53:57, signed integer overflow:
57068 * 42787 cannot be represented in type 'int'

New and old code produce the same code as tested with:

#include <stdio.h>
#include <stdlib.h>

#define COUNT 1000 * 1000

int
main(void)
{
	FILE *fp;
        int i;

        fp = fopen("numbers.txt", "w+");
	if (!fp)
		abort();

        for(i = 0; i < COUNT; i++) {
                fprintf(fp, "%f\n", drand48());
                fprintf(fp, "%ld\n", lrand48());
                fprintf(fp, "%ld\n", mrand48());
        }

        fclose(fp);

        return 0;
}
2020-02-22 14:07:57 +00:00
pgoyette
79e45209ec Remove vestigial remnant of an earlier modification to the module
implementation.  There currently is no such thing as a module's
"alias".
2020-02-22 14:06:05 +00:00
jmcneill
c992f78e6a Add support for hardware rx filters. 2020-02-22 13:41:40 +00:00
kamil
57225a2ce5 Reorder words to fix grammar
Noted by <leot>
2020-02-22 13:20:21 +00:00
kamil
756b86e872 rand48: Document that short integers are unsigned 2020-02-22 11:56:13 +00:00
roy
536a6b742b Revert unrelated changes to prior 2020-02-22 11:55:43 +00:00
roy
68c104dbdb rc.d/network: improve wording of waiting for DAD to finish 2020-02-22 11:52:45 +00:00
kamil
2bddf73745 Improve readability of __dorand48()
Break long lines into shorter instructions per line.

No Functional Change.
2020-02-22 11:24:47 +00:00
jmcneill
300584e77e Remove check for bestmode==-1 (shouldn't happen) 2020-02-22 10:30:37 +00:00
kamil
6ab39b6716 Avoid undefined behavior in left shift
crypt.c:772:11, left shift of 1363235140 by 1 places cannot be represented
in type 'int32_t' (aka 'int')
2020-02-22 10:29:17 +00:00
kamil
96be1c9965 Avoid undefined behavior in bit shift operations
crypt.c:839:40, left shift of negative value -1197182952
crypt.c:840:40, left shift of negative value -264997776
2020-02-22 10:22:32 +00:00
kamil
e1278de2f9 Avoid NULL pointer arithmetics on environ
_env.c:260:9, pointer expression with base 0 overflowed to 0
_env.c:260:9, load of null pointer of type 'char *'
2020-02-22 10:05:12 +00:00
kamil
b110dc906e Avoid unportable shift construct
boot.c:150:29, left shift of 255 by 24 places cannot be represented in type 'int'
boot.c:153:29, left shift of 255 by 24 places cannot be represented in type 'int'
2020-02-22 09:59:22 +00:00
skrll
f7f69ae002 Define pinctrl-names for sdhci to fix it. From Harold Gutch and discussed
on port-arm.

http://mail-index.netbsd.org/port-arm/2020/02/13/msg006497.html
2020-02-22 09:54:27 +00:00
roy
5403a7a7c1 zfs: build a ramdisk on amd64 with enough to mount rpool/ROOT on /
Until we get ZFS integrated into our boot loader, this is the next best
thing. The idea is simple - have a small FFS partition with a kernel,
modules and this ramdisk. Once the ramdisk boots it will mount the FFS
partition read only, copy the needed ZFS modules to the ramdisk and then
unmount the partition. Then we import the ZFS root pool, mount the
ZFS root filesystem and then pivot to it.

Because the initial FFS partition is not mounted at this point, we
can mount it in /altroot so we can replace the kernel and modules with
newer ones so it's easily maintainable.

This ZFS boot strapper currently makes the following assumptions:
 * The device NAME=boot is the FFS with kernel, modules and this ramdisk.
 * The ZFS root pool and root filesystem are called rpool/ROOT.

A boot.cfg menu entry can then be added like so:
menu=Boot ZFS root:fs /ramdisk-zfsroot.fs;boot
2020-02-22 09:53:47 +00:00
maxv
11fc230787 pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
2020-02-22 09:42:20 +00:00
jmcneill
2426b4c1e2 If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000
2020-02-22 09:34:26 +00:00
maxv
a4bb61b904 pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
2020-02-22 09:30:42 +00:00
maxv
99c26a8a3e pass the address of the field, instead of relying on it being the first
field of the structure, no functional change, ok kamil
2020-02-22 09:24:05 +00:00
maxv
0d945ea0ff Inline the block in the parent block, for clarity, and also to prevent a
false positive with kMSan.

Here, LLVM reorders the conditions and checks 'vattr' before 'error'. But
if 'error' is non-zero then 'vattr' is not initialized, and kMSan notices
the uninitialized memory read.
2020-02-22 08:58:39 +00:00
maxv
559c53d028 Zero out 'tv', to prevent uninitialized bytes in its padding from leaking
to userland. Found by kMSan.

Reported-by: syzbot+8134380511a82c8f5fd7@syzkaller.appspotmail.com
2020-02-22 08:39:33 +00:00
skrll
adfb9b968c Fix previous for _ARM32_NEED_BUS_DMA_BOUNCE 2020-02-22 08:22:09 +00:00
isaki
4f60b558c3 Make calling get_props() lockless.
get_props() of all MD drivers now can be called without sc_lock.
2020-02-22 08:15:09 +00:00
isaki
6d13f8a36a On audio_[pr]mixer_halt(), it's better to reset parameters in intr_lock. 2020-02-22 08:03:19 +00:00
isaki
710d84f6ac Add KASSERTs. audio_[pr]mixer_start() need exlock. 2020-02-22 08:01:59 +00:00
isaki
3dc846c0d9 Move #if DIAGNOSTIC..#endif to correct place.
It should ignore stray interrupts regardless of DIAGNOSTIC.
2020-02-22 07:59:47 +00:00
isaki
379e7aeb32 hw_if->query_format is already mandatory method. Drop null checks. 2020-02-22 07:09:18 +00:00
isaki
61f731db38 Improve KASSERT messages. 2020-02-22 06:58:39 +00:00
isaki
63cdbdbe8c Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.
2020-02-22 06:36:07 +00:00
isaki
9fd5ffc974 const-ify. These arguments are no longer written back. 2020-02-22 06:28:10 +00:00
isaki
5eda9f581a Fix/Update comments. 2020-02-22 06:22:46 +00:00
isaki
a05df8ab92 Update AUDIO_SETINFO_channels test.
The kernel limits the number of channels that userland apps can set to
the number of channels supported by the hardware or less.
2020-02-22 05:53:19 +00:00
isaki
0b3fcad9a1 Limit the number of channels that userland apps can set (by AUDIO_SETINFO)
to the number of channels supported by the hardware or less, if the hardware
supports multi channels.
- On monaural or stereo hardware, userland apps can always set 1ch or 2ch.
  The kernel (audio layer) can convert mono-stereo each other.
- On 3ch (2.1ch) hardware, for example, userland apps can set 1, 2, or 3ch,
  but not 4ch or more.
This allows userland apps to know actual number of channels supported by
the hardware in the same way as before.
PR kern/54973.
2020-02-22 05:51:39 +00:00
jmcneill
cb1ea6d12b Add ACPI glue for Broadcom GENETv5 2020-02-22 02:28:06 +00:00
kamil
7cd593c092 Avoid undefined behavior
route.c:1523:20, left shift of 1073741824 by 1 places cannot be represented
in type 'int'
2020-02-22 00:42:15 +00:00
kamil
35ea0de335 Avoid unportable left shift construct
left shift of 9 by 28 places cannot be represented in type 'int'
2020-02-22 00:38:14 +00:00
kamil
5c041fb274 Avoid undefined behavior in *_BITMAP_FREE() macros
left shift of 1 by 31 places cannot be represented in type 'int'
2020-02-22 00:32:08 +00:00
jmcneill
75b925d5cf Add support for Broadcom GENET v5 ethernet controller as found on the
Raspberry Pi 4 (BCM2711).
2020-02-22 00:28:35 +00:00
kamil
93226e2fbb Avoid undefined behavior in get_modstat_info
t_modctl.c:114:16, member access within misaligned address 0x71bf5bcede84
for type 'struct modstat_t'

t_modctl.c:116:13, load of misaligned address 0x7e81bc3c9104 for type
'struct modstat_t' which requires 8 byte alignment
2020-02-22 00:24:15 +00:00
kamil
b216505454 Avoid undefined behavior in disabledstat
t_builtin.c:174:16, member access within misaligned address 0x741271c25004
for type 'struct modstat_t'

t_builtin.c:175:4, member access within misaligned address 0x741271c251c4
for type 'struct modstat_t'
2020-02-22 00:18:55 +00:00
jmcneill
cb06b35c41 Translate bus addresses for SCB on BCM2711 2020-02-22 00:17:54 +00:00
maya
7b32337ee9 Make sure to convey a failure to the calling function
Likely fix for PR kern/54999, but that was a one-off panic.
2020-02-21 23:27:06 +00:00
kamil
ea9be1b430 Mark division by 0 as expected in sigfpe_int
Disable ubsan instrumentation on the operation.
2020-02-21 22:25:50 +00:00
kamil
510d9ff8d5 Avoid undefined behavior in is_module_present()
t_fopen.c:339:18, member access within misaligned address 0x7f7ff7ebd004
for type 'modstat_t' (aka 'struct modstat') which requires 8 byte alignment
2020-02-21 22:14:59 +00:00
kamil
ca9a018f12 Avoid undefined behavior in *BIT macros
hash_page.c:792:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:855:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:779:3, left shift of 1 by 31 places cannot be represented in type 'int'
2020-02-21 22:04:06 +00:00
maxv
e3ba625111 In pmap_changeprot_local(), drop the dirty bit along with the write bit. 2020-02-21 18:34:37 +00:00