]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r319897-r319898, r319904: Improve yes' throughput
kevans [Fri, 13 Apr 2018 03:32:18 +0000 (03:32 +0000)]
MFC r319897-r319898, r319904: Improve yes' throughput

r319897: Improve yes' throughput

On my system, this brings up the throughput from ~20 to ~600 MiB/s.

Inspired by:
  https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes_so_fast/

r319898: Handle partial writes

r319904: style(9) fixes.

6 years agoMFC r308432, r308657: Capsicumize some trivial stdio programs
kevans [Fri, 13 Apr 2018 03:30:10 +0000 (03:30 +0000)]
MFC r308432, r308657: Capsicumize some trivial stdio programs

r308432: Capsicumize some trivial stdio programs

Trivially capsicumize some simple programs that just interact with
stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.

r308657: fold(1): Revert incorrect r308432

As Jean-Sébastien notes, fold(1) requires handling argv-supplied files. That
will require a slightly more sophisticated approach.

6 years agoMFC r306758 (emaste): locate: ANSIfy
kevans [Fri, 13 Apr 2018 02:40:10 +0000 (02:40 +0000)]
MFC r306758 (emaste): locate: ANSIfy

6 years agoMFC r332145: Do not fail devices just for errors in descriptor format.
mav [Fri, 13 Apr 2018 00:29:42 +0000 (00:29 +0000)]
MFC r332145: Do not fail devices just for errors in descriptor format.

Sponsored by: iXsystems, Inc.

6 years agoMFC r331758: makefs: sync fragment and block size with newfs
emaste [Fri, 13 Apr 2018 00:25:53 +0000 (00:25 +0000)]
MFC r331758: makefs: sync fragment and block size with newfs

r222319 in newfs raised the default blocksize for UFS/FFS filesystems
from 16K to 32K and the default fragment size from 2K to 4K, with a
rationale that most disks were now running with 4K sectors.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

6 years agoWork around netmap issue with ixgbe
shurd [Thu, 12 Apr 2018 19:06:15 +0000 (19:06 +0000)]
Work around netmap issue with ixgbe

After multiple start/stop of netmap, ixgbe will get into a bad state
requiring a reboot to recover.  Adding a delay before stopping the interface
appears to work around the issue.

The -CURRENT driver has diverged too far from -STABLE for an MFC.

PR: 221317
Submitted by: Sylvain Galliano <sg@efficientip.com>
Reported by: Cassiano Peixoto <peixoto.cassiano@gmail.com>
Sponsored by: Limelight Networks

6 years agoMFC r332061:
kib [Thu, 12 Apr 2018 13:40:02 +0000 (13:40 +0000)]
MFC r332061:
Fix ERESTART for lcall $7,$0 syscalls.

6 years agoMFC r332060:
kib [Thu, 12 Apr 2018 13:39:01 +0000 (13:39 +0000)]
MFC r332060:
Make the INTO instruction operational in 32bit mode.

6 years agoMFC 328101,328911: Require SHF_ALLOC for kernel object module sections.
jhb [Wed, 11 Apr 2018 22:23:22 +0000 (22:23 +0000)]
MFC 328101,328911: Require SHF_ALLOC for kernel object module sections.

328101:
Require the SHF_ALLOC flag for program sections from kernel object modules.

ELF object files can contain program sections which are not supposed
to be loaded into memory (e.g. .comment).  Normally the static linker
uses these flags to decide which sections are allocated to loadable
program segments in ELF binaries and shared objects (including kernels
on all architectures and kernel modules on architectures other than
amd64).

Mapping ELF object files (such as amd64 kernel modules) into memory
directly is a bit of a grey area.  ELF object files are intended to be
used as inputs to the static linker.  As a result, there is not a
standardized definition for what the memory layout of an ELF object
should be (none of the section headers have valid virtual memory
addresses for example).

The kernel and loader were not checking the SHF_ALLOC flag but loading
any program sections with certain types such as SHT_PROGBITS.  As a
result, the kernel and loader would load into RAM some sections that
weren't marked with SHF_ALLOC such as .comment that are not loaded
into RAM for kernel modules on other architectures (which are
implemented as ELF shared objects).  Aside from possibly requiring
slightly more RAM to hold a kernel module this does not affect runtime
correctness as the kernel relocates symbols based on the layout it
uses.

Debuggers such as gdb and lldb do not extract symbol tables from a
running process or kernel.  Instead, they replicate the memory layout
of ELF executables and shared objects and use that to construct their
own symbol tables.  For executables and shared objects this works
fine.  For ELF objects the current logic in kgdb (and probably lldb
based on a simple reading) assumes that only sections with SHF_ALLOC
are memory resident when constructing a memory layout.  If the
debugger constructs a different memory layout than the kernel, then it
will compute different addresses for symbols causing symbols in the
debugger to appear to have the wrong values (though the kernel itself
is working fine).  The current port of mdb does not check SHF_ALLOC as
it replicates the kernel's logic in its existing kernel support.

The bfd linker sorts the sections in ELF object files such that all of
the allocated sections (sections with SHF_ALLOCATED) are placed first
followed by unallocated sections.  As a result, when kgdb composed a
memory layout using only the allocated sections, this layout happened
to match the layout used by the kernel and loader.  The lld linker
does not sort the sections in ELF object files and mixed allocated and
unallocated sections.  This resulted in kgdb composing a different
memory layout than the kernel and loader.

We could either patch kgdb (and possibly in the future lldb) to use
custom handling when generating memory layouts for kernel modules that
are ELF objects, or we could change the kernel and loader to check
SHF_ALLOCATED.  I chose the latter as I feel we shouldn't be loading
things into RAM that the module won't use.  This should mostly be a
NOP when linking with bfd but will allow the existing kgdb to work
with amd64 kernel modules linked with lld.

Note that we only require SHF_ALLOC for "program" sections for types
like SHT_PROGBITS and SHT_NOBITS.  Other section types such as symbol
tables, string tables, and relocations must also be loaded and are not
marked with SHF_ALLOC.

328911:
Ignore relocation tables for non-memory-resident sections.

As a followup to r328101, ignore relocation tables for ELF object
sections that are not memory resident.  For modules loaded by the
loader, ignore relocation tables whose associated section was not
loaded by the loader (sh_addr is zero).  For modules loaded at runtime
via kldload(2), ignore relocation tables whose associated section is
not marked with SHF_ALLOC.

6 years agoMFC r328988,r328989:
ae [Wed, 11 Apr 2018 10:36:20 +0000 (10:36 +0000)]
MFC r328988,r328989:
  Rework ipfw dynamic states implementation to be lockless on fast path.

  o added struct ipfw_dyn_info that keeps all needed for ipfw_chk and
    for dynamic states implementation information;
  o added DYN_LOOKUP_NEEDED() macro that can be used to determine the
    need of new lookup of dynamic states;
  o ipfw_dyn_rule now becomes obsolete. Currently it used to pass
    information from kernel to userland only.
  o IPv4 and IPv6 states now described by different structures
    dyn_ipv4_state and dyn_ipv6_state;
  o IPv6 scope zones support is added;
  o ipfw(4) now depends from Concurrency Kit;
  o states are linked with "entry" field using CK_SLIST. This allows
    lockless lookup and protected by mutex modifications.
  o the "expired" SLIST field is used for states expiring.
  o struct dyn_data is used to keep generic information for both IPv4
    and IPv6;
  o struct dyn_parent is used to keep O_LIMIT_PARENT information;
  o IPv4 and IPv6 states are stored in different hash tables;
  o O_LIMIT_PARENT states now are kept separately from O_LIMIT and
    O_KEEP_STATE states;
  o per-cpu dyn_hp pointers are used to implement hazard pointers and they
    prevent freeing states that are locklessly used by lookup threads;
  o mutexes to protect modification of lists in hash tables now kept in
    separate arrays. 65535 limit to maximum number of hash buckets now
    removed.
  o Separate lookup and install functions added for IPv4 and IPv6 states
    and for parent states.
  o By default now is used Jenkinks hash function.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D12685

6 years agoMFC r331668:
ae [Wed, 11 Apr 2018 10:24:47 +0000 (10:24 +0000)]
MFC r331668:
  Rework ipfw rules parsing and printing code.

  Introduce show_state structure to keep information about printed opcodes.
  Split show_static_rule() function into several smaller functions. Make
  parsing and printing opcodes into several passes. Each printed opcode
  is marked in show_state structure and will be skipped in next passes.
  Now show_static_rule() function is simple, it just prints each part
  of rule separately: action, modifiers, proto, src and dst addresses,
  options. The main goal of this change is avoiding occurrence of wrong
  result of `ifpw show` command, that can not be parsed by ipfw(8).
  Also now it is possible to make some simple static optimizations
  by reordering of opcodes in the rule.

  PR: 222705

6 years agoMFC r308490 by syrinx:
emaste [Tue, 10 Apr 2018 23:38:31 +0000 (23:38 +0000)]
MFC r308490 by syrinx:

Reply to a snmpEngineID discovery PDU with a Report PDU as per the
requirements of RFC 3414 section 4.

PR: 174974
Submitted by: pguyot@kallisys.net

6 years agoMFC r329388, r331441 and r331898, to bring the -CURRENT ck version.
cognet [Tue, 10 Apr 2018 20:22:36 +0000 (20:22 +0000)]
MFC r329388, r331441 and r331898, to bring the -CURRENT ck version.
r329388:
Define CK_MD_TSO for the relevant arches (i386, amd64 and sparc64).
Defaulting to CK_MD_RMO has the unfortunate side effect of generating
memory barriers that are useless on those arches, and the even more
unfortunate side effect of generating lfence/sfence/mfence on i386, even
if older CPUs don't support it.
This should fix the panic reported when using IPFW on a Pentium 3.
Note that mfence and sfence might still be used in a few case, but that
shouldn't happen in FreeBSD right now, and should be fixed upstream first.

r331441:
In __sync_bool_compare_and_swap(), return true if the returned value is the
same as the expected one, not the desired one.

r331898:
Import CK as of commit b19ed4c6a56ec93215ab567ba18ba61bf1cfbac8
It should fix ck_pr_[load|store]_ptr on mips and riscv, make sure no
*fence instructions are used on i386, as older cpus don't support it, and
make sure we don't rely on gcc builtins that can lead to calls to
libatomic when linked with -O0.

6 years agoMFC r318412: fix sparc64 build by restoring 'register' in pcpu.h
emaste [Tue, 10 Apr 2018 16:44:40 +0000 (16:44 +0000)]
MFC r318412: fix sparc64 build by restoring 'register' in pcpu.h

6 years agoMFC r328037: Rename 'recv' to 'receive' to appease shadow warnings from GCC.
kevans [Tue, 10 Apr 2018 15:38:16 +0000 (15:38 +0000)]
MFC r328037: Rename 'recv' to 'receive' to appease shadow warnings from GCC.

6 years agoMFC r319828, r324625
kevans [Tue, 10 Apr 2018 14:13:35 +0000 (14:13 +0000)]
MFC r319828, r324625

r319828:
rc.subr: Optimize repeated sourcing.

When /etc/rc runs all /etc/rc.d scripts, it has already loaded /etc/rc.subr
but each /etc/rc.d script sources it again (since /etc/rc.d scripts must
also work when started stand-alone).

Therefore, if rc.subr is already loaded, return so sh need not parse the
rest of the file.

A second effect is that there is no longer a compound command around most of
rc.subr. This reduces memory usage while sh is loading rc.subr for the first
time (but this memory is free()d once rc.subr is loaded).

For purposes of porting this to other systems, I do not recommend porting
this to systems with shells that do not have the change to the return
special builtin like in r255215 (before FreeBSD 10.0-RELEASE). This change
ensures that return in the top level of a dot script returns from the dot
script, even if the dot script was sourced from a function.

A comparison of CPU time on an amd64 bhyve virtual machine from a times
command added near the end of /etc/rc, all four values summed:

x orig1
+ quickreturn
+--------------------------------------------------------------------------+
|  +    +              +                             x    x               x|
||______M__A_________|                             |______M___A__________| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         1.704         1.802         1.726         1.744   0.051419841
+   3         1.467         1.559         1.487     1.5043333   0.048387326
Difference at 95.0% confidence
-0.239667 +/- 0.113163
-13.7424% +/- 6.48873%
(Student's t, pooled s = 0.0499266)

r324625:
rc.subr: Remove test that is always true.

The code above always sets _pidcmd to a non-empty value.

6 years agoDocument EN-18:03, EN-18:04, SA-18:04, SA-18:05.
gjb [Tue, 10 Apr 2018 14:07:29 +0000 (14:07 +0000)]
Document EN-18:03, EN-18:04, SA-18:04, SA-18:05.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r309350, r309352
kevans [Tue, 10 Apr 2018 14:04:11 +0000 (14:04 +0000)]
MFC r309350, r309352

r309350:
If the kenv variable rc_debug is set, turn on rc_debug.

r309352:
Finish incomplete comments in prior revision. I was going to fix this
after I tested it, but didn't.

6 years agoMFC r308896
kevans [Tue, 10 Apr 2018 14:00:45 +0000 (14:00 +0000)]
MFC r308896

r308896: rc.subr: $(ps -p $$ -o jid=) is always 0, so do not fork ps for it.

The JID keyword writes 0 for a process also in the host system or in the
same jail.

6 years agoRevert r331880, MFC of r328331 and bump FreeBSD_version
kevans [Tue, 10 Apr 2018 13:35:07 +0000 (13:35 +0000)]
Revert r331880, MFC of r328331 and bump FreeBSD_version

There are logistics issues that weren't considered when this was originally
MFC'd. All rc scripts in ports need audited (this is in progress) for usage
of ${name}_limits that doesn't line up with the new interpretation, and
individual rc.conf(5)'s need to be scrubbed of usage that doesn't line up.

It's since been decided that it should be left for a feature in 12.

1101514 introduced interpretation of ${name}_limits for rc scripts; this
feature no longer exists as of 1101515.

6 years agoMFC r331180: Plug a possible memory leak.
delphij [Tue, 10 Apr 2018 03:12:22 +0000 (03:12 +0000)]
MFC r331180: Plug a possible memory leak.

6 years agodmagent: add -D_WITH_GETLINE to fix stable/11 build
emaste [Mon, 9 Apr 2018 21:16:28 +0000 (21:16 +0000)]
dmagent: add -D_WITH_GETLINE to fix stable/11 build

The need for _WITH_GETLINE and _WITH_DPRINTF was removed in HEAD in
r303524 but is still needed in stable/11 to enable prototypes for these
functions.

6 years agoMFC r326641 by bapt: Split body of mails not respecting RFC2822
emaste [Mon, 9 Apr 2018 20:00:07 +0000 (20:00 +0000)]
MFC r326641 by bapt: Split body of mails not respecting RFC2822

For mails which has a body not respecting RFC2822 (which often happen with
crontabs) try to split by words finding the last space before 1000's
character

If no spaces are found then consider the mail to be malformed anyway

PR: 208261

6 years agoFix wl(4) after r332288.
brooks [Mon, 9 Apr 2018 16:18:02 +0000 (16:18 +0000)]
Fix wl(4) after r332288.

I missed that this was an assignment (a bad pattern, use another
member) on i386.  As wl(4) is i386 only and gone in head, just
expand the ifr_ifru member rather than adding an accessor.

Reported by: gjb

6 years agoMFC r332151:
brooks [Mon, 9 Apr 2018 15:21:40 +0000 (15:21 +0000)]
MFC r332151:

ifconf(): correct handling of sockaddrs smaller than struct sockaddr.

Portable programs that use SIOCGIFCONF (e.g. traceroute) assume
that each pseudo ifreq is of length MAX(sizeof(struct ifreq),
sizeof(ifr_name) + ifr_addr.sa_len).  For short sockaddrs we copied
too much from the source sockaddr resulting in a heap leak.

I believe only one such sockaddr exists (struct sockaddr_sco which
is 8 bytes) and it is unclear if such sockaddrs end up on interfaces
in practice.  If it did, the result would be an 8 byte heap leak on
current architectures.

admbugs: 869
Reviewed by: kib
Obtained from: CheriBSD
Security: kernel heap leak
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14981

6 years agoMFC r331225:
kp [Mon, 9 Apr 2018 15:11:17 +0000 (15:11 +0000)]
MFC r331225:

pf: Fix memory leak in DIOCRADDTABLES

If a user attempts to add two tables with the same name the duplicate table
will not be added, but we forgot to free the duplicate table, leaking memory.
Ensure we free the duplicate table in the error path.

Reported by: Coverity
CID: 1382111

6 years agoMFC r327559:
smh [Mon, 9 Apr 2018 08:25:29 +0000 (08:25 +0000)]
MFC r327559:

Disabled the use of flowid for lagg by default

Sponsored by: Multiplay

6 years agoMFC r328434 by maxim:
gonzo [Mon, 9 Apr 2018 05:43:30 +0000 (05:43 +0000)]
MFC r328434 by maxim:

o A command line flag for the syslog_facility fixed in the SYNOPSIS.

PR: 225441

6 years agoMFC r331439: Sort headers in MD Linuxulator files
emaste [Mon, 9 Apr 2018 01:07:47 +0000 (01:07 +0000)]
MFC r331439: Sort headers in MD Linuxulator files

Bring #includes closer to style(9) and reduce differences between the
(three) MD versions of linux_machdep.c and linux_sysvec.c.

6 years agoMFC r331053: ANSIfy i386/vm86.c
emaste [Mon, 9 Apr 2018 01:06:09 +0000 (01:06 +0000)]
MFC r331053: ANSIfy i386/vm86.c

6 years agoMFC r332146: Re-sort LOADER options
kevans [Mon, 9 Apr 2018 01:02:32 +0000 (01:02 +0000)]
MFC r332146: Re-sort LOADER options

6 years agoMFC r331969, r332035:
pfg [Sun, 8 Apr 2018 21:56:35 +0000 (21:56 +0000)]
MFC r331969, r332035:
pthread.h: drop nullability attributes.

These have been found to be practically useless. We were actually
following the Android bionic library and had some interest in replicating
the same warnings and behaviour but Android has since removed them.

We are still keeping some uses of nullability attributes in other headers,
somewhat in line with Apple's libc.

Hinted by: bionic (git 3f66e74b903905e763e104396aff52a81718cfde)

6 years agoRegen src.conf.5 after r332306 (WITH_KERNEL_RETPOLINE MFC)
emaste [Sun, 8 Apr 2018 20:58:13 +0000 (20:58 +0000)]
Regen src.conf.5 after r332306 (WITH_KERNEL_RETPOLINE MFC)

6 years agoMFC r330110: Add kernel retpoline option for amd64
emaste [Sun, 8 Apr 2018 20:54:13 +0000 (20:54 +0000)]
MFC r330110: Add kernel retpoline option for amd64

Retpoline is a compiler-based mitigation for CVE-2017-5715, also known
as Spectre V2, that protects against speculative execution branch target
injection attacks.

In this commit it is disabled by default, but will be changed in a
followup commit.

MFC r330962: Remove KERNEL_RETPOLINE from BROKEN_OPTIONS on i386

Clang will compile both amd64 and i386 with retpoline.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r331082: ANSIfy sys/x86
emaste [Sun, 8 Apr 2018 20:52:09 +0000 (20:52 +0000)]
MFC r331082: ANSIfy sys/x86

6 years agoMFC ath(4) potential memory disclosure fixes
emaste [Sun, 8 Apr 2018 20:50:16 +0000 (20:50 +0000)]
MFC ath(4) potential memory disclosure fixes

[1] r327499: ath: fix memory disclosure from ath_btcoex_ioctl

The ath_btcoex_ioctl handler allocated a buffer without M_ZERO and
returned it to userland without writing to it.

The device has permissions only for root so this is not urgent, and the
fix can be MFCd and considered for a future EN.

[2] r327500: ath: fix possible memory disclosures in ioctl handlers

Apply the fix from r327499 to additional ioctl handlers.

[3] r327529: ath: fix possible memory disclosure in ioctl handler

Submitted by: Domagoj Stolfa <domagoj.stolfa@gmail.com> [1,3]
Reported by: Ilja van Sprundel <ivansprundel@ioactive.com> [1,2]
Reviewed by: adrian [1]
Sponsored by: The FreeBSD Foundation

6 years agoMFC r331935: vtfontcvt: allow .bdf characters less than full height
emaste [Sun, 8 Apr 2018 20:30:52 +0000 (20:30 +0000)]
MFC r331935: vtfontcvt: allow .bdf characters less than full height

Sponsored by: The FreeBSD Foundation

6 years agoMFC r328972: add retpoline compiler and linker feature flags
emaste [Sun, 8 Apr 2018 20:28:37 +0000 (20:28 +0000)]
MFC r328972: add retpoline compiler and linker feature flags

These features indicate that the compiler and linker support the
retpoline speculative execution vulnerability (CVE-2017-5715)
mitigation.

6 years agoMFC r320243 (bdrewery): Fix spelling error.
emaste [Sun, 8 Apr 2018 20:26:50 +0000 (20:26 +0000)]
MFC r320243 (bdrewery): Fix spelling error.

6 years agoMFC r332087:
brooks [Sun, 8 Apr 2018 17:18:51 +0000 (17:18 +0000)]
MFC r332087:

ifconf(): Always zero the whole struct ifreq.

The previous split of zeroing ifr_name and ifr_addr seperately is safe
on current architectures, but would be unsafe if pointers were larger
than 8 bytes. Combining the zeroing adds no real cost (a few
instructions) and makes the security property easier to verify.

Reviewed by: kib, emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14912

6 years agoGC never enabled support for SIOCGADDRROM and SIOCGCHIPID.
brooks [Sun, 8 Apr 2018 16:59:39 +0000 (16:59 +0000)]
GC never enabled support for SIOCGADDRROM and SIOCGCHIPID.

When de(4) was imported in 1997 the world was not ready for these ioctls.
In over 20 years that hasn't changed so it seems safe to assume their
time will never come.

Reviewed by: imp, jhb
Approved by: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14889

6 years agoMFC r331797:
brooks [Sun, 8 Apr 2018 16:54:07 +0000 (16:54 +0000)]
MFC r331797:

Use an accessor function to access ifr_data.

This fixes 32-bit compat (no ioctl command defintions are required
as struct ifreq is the same size).

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14900

6 years agoMFC r331641, r331644, r332158
brooks [Sun, 8 Apr 2018 15:52:32 +0000 (15:52 +0000)]
MFC r331641, r331644, r332158

r331641:
Fix access to ifru_buffer on freebsd32.

Make all kernel accesses to ifru_buffer go via access functions
which take the process ABI into account and use an appropriate union
to access members in the correct place in struct ifreq.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14846

r331644:
Fix a whitespace bug missed in refactoring prior to r331641.

MFC with: r331641

r332158:
Remove the thread argument from ifr_buffer_*() accessors.

They are always used in a context where curthread is the correct thread.
This makes them more similar to the ifr_data_get_ptr() accessor.

6 years agoMFC r331654, r331869
brooks [Sun, 8 Apr 2018 15:30:58 +0000 (15:30 +0000)]
MFC r331654, r331869

r331654:
Don't access userspace directly from the kernel in nxge(4).

Update to what the previous code seemed to be doing via the correct
interfaces.  Further issues exist in xge_ioctl_registers(), but this is
debugging code in a driver that has few users and they don't appear to
be crashes or leaks.

Reviewed by: jhb (prior version)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14848

r331869:
Fix the build on arches with default unsigned char.  Capture the fubyte()
return value in an int as well as the char, and test the full int value
for fubyte() failure.

6 years agoMFC r327203:
tuexen [Sun, 8 Apr 2018 14:09:27 +0000 (14:09 +0000)]
MFC r327203:

Allow the first (and second) argument of sn_calloc() be a sum.
This fixes a bug reported in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224103

PR: 224103

6 years agoMFC r327214:
tuexen [Sat, 7 Apr 2018 21:25:29 +0000 (21:25 +0000)]
MFC r327214:

Whitespace changes.

6 years agoMFC r327209:
tuexen [Sat, 7 Apr 2018 21:24:17 +0000 (21:24 +0000)]
MFC r327209:

Clarify that there is no break missing. While there, cleanup whitespaces.

6 years agoClarify that the break is not missing.
tuexen [Sat, 7 Apr 2018 21:22:29 +0000 (21:22 +0000)]
Clarify that the break is not missing.

CID: 1008198

6 years agoMFC r327205:
tuexen [Sat, 7 Apr 2018 21:12:16 +0000 (21:12 +0000)]
MFC r327205:

Fix an assignment. While there, do some whitespace cleanups.

CID: 1008936

6 years agoMFC r328081:
tuexen [Sat, 7 Apr 2018 21:09:51 +0000 (21:09 +0000)]
MFC r328081:

Add missing assignment to make sure non-first cmsgs are handled as such.

6 years agoMFC r328059:
tuexen [Sat, 7 Apr 2018 21:08:44 +0000 (21:08 +0000)]
MFC r328059:

Improve the printing of cmgs when the length is 0. Fix error handling.

6 years agoMFC r328058:
tuexen [Sat, 7 Apr 2018 21:07:47 +0000 (21:07 +0000)]
MFC r328058:

Using %p already prints "0x", so don't do it explicitly.

6 years agoMFC r328033:
tuexen [Sat, 7 Apr 2018 21:06:39 +0000 (21:06 +0000)]
MFC r328033:

Bump date, which I missed in r328014. Thanks to jhb@ for reporting.

6 years agoMFC r328015:
tuexen [Sat, 7 Apr 2018 21:05:39 +0000 (21:05 +0000)]
MFC r328015:

Decode msghdr argument of sendmsg() and recvmsg().

6 years agoMFC r328014:
tuexen [Sat, 7 Apr 2018 21:04:43 +0000 (21:04 +0000)]
MFC r328014:

Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.

6 years agoMFC r327995:
tuexen [Sat, 7 Apr 2018 21:03:46 +0000 (21:03 +0000)]
MFC r327995:

Add support for decoding the type of a cmsg.

6 years agoMFC r327994:
tuexen [Sat, 7 Apr 2018 21:02:42 +0000 (21:02 +0000)]
MFC r327994:

Simplify table generation.

6 years agoMFC r327967:
tuexen [Sat, 7 Apr 2018 21:01:43 +0000 (21:01 +0000)]
MFC r327967:

Improve support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
and add support for sctp_generic_sendmsg_iov().

Handle the struct iovec argument and the struct sctp_sndrcvinfo
arguments.

6 years agoMFC r327966:
tuexen [Sat, 7 Apr 2018 21:00:21 +0000 (21:00 +0000)]
MFC r327966:

Add a function is decode the sinfo_flags of struct sctp_sndrcvinfo.

6 years agoMFC r327962:
tuexen [Sat, 7 Apr 2018 20:57:27 +0000 (20:57 +0000)]
MFC r327962:

Add support for the supported PR-SCTP policies.

6 years agoMFC r327961:
tuexen [Sat, 7 Apr 2018 20:56:07 +0000 (20:56 +0000)]
MFC r327961:

Mark the iovec parameters of writev() and readv() as IN and OUT.
This makes truss work on readv() as expected.

6 years agoMFC r327921:
tuexen [Sat, 7 Apr 2018 20:54:37 +0000 (20:54 +0000)]
MFC r327921:

Fix a typo introduced in r327919.

6 years agoMFC r327919:
tuexen [Sat, 7 Apr 2018 20:52:05 +0000 (20:52 +0000)]
MFC r327919:

Add support for readv() and writev() to truss.

Sponsored by:i Netflix, Inc.

6 years agoMFC r331061:
tuexen [Sat, 7 Apr 2018 20:47:25 +0000 (20:47 +0000)]
MFC r331061:

Set the inp_vflag consistently for accepted TCP/IPv6 connections when
net.inet6.ip6.v6only=0.

Without this patch, the inp_vflag would have INP_IPV4 and the
INP_IPV6 flags for accepted TCP/IPv6 connections if the sysctl
variable net.inet6.ip6.v6only is 0. This resulted in netstat
to report the source and destination addresses as IPv4 addresses,
even they are IPv6 addresses.

PR: 226421
Reviewed by: bz, hiren, kib
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D13514

6 years agoMFC r328488:
tuexen [Sat, 7 Apr 2018 20:44:30 +0000 (20:44 +0000)]
MFC r328488:

When using SCTP for sending probe packets, use INIT chunks for payloads
larger than or equal to 32 bytes. For smaller probe packets, keep using
SHUTDOWN-ACK chunks, possibly bundled with a PAD chunk.
Packets with INIT chunks more likely pass through firewalls. Therefore,
use them when possible.

6 years agoMFC r328478:
tuexen [Sat, 7 Apr 2018 20:42:06 +0000 (20:42 +0000)]
MFC r328478:

Add constant for the PAD chunk as defined in RFC 4820.
This will be used by traceroute and traceroute6 soon.

6 years agoMFC r328477:
tuexen [Sat, 7 Apr 2018 20:40:40 +0000 (20:40 +0000)]
MFC r328477:

Update references in comments, since the IDs have become an RFC long
time ago. Also cleanup whitespaces. No functional change.

6 years agoMFC r328066:
tuexen [Sat, 7 Apr 2018 20:39:09 +0000 (20:39 +0000)]
MFC r328066:

Fix a bug related to fast retransmissions.

When processing a SACK advancing the cumtsn-ack in fast recovery,
increment the miss-indications for all TSN's reported as missing.

Thanks to Fabian Ising for finding the bug and to Timo Voelker
for provinding a fix.

This fix moves also CMT related initialisation of some variables
to a more appropriate place.

6 years agoMFC r328028:
tuexen [Sat, 7 Apr 2018 20:37:44 +0000 (20:37 +0000)]
MFC r328028:

Don't provide a (meaningless) cmsg when proving a notification
in a recvmsg() call.

6 years agoMFC r327844:
tuexen [Sat, 7 Apr 2018 20:34:03 +0000 (20:34 +0000)]
MFC r327844:

Ensure that the vnet is set when calling pru_sockaddr() and
pru_peeraddr().

This is already true when called via kern_getsockname() and
kern_getpeername(). This patch sets it also, when they arecalled
via soo_fill_kinfo(). This is necessary, since the corresponding
functions for SCTP require the vnet to be set. Without this,
if a process having an wildcard bound SCTP socket is
terminated and a core is written, the kernel panics.

6 years agoMFC r326233:
tuexen [Sat, 7 Apr 2018 20:27:11 +0000 (20:27 +0000)]
MFC r326233:

Add to ipfw support for sending an SCTP packet containing an ABORT chunk.
This is similar to the TCP case. where a TCP RST segment can be sent.

There is one limitation: When sending an ABORT in response to an incoming
packet, it should be tested if there is no ABORT chunk in the received
packet. Currently, it is only checked if the first chunk is an ABORT
chunk to avoid parsing the whole packet, which could result in a DOS attack.

Thanks to Timo Voelker for helping me to test this patch.

MFC r327200:

When adding support for sending SCTP packets containing an ABORT chunk
to ipfw in https://svnweb.freebsd.org/changeset/base/326233,
a dependency on the SCTP stack was added to ipfw by accident.

This was noted by Kevel Bowling in https://reviews.freebsd.org/D13594
where also a solution was suggested. This patch is based on Kevin's
suggestion, but implements the required SCTP checksum computation
without any dependency on other SCTP sources.

While there, do some cleanups and improve comments.

Thanks to Kevin Kevin Bowling for reporting the issue and suggesting
a fix.

6 years agoMFC r326829:
tuexen [Sat, 7 Apr 2018 20:23:34 +0000 (20:23 +0000)]
MFC r326829:

Cleaup, no functional change.

6 years agoMFC r326672:
tuexen [Sat, 7 Apr 2018 20:22:04 +0000 (20:22 +0000)]
MFC r326672:

Retire SCTP_WITH_NO_CSUM option.

This option was used in the early days to allow performance measurements
extrapolating the use of SCTP checksum offloading. Since this feature
is now available, get rid of this option.
This also un-breaks the LINT kernel. Thanks to markj@ for making me
aware of the problem.

6 years agoMFC r325864:
tuexen [Sat, 7 Apr 2018 20:15:12 +0000 (20:15 +0000)]
MFC r325864:

Fix the handling of ERROR chunks which a lot of error causes.
While there, clean up the code.
Thanks to Felix Weinrank who found the bug by using fuzz-testing
the SCTP userland stack.

6 years agoMFC r325788:
tuexen [Sat, 7 Apr 2018 20:13:29 +0000 (20:13 +0000)]
MFC r325788:

Simply the code and use the full buffer for contigous chunk representation.

6 years agoMFC r325746:
tuexen [Sat, 7 Apr 2018 20:11:56 +0000 (20:11 +0000)]
MFC r325746:

Cleanup the handling of control chunks. While there fix some minor
bug related to clearing the assoc retransmit counter and the dup TSN
handling of NR-SACK chunks.

6 years agoMFC r325434:
tuexen [Sat, 7 Apr 2018 20:10:26 +0000 (20:10 +0000)]
MFC r325434:

Fix an accounting bug where data was counted twice if on the read
queue and on the ordered or unordered queue.
While there, improve the checking in INVARIANTs when computing the
a_rwnd.

6 years agoMFC r325370:
tuexen [Sat, 7 Apr 2018 20:08:17 +0000 (20:08 +0000)]
MFC r325370:

Allow the setting of the MTU for future paths using an SCTP socket option.
This functionality was missing.

6 years agoMFC r325284:
tuexen [Sat, 7 Apr 2018 20:06:50 +0000 (20:06 +0000)]
MFC r325284:

Fix the reporting of the MTU for SCTP sockets when using IPv6.

6 years agoMFC r325046:
tuexen [Sat, 7 Apr 2018 20:05:25 +0000 (20:05 +0000)]
MFC r325046:

Fix parsing error when processing cmsg in SCTP send calls. The bug is
related to a signed/unsigned mismatch.
This should most likely fix the issue in sctp_sosend reported by
Dmitry Vyukov on the freebsd-hackers mailing list and found by
running syzkaller.

6 years agoMFC r324971:
tuexen [Sat, 7 Apr 2018 20:03:35 +0000 (20:03 +0000)]
MFC r324971:

Fix a bug reported by Felix Weinrank using the libfuzzer on the
userland stack.

6 years agoMFC r324958:
tuexen [Sat, 7 Apr 2018 20:02:08 +0000 (20:02 +0000)]
MFC r324958:

Fix a bug in handling special ABORT chunks.
Thanks to Felix Weinrank for finding this issue using libfuzzer with
the userland stack.

6 years agoMFC r324954:
tuexen [Sat, 7 Apr 2018 20:00:58 +0000 (20:00 +0000)]
MFC r324954:

Fix a locking issue found by running AFL on the userland stack.
Thanks to Felix Weinrank for reporting the issue.

6 years agoMFC r324730:
tuexen [Sat, 7 Apr 2018 19:59:40 +0000 (19:59 +0000)]
MFC r324730:

Fix a signed/unsigned warning.

6 years agoMFC r324729:
tuexen [Sat, 7 Apr 2018 19:58:14 +0000 (19:58 +0000)]
MFC r324729:

Abort an SCTP association, when a DATA chunk is followed by an unknown
chunk with a length smaller than the minimum length.

Thanks to Felix Weinrank for making me aware of the problem.

6 years agoMFC r324638:
tuexen [Sat, 7 Apr 2018 19:56:34 +0000 (19:56 +0000)]
MFC r324638:

Fix the handling of parital and too short chunks.

Ensure that the current behaviour is consistent: stop processing
of the chunk, but finish the processing of the previous chunks.

This behaviour might be changed in a later commit to ABORT the
assoication due to a protocol violation, but changing this
is a separate issue.

MFC r324725

Fix a bug introduced in r324638.
Thanks to Felix Weinrank for making me aware of this.

MFC r324726:

Revert change which got in accidently.

6 years agoMFC r324615:
tuexen [Sat, 7 Apr 2018 19:44:41 +0000 (19:44 +0000)]
MFC r324615:

Code cleanup, not functional change.

This avoids taking a pointer of a packed structure which allows simpler
compilation of the userland stack.

6 years agoMFC r324317:
tuexen [Sat, 7 Apr 2018 19:42:53 +0000 (19:42 +0000)]
MFC r324317:

Ensure that the accept ABORT chunks with the T-bit set only the
a non-zero matching peer tag is provided.

6 years agoMFC r324218:
tuexen [Sat, 7 Apr 2018 19:40:48 +0000 (19:40 +0000)]
MFC r324218:

Whitespace changes: Remove leading spaces followed by a tab.

6 years agoMFC r324216:
tuexen [Sat, 7 Apr 2018 19:38:55 +0000 (19:38 +0000)]
MFC r324216:

Fix a bug which avoided that rules for matching port numbers for SCTP
packets where actually matched.
While there, make clean in the man-page that SCTP port numbers are
supported in rules.

6 years agoMFC r324122:
tuexen [Sat, 7 Apr 2018 19:23:51 +0000 (19:23 +0000)]
MFC r324122:

Fix reporting of probing size. This bug was introduced in r324119.

6 years agoMFC r324120:
tuexen [Sat, 7 Apr 2018 19:22:32 +0000 (19:22 +0000)]
MFC r324120:

Add SCTP and TCP as protocols for sending probe packets.

6 years agoMFC r324119:
tuexen [Sat, 7 Apr 2018 19:21:15 +0000 (19:21 +0000)]
MFC r324119:

* Update function definitions.
* Ensure that the datalen always describes the length after the IPv6
  header consistently, not matter which protocol us used for probes..
* Document that the default length is 20, not 12.
* Don't send inormation in probe packets which is not needed or
  even checked when the responses are processed.
* Address CID 978587.

This is mainly a cleanup preparing the addition of SCTP and TCP
as possible probe packet protocols.

6 years agoMFC r324056:
tuexen [Sat, 7 Apr 2018 19:19:25 +0000 (19:19 +0000)]
MFC r324056:

Remove unused function.

6 years agoMFC r323904:
tuexen [Sat, 7 Apr 2018 19:17:31 +0000 (19:17 +0000)]
MFC r323904:

Add missing locking. Found by Coverity while scanning the usrsctp
library.

6 years agoMFC r323902:
tuexen [Sat, 7 Apr 2018 19:16:06 +0000 (19:16 +0000)]
MFC r323902:

Add missing socket lock.

6 years agoMFC r323861:
tuexen [Sat, 7 Apr 2018 19:14:31 +0000 (19:14 +0000)]
MFC r323861:

Code cleanup, no functional change.

6 years agoMFC r323850:
tuexen [Sat, 7 Apr 2018 19:13:05 +0000 (19:13 +0000)]
MFC r323850:

Free the control structure after using is, not before.
Found by Coverity while scanning the usrsctp library.

6 years agoMFC r323847:
tuexen [Sat, 7 Apr 2018 19:11:21 +0000 (19:11 +0000)]
MFC r323847:

No need to wakeup, since sctp_add_to_readq() does it.

6 years agoMFC r323833:
tuexen [Sat, 7 Apr 2018 19:09:51 +0000 (19:09 +0000)]
MFC r323833:

Protect the address workqueue timer by a mutex.