Commit Graph

259282 Commits

Author SHA1 Message Date
kamil 7806b47917 Rework perform_arith_op() in expr(1) to omit Undefined Behavior
The current implementation of operations - + * / % could cause Undefined
Behavior and in narrow cases (INT64_MIN / -1 and INT64_MIN % -1) SIGFPE
and crash duping core.

Detected with MKSANITIZER enabled for the Undefined Behavior variation:
# eval expr '4611686018427387904 + 4611686018427387904'
/public/src.git/bin/expr/expr.y:315:12: runtime error: signed integer overflow: 4611686018427387904 + 4611686018427387904 cannot be represented in type 'long'

All bin/t_expr ATF tests pass now in a sanitized userland.

Sponsored by <The NetBSD Foundation>
2018-06-12 18:12:18 +00:00
christos 88efda49f6 remove extra quotes. 2018-06-12 15:41:35 +00:00
christos bf830a4102 - instead of hard-coding the include paths in mkioctls, pass them in
from the Makefile so that they are consistent.
- do more sed so that destination paths are not hard-coded inside #include
  statements.
2018-06-12 15:40:39 +00:00
kamil d6d5f49c60 Change typ of tilde_ok from int to unsigned int in ksh(1)
UBSan can detect that during switching a login to root there is unportable
left shift operation:

$ su -
Password:
/public/src.git/bin/ksh/eval.c:598:13: runtime error: left shift of 1073741824 by 1 places cannot be represented in type 'int'
#

Sponsored by <The NetBSD Foundation>
2018-06-12 14:13:55 +00:00
kamil 463be44101 Do not use index out of bounds in nawk
$ awk '{w=$1}' < /dev/null
/public/src.git/external/historical/nawk/bin/../dist/lex.c:476:16: runtime error: index -1 out of bounds for type 'const Keyword [46]'

There used to be documented a bug in the code that index ouf of bounds
can in theory fault (by daniel barrett).

Before assigning the pointer, first check for the index whether it's not
not -1. This was a suggested solution in the comment in the code.

The sanitizer is overcautious as this pointer wasn't dereferenced, but
fix is nonetheless.

Sponsored by <The NetBSD Foundation>
2018-06-12 13:24:28 +00:00
thorpej e4ede69598 When initiating a transfer, if a device isn't present, we won't
get an ACK after sending the address.  Check for this alternate
state and suppress the error message when it occurs.

Fixes PR kern/53356.
2018-06-12 13:18:48 +00:00
jmcneill 8baf3a2138 Process assigned clock parents and rates on clock provider nodes. 2018-06-12 10:28:55 +00:00
ozaki-r 8434fb2752 Check if ether_ifdetach is called without INET_LOCK 2018-06-12 07:12:35 +00:00
ozaki-r 9da465c4ef Add tests of vlan with bridge
The tests trigger a panic reported in PR kern/53357.
2018-06-12 04:21:22 +00:00
ozaki-r bf03e726ab vlan: call ether_ifdetach without IFNET_LOCK
Fix PR kern/53357
2018-06-12 04:20:36 +00:00
kamil 2760f15b81 Correct Undefined Behavior in gzip(1)
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# progress -zf ./games.tgz  tar -xp -C "./" -f -
/public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of 251 by 24 places cannot be represented in type 'int'
100% |****************************************************************************************************************| 44500 KiB  119.69 MiB/s    00:00 ETA


Refactor the following code into something that is more clear
and fix signed integer shift, by casting all buf[] elements to
(unsigned int):

unsigned char buf[8];
uint32_t usize;
[...]
else {
    usize = buf[4] | buf[5] << 8 |
            buf[6] << 16 | buf[7] << 24;
[...]

New version:

    usize = buf[4];
    usize |= (unsigned int)buf[5] << 8;
    usize |= (unsigned int)buf[6] << 16;
    usize |= (unsigned int)buf[7] << 24;

Only the "<< 24" part needs explicit cast, but for consistency make the
integer promotion explicit and clear to a code reader.

Sponsored by <The NetBSD Foundation>
2018-06-12 00:42:17 +00:00
jmcneill 26a17ff4d4 If we don't have a native driver for a node and it has a simple-mfd
compatible string, treat it the same as a simple-bus.
2018-06-12 00:19:17 +00:00
christos a8d37ef71d switch from MAKEOBJDIRPREFIX to MAKEOBJDIR. 2018-06-11 21:37:29 +00:00
christos adf8f6f4a2 Switch from using MAKEOBJDIRPREFIX to MAKEOBJDIR 2018-06-11 21:36:20 +00:00
christos 24ac53912b switch CFLAGS from using MAKEOBJDIRPREFIX to MAKEOBJDIR. This whole thing
is disgusting, but fixing it properly. requires restructuring
2018-06-11 21:35:13 +00:00
maya 9616ec28db Avoid left-shifting a negative number in the non-compat case, too. 2018-06-11 20:28:23 +00:00
jakllsch 70ed068d8b Fix fdtbus_get_cells(, 2) when running big endian. 2018-06-11 19:54:39 +00:00
jakllsch dabb005d56 fill in vexpress_platform_early_putchar(); make comment about CONSADDR 2018-06-11 19:49:18 +00:00
jakllsch aade04f98a fix xputc for big endian 2018-06-11 19:42:22 +00:00
jdolecek c0cdc2cf1e Factual correction: actually old code also used number of octents, but set
sc_if->sk_tx_ramend to invalid value, and assumed 128k buffer when
SK_EPROM0 read returned zero

(no code change)
2018-06-11 19:40:05 +00:00
reinoud 73230b59c8 Now we use timestamp info, use direct console output instead of kernel
timestamped output for usage() reporting
2018-06-11 19:35:56 +00:00
reinoud 8013e6a301 Prevent nested SIGIOs ruining the system stack 2018-06-11 19:23:21 +00:00
jdolecek ee32b5a5c7 adopt tx/rx buffer size computation from OpenBSD rev. 1.51 to fix
"random" msk failures

the crucial fix is that the start/end adresses are computed and
written to hw registers in number of octets (i.e. size /
sizeof(u_int64_t)), as that is actually what the hardware expects

fixes PR kern/36454 (which had fix which highlighted the trouble),
and seems likely to also fix kern/35711 and port-i386/42514
2018-06-11 19:13:38 +00:00
maya a3ebee93c8 Add configure check and fallback definition for u_longlong_t
Should help linux tools compilation of dtrace tools, and not
affect NetBSD.

From Chuck Zmudzinski in current-users, with light modification
by myself.
2018-06-11 18:48:24 +00:00
kamil 5a889623ce Correct Undefined Behavior in libc/citrus
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# nm /usr/lib/libc.so|grep sanit
/public/src.git/lib/libc/citrus/modules/citrus_mapper_std.c:173:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Sponsored by <The NetBSD Foundation>
2018-06-11 18:03:38 +00:00
kamil 5f51a87ea5 Correct Undefined Behavior in ifconfig(8)
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# ifconfig
alc0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ec_capabilities=3<VLAN_MTU,VLAN_HWTAGGING>
        ec_enabled=0
        address: xx:xx:xx:xx:xx:xx
/public/src.git/sbin/ifconfig/af_inet.c:102:34: runtime error: left shift of 16777215 by 8 places cannot be represented in type 'int'
        inet 192.168.0.38/24 broadcast 192.168.0.255 flags 0x0
        inet6 xxxx::xxxx:xxxx:xxxx:xxx%alc0/64 flags 0x0 scopeid 0x1
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
        inet 127.0.0.1/8 flags 0x0
        inet6 ::1/128 flags 0x20<NODAD>
        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2

Change shifting left 1 to shifting 1U. This corrects the issue.

        if (cidr < 32) {                /* more than 1 bit in mask */
                /* check for non-contig netmask */
                if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0) // <- here
                        return -1;      /* noncontig, no pfxlen */
        }

Solution suggested by <uwe>

Sponsored by <The NetBSD Foundation>
2018-06-11 17:45:50 +00:00
christos 9137a68872 use LIBISCXX = yes, instead of hard-coding the c++ library. Suggested by joerg 2018-06-11 15:29:33 +00:00
kamil 1c426e1841 Restore the MKGROFF=bo MKCXX=yes build
Mark the documentation in dc(1), gprof(1), rogue(6) and fsck_ffs(8) with
the .roff flag in SUBDIR.

Sponsored by <The NetBSD Foundation>
2018-06-11 14:18:16 +00:00
christos b1e04fb08c Add libstdc++ again; needed for:
undefined reference to `typeinfo for __cxxabiv1::__class_type_info'
undefined reference to `typeinfo for __cxxabiv1::__si_class_type_info'
undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
undefined reference to `typeinfo for std::type_info'
undefined reference to `__dynamic_cast'
2018-06-11 12:47:47 +00:00
msaitoh 6aca29bffd Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
 - Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
   in ixgbe_acquire_swfw_sync_X540().
 - Add some unused macros (IXGBE_FW_LESM_*).
2018-06-11 10:34:18 +00:00
christos d58777d134 Handle more objdir variations for MKREPRO (untested) 2018-06-11 01:34:03 +00:00
christos 2357fc5dd5 use SUBDIR.roff suggested by uwe@ 2018-06-10 17:55:11 +00:00
jdolecek 3d8c9e20d7 convert the (still disabled) 'direct write' for pipes to use the
experimental PMAP_DIRECT if available; the direct code paths now survive
longer than the pmap_enter() variant, but still triggers panic during
build.sh tools run; remove some obsolete sysctls

add some XXXs to mark places which need attention to make this more stable

Note: the loan case is now actually significantly slower than the
non-loan case on MP systems, due to synchronous IPIs triggered by
marking the page read-only by uvm_loan(); this is being discussed
in the email thread
https://mail-index.netbsd.org/tech-kern/2018/05/21/msg023441.html

that is basically the same issue due to which loaning was disabled
for sosend()
2018-06-10 17:54:51 +00:00
jmcneill b8cc3839ab If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.
2018-06-10 17:52:20 +00:00
kamil e153ab384c Fix the MKGROFF=no MKCXX=yes build
Allow to disable building groff. This is a build tool written in C++.

This option is useful with an external toolchain configured for building the
distribution rather than building tools (e.g. C++ lookup paths may differ).

Looks ok by <christos>

Sponsored by <The NetBSD Foundation>
2018-06-10 17:17:46 +00:00
jakllsch 55ebc0875f remove irrelevant pci(9) #includes from virtio child drivers 2018-06-10 14:59:23 +00:00
jakllsch 03046bf097 The virtio block device capacity config item is expressed always in
request protocol sector units of 512 bytes.

Also, add and use a symbolic constant to refer to request protocol
sector units.
2018-06-10 14:43:07 +00:00
jmcneill 9a2e3e05ca Add fdtbus_clock_byname, which can be used by clock backends to
lookup clocks in other domains by "clock-output-names" property.
Not intended for ordinary driver use.
2018-06-10 13:26:29 +00:00
zafer 061f0fcc8a Set default homeperm values before writing usermgmt.conf file and honor values in it instead of ignoring it.
Fixes PR bin/40324 by Guy Yur
2018-06-10 07:52:05 +00:00
christos aa66956410 But set NOSANITIZER 2018-06-09 23:45:56 +00:00
christos 64715b9aa8 We can't build those three with MKSANITIZER, they are used too early. 2018-06-09 22:41:55 +00:00
christos 1ed1559579 don't depend on libstdc++ 2018-06-09 22:40:00 +00:00
christos db50de0d5b consistency, define to empty. 2018-06-09 22:39:29 +00:00
oster 362990b68f Fix two mis-spellings in comments. No functional changes. 2018-06-09 21:18:41 +00:00
jdolecek f894490ecd port basic match support for several more Yukon variants from OpenBSD, together
with some basic conditionals I've found in that driver; only compile-tested, so
very likely needs further work to actually work

adresses also PR kern/43507
2018-06-09 18:53:16 +00:00
zafer cf3761a94c Add missing b_cflags and b_oflags.
Ok dholland@
Addresses PR kern/42342 by Yoshihiro Nakajima
2018-06-09 18:48:31 +00:00
jdolecek 7bc3817079 regen 2018-06-09 18:39:58 +00:00
jdolecek 459be5248c small sync of Marvell Yukon PCI product ids with OpenBSD - add 8048 variant, rename
YUKON_1 to YUKON_8070

also adjust description for YUKON_8055_2 to have "88E8055-2" just so that it shows
up differently
2018-06-09 18:39:32 +00:00
christos a3c16b5549 Provide more compatibility with readline headers; now python-3.6.5 works
when changing 'readline' -> 'edit' in setup.py.
Revert previous conditional setting of unbuffered.
2018-06-09 17:41:55 +00:00
macallan 84a5dd583d set options ADBKBD_EMUL_USB by default
With this ADB and USB keyboards can coexist on the same mux, as needed by
built-in Bluetooth modules on some *Books
should fix PR53351
2018-06-09 02:25:52 +00:00