Commit Graph

275766 Commits

Author SHA1 Message Date
Rick Macklem
7cab630ba4 mount_nfs: Only create a mounttab file entry is nmount(2) succeeds
mount_nfs creates entries in the mounttab file and umount removes
them.  Entries in the mounttab file ae used by rpc.umntall to
notify the NFS server that NFSv3 entries need to be removed when
they have not been removed by umount.

Without this patch, an enty will be created in the mounttab file,
even if the nmount(2) syscall fails for the mount.  This patch
modifies the code so that the mounttab entry is only created
after nmount(2) succeeds.

This change only affects NFSv3 and only affects how showmount
displays NFSv3 mounts.

MFC after:	2 weeks
2022-05-28 15:48:40 -07:00
Dimitry Andric
6a5eebc190 Apply clang fix for assertion failure building putty 0.77 on i386
Merge commit 45084eab5e63 from llvm git (by Arthur Eubanks):

  [clang] Fix some clang->llvm type cache invalidation issues

  Take the following as an example

    struct z {
      z (*p)();
    };

    z f();

  When we attempt to get the LLVM type of f, we recurse into z. z itself
  has a function pointer with the same type as f. Given the recursion,
  Clang simply treats z::p as a pointer to an empty struct `{}*`. The
  LLVM type of f is as expected. So we have two different potential
  LLVM types for a given Clang type. If we store one of those into the
  cache, when we access the cache with a different context (e.g. we
  are/aren't recursing on z) we may get an incorrect result. There is some
  attempt to clear the cache in these cases, but it doesn't seem to handle
  all cases.

  This change makes it so we only use the cache when we are not in any
  sort of function context, i.e. `noRecordsBeingLaidOut() &&
  FunctionsBeingProcessed.empty()`, which are the cases where we may
  decide to choose a different LLVM type for a given Clang type. LLVM
  types for builtin types are never recursive so they're always ok.

  This allows us to clear the type cache less often (as seen with the
  removal of one of the calls to `TypeCache.clear()`). We
  still need to clear it when we use a placeholder type then replace it
  later with the final type and other dependent types need to be
  recalculated.

  I've added a check that the cached type matches what we compute. It
  triggered in this test case without the fix. It's currently not
  check-clang clean so it's not on by default for something like expensive
  checks builds.

  This change uncovered another issue where the LLVM types for an argument
  and its local temporary don't match. For example in type-cache-3, when
  expanding z::dc's argument into a temporary alloca, we ConvertType() the
  type of z::p which is `void ({}*)*`, which doesn't match the alloca GEP
  type of `{}*`.

  No noticeable compile time changes:
  https://llvm-compile-time-tracker.com/compare.php?from=3918dd6b8acf8c5886b9921138312d1c638b2937&to=50bdec9836ed40e38ece0657f3058e730adffc4c&stat=instructions

  Fixes #53465.

  Reviewed By: rnk

  Differential Revision: https://reviews.llvm.org/D118744

PR:		264318
Reported by:	mandree
MFC after:	3 days
2022-05-28 23:26:37 +02:00
Dmitry Chagin
3735f9cff1 linux(4): Handle multiple mbufs in a control message chain in recvmsg
PR:		230274
MFC after:	2 weeks
2022-05-28 23:48:45 +03:00
Dmitry Chagin
31d7f3e9ce linux(4): Ratelimit message about unupported cmsg
MFC after:		2 weeks
2022-05-28 23:48:16 +03:00
Dmitry Chagin
f8a6615064 linux(4): Handle IP_ORIGDSTADDR socket option for IPPROTO_IP protocol level
MFC after:		2 weeks
2022-05-28 23:47:40 +03:00
Dmitry Chagin
4f02a4f48c linux(4): Add LINUX_RATELIMIT_MSG_OPT2 for future use
MFC after:		2 weeks
2022-05-28 23:47:23 +03:00
Dmitry Chagin
53494b918d linux(4): Overwrite SO_TIMESTAMP counterpart
A socket cannot mix SO_TIMESTAMP and SO_TIMESTAMPNS: the two modes
are mutually exclusive.

MFC after:		2 weeks
2022-05-28 23:46:38 +03:00
Dmitry Chagin
0eda2ceab7 linux(4): Refactor linux_common_recvmsg()
To improve readability lower nesting level, better naming for variables.
No functional changes.

MFC after:		2 weeks
2022-05-28 23:46:22 +03:00
Dmitry Chagin
71bc8bcf66 linux(4): Handle SO_TIMESTAMPNS socket option
The SO_TIMESTAMPNS enables or disables the receiving of the SCM_TIMESTAMPNS
control message. The cmsg_data field is a struct timespec.
To distinguish between SO_TIMESTAMP and SO_TIMESTAMPNS in the recvmsg()
map the last one to the SO_BINTIME and convert bintime to the timespec.
In the rest, implementation is identical to the SO_TIMESTAMP.

MFC after:		2 weeks
2022-05-28 23:46:05 +03:00
Dmitry Chagin
0e26e54bdf linux(4): Handle 64-bit SO_TIMESTAMP for 32-bit binaries
To solve y2k38 problem in the recvmsg syscall the new SO_TIMESTAMP
constant were added on v5.1 Linux kernel. So, old 32-bit binaries
that knows only 32-bit time_t uses the old value of the constant,
and binaries that knows 64-bit time_t uses the new constant.

To determine what size of time_t type is expected by the user-space,
store requested value (SO_TIMESTAMP) in the process emuldata structure.

MFC after:		2 weeks
2022-05-28 23:45:39 +03:00
Dmitry Chagin
6335583990 linux(4): For future use replace malloc type for l_sockaddr by M_LINUX
MFC after:		2 weeks
2022-05-28 23:44:48 +03:00
Dmitry Chagin
b408788d6b linux(4): Improve recvmsg() readability
To improve recvmsg() readability SCM_ handlers moved to a separate
functions.

MFC after:		2 weeks
2022-05-28 23:44:02 +03:00
Dmitry Chagin
f409a7c538 linux(4): For future use move SCM definitions below socket options
MFC after:		2 weeks
2022-05-28 23:42:23 +03:00
Dmitry Chagin
db48fa8319 linux(4): Avoid EISCONN if addr is specified for sendto()
If the socket is in a connected state, the target address should be
ignored.

MFC after:		2 weeks
2022-05-28 23:42:09 +03:00
Dmitry Chagin
e8d9d8082b linux(4): Fix SO_LINGER l_onoff value
On Linux l_onoff should be 1 when linger is used.

MFC after:		2 weeks
2022-05-28 23:31:06 +03:00
Dmitry Chagin
e92b9a9eaa linux(4): Add a helper to copyout getsockopt value
For getsockopt(), optlen is a value-result argument, which is modified
on return to indicate the actual size of the value returned.
For some cases this was missed, fixed.

MFC after:		2 weeks
2022-05-28 23:30:22 +03:00
Dmitry Chagin
3a99aac66f linux(4): Check the socket before any others sanity checks
Strictly speaking, this check is performed by the kern_recvit(), but in
the Linux emulation layer before calling the kernel we do other sanity
checks and conversions from Linux types to the native types. This changes
an order of the error returning that is critical for some buggy Linux
applications.

For recvmmsg() syscall this fixes a panic in case when the user-supplied
vlen value is 0, then error is not initialized and garbage passed to the
bsd_to_linux_errno().

MFC after:		2 weeks
2022-05-28 23:29:12 +03:00
Alan Somers
77d678b7a4 Fix a memory leak from caf73e5857
Don't shadow an already-local variable with another local declaration.

Reported by:	dteske
MFC after:	13 days
MFC with:	caf73e5857
Sponsored by:	Axcient
Differential Revision:	https://reviews.freebsd.org/D35331
2022-05-28 13:17:37 -06:00
Dmitry Chagin
d46174cd88 Finish cpuset_getaffinity() after f35093f8
Split cpuset_getaffinity() into a two counterparts, where the
user_cpuset_getaffinity() is intended to operate on the cpuset_t from
user va, while kern_cpuset_getaffinity() expects the cpuset from kernel
va.
Accordingly, the code that clears the high bits is moved to the
user_cpuset_getaffinity(). Linux sched_getaffinity() syscall returns
the size of set copied to the user-space and then glibc wrapper clears
the high bits.

MFC after:		2 weeks
2022-05-28 20:53:08 +03:00
Dmitry Chagin
31d1b816fe sysent: Get rid of bogus sys/sysent.h include.
Where appropriate hide sysent.h under proper condition.

MFC after:	2 weeks
2022-05-28 20:52:17 +03:00
Michael Tuexen
2646cd0858 sctp: use a consistent view of the send parameters
Reported by:	syzbot+e26628a755f78bacff16@syzkaller.appspotmail.com
MFC after:	3 days
2022-05-28 19:35:58 +02:00
Michael Tuexen
e2ceff3028 sctp: ignore SCTP_SENDALL flag on 1-to-1 style sockets
MFC after:	3 days
2022-05-28 19:07:10 +02:00
Michael Tuexen
64b297e803 sctp: improve handling of send() when association is shutdown
Accept send() calls only when the association is not being
shut down or the expicit message EOR mode is used and the
application provides follow-up data.

Reported by:	syzbot+341e9ebd9d24ca7dc62a@syzkaller.appspotmail.com
MFC after:	3 days
2022-05-28 17:40:17 +02:00
Michael Tuexen
f21168e614 sctp: cleanup of error paths
MFC after:	3 days
2022-05-28 17:15:14 +02:00
Dimitry Andric
7b6f5ebef6 Add several sanitizer ignore lists under /usr/lib/clang
Some of the sanitizers from compiler-rt can use ignore lists, which are
loosely modeled on valgrind's example. Upstream provides default lists
for AddressSanitizer, CFI, and MemorySanitizer, so install these in the
expected location, /usr/lib/clang/14.0.3/share.

Reviewed by:	emaste
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D35338
2022-05-28 15:46:38 +02:00
Michael Tuexen
9cb70cb476 sctp: cleanup, no functional change except on error paths
MFC after:	3 days
2022-05-28 11:34:20 +02:00
Gleb Smirnoff
d64f2f42c1 unix: unp_externalize() can M_WAITOK
Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35318
2022-05-27 20:48:38 -07:00
Rick Macklem
a7bb120f8b nfscl: Add a diagnostic printf() for a "should never happen" case
When a NFSv4.1/4.2 session to the NFS server (not a pNFS DS) is
replaced, the old session should always be marked defunct by
nfsess_defunct being set non-zero.

However, the hang reported by the PR suggests that this might
be the case.

This patch adds a printf() to indicate this has somehow happened.

PR:	260011
MFC after: 	2 weeks
2022-05-27 14:32:46 -07:00
Rick Macklem
425e5c739b nfscl: Do not handle NFSERR_BADSESSION in operation code
The NFSERR_BADSESSION reply from a NFSv4.1/4.2 server
is handled by newnfs_request().  It should not be handled
separately after newnfs_request() has returned.

These two cases were spotted during code inspection.
One of them should only redo what newnfs_request() already
did by the same "nfscl" thread.  The other might have
resulted in recovery being done twice, but the code is
only used for "pnfs" mounts, so that would be rare.
Also, since NFSERR_BADSESSION should only be replied by
a server after the server reboots, this would be extremely
rare.

MFC after: 	2 weeks
2022-05-27 14:20:31 -07:00
Cy Schubert
05882e28fb tests: Fix i386 and powerpc build
Fix:

tests/sys/kern/unix_passfd_test.c:414:24: error: comparison of integers
of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
        ATF_REQUIRE(getnfds() == nfds + MAXFDS);
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
powerpc.powerpc/tmp/usr/include/atf-c/macros.h:144:15: note: expanded
from macro 'ATF_REQUIRE'
        if (!(expression)) \
              ^~~~~~~~~~
1 error generated.
--- unix_passfd_test.o ---
2022-05-27 14:04:17 -07:00
Kirk McKusick
076002f24d Do comprehensive UFS/FFS superblock integrity checks when reading a superblock.
Historically only minimal checks were made of a superblock when it
was read in as it was assumed that fsck would have been run to
correct any errors before attempting to use the filesystem. Recently
several bug reports have been submitted reporting kernel panics
that can be triggered by deliberately corrupting filesystem superblocks,
see Bug 263979 - [meta] UFS / FFS / GEOM crash (panic) tracking
which is tracking the reported corruption bugs.

This change upgrades the checks that are performed. These additional
checks should prevent panics from a corrupted superblock. Although
it appears in only one place, the new code will apply to the kernel
modules and (through libufs) user applications that read in superblocks.

Reported by:  Robert Morris and Neeraj
Reviewed by:  kib
Tested by:    Peter Holm
PR:           263979
MFC after:    1 month
Differential Revision: https://reviews.freebsd.org/D35219
2022-05-27 12:22:07 -07:00
Dimitry Andric
eca6e0f7e4 Apply clang fix for assertion failure building webkit2-gtk
Merge commit 30baa5d2a450 from llvm git (by Richard Smith):

  PR45879: Fix assert when constant evaluating union assignment.

  Consider the form of the first operand of a class assignment not the
  second operand when implicitly starting the lifetimes of union members.
  Also add a missing check that the assignment call actually came from a
  syntactic assignment, not from a direct call to `operator=`.

PR:		264280
Reported by:	bapt
MFC after:	3 days
2022-05-27 19:44:06 +02:00
Gleb Smirnoff
d59bc188d6 sockbuf: remove unused mbuf counter and cluster counter
With M_EXTPG mbufs these two counters already do not represent the
reality.  As we are moving towards protocol independent socket buffers,
which may not even use mbufs at all, the counters become less and less
relevant.  The only userland seeing them was 'netstat -x'.

PR:			264181 (exp-run)
Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35334
2022-05-27 08:20:17 -07:00
Alan Somers
55c8093f73 Replace subversion with git in the installation DVD
I assume the original reason for Subversion's inclusion was to checkout
the base system.  But now we use git for that.

Reviewed by:	gjb
Sponsored by:	Axcient
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D35329
2022-05-27 09:10:19 -06:00
Alan Somers
caf73e5857 bsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS
If the ZFSBOOT_DISKS variable is set to one or more disk names, then
those disks should be preselected in the disk menu.  However, the code
wasn't correctly setting the variable, leaving all disks unselected.

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	dteske
Differential Revision: https://reviews.freebsd.org/D35331
2022-05-27 09:09:33 -06:00
Peter Holm
4581e8e9a2 stress2: Added a syzkaler reproducer 2022-05-27 15:05:33 +02:00
Konrad Sewiłło-Jopek
c9a5c48ae8 arp: Implement sticky ARP mode for interfaces.
Provide sticky ARP flag for network interface which marks it as the
"sticky" one similarly to what we have for bridges. Once interface is
marked sticky, any address resolved using the ARP will be saved as a
static one in the ARP table. Such functionality may be used to prevent
ARP spoofing or to decrease latencies in Ethernet networks.

The drawbacks include potential limitations in usage of ARP-based
load-balancers and high-availability solutions such as carp(4).

The implemented option is disabled by default, therefore should not
impact the default behaviour of the networking stack.

Sponsored by:		Conclusive Engineering sp. z o.o.
Reviewed By:		melifaro, pauamma_gundo.com
Differential Revision: https://reviews.freebsd.org/D35314
MFC after:		2 weeks
2022-05-27 12:41:30 +00:00
Alexander Motin
18054d0220 libpmc: Another update of x86 event definitions.
MFC after:	1 month
2022-05-26 22:07:42 -04:00
John Baldwin
8020c05683 cxgbei: Adjust the calculation for the maximum ISO payload.
Round down the maximim ISO payload by the current MSS.  Otherwise the
round up by MSS when calculating the 16-bit maximum payload len passed
along in the FLOWC work request can overflow.

Discussed with:	np
Sponsored by:	Chelsio Communications
2022-05-26 14:32:54 -07:00
Gleb Smirnoff
75e7e3ce34 unix: fix incorrect assertion in 4682ac697c
Pointy hat to:	glebius
Fixes:		4682ac697c
2022-05-26 11:35:05 -07:00
Dimitry Andric
442bf90e52 Add newline after 20220524 entry in ObsoleteFiles.inc 2022-05-26 16:31:51 +02:00
Ed Maste
20b2b464eb syscons: note incompatibility with UEFI
PR:		264226
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-05-25 20:25:41 -04:00
John-Mark Gurney
35dc7f8f5d
dhclient: test against a real (ISC) dhcp server
This tests both both normal (untagged), and pcp tagged (VLAN 0)
networks which are now common for fiber ISPs.

Reviewed by: markj, kp
Differential Revision: https://reviews.freebsd.org/D35178
2022-05-25 17:02:38 -07:00
John Baldwin
f8287caae4 etcupdate: Preserve permissions when installing a resolved file.
Similar to the change in 1a04446f08, use
cat to overwrite the contents of the existing file rather than cp so
that metadata of the existing file such as permissions and ownership
is preserved.

PR:		255514
Reported by:	uqs
MFC after:	1 week
2022-05-25 14:20:40 -07:00
John Baldwin
431944fb5f etcupdate: Don't rotate trees for a dry run.
When performing a dry run, remove the temporary tree created rather
than rotating the trees.  Rotating the trees meant that etcupdate
thought the latest changes were already merged and would not merge
them on the next real run.

PR:		260281
Reported by:	Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Fixes:		0611aec3cf etcupdate: Always extract to a temporary tree.
MFC after:	1 week
2022-05-25 14:02:51 -07:00
Gleb Smirnoff
4682ac697c unix: turn check in unp_externalize() into assertion
In this function we always work with mbufs that we previously
created ourselves in unp_internalize().  They must be valid.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35319
2022-05-25 13:29:20 -07:00
Gleb Smirnoff
579b45e203 unix/*: check new control size in unp_internalize()
Now that we call sbcreatecontrol() with M_WAITOK, we are expected to
pass a valid size.  Return same error code, we are returning for an
oversized control from sockargs().

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35317
2022-05-25 13:29:13 -07:00
Gleb Smirnoff
d60ea9a10a sockets: return EMSGSIZE if control part of message is too large
Specification doesn't list an explicit error code for the control
size specified by msg_control being too large.  But it does list
EMSGSIZE as error code for "message is too large to be sent all at
once (as the socket requires)".  It also lists EINVAL as code for
the "The sum of the iov_len values overflows an ssize_t."  Given
how generic and uninformative EINVAL is, the EMSGSIZE is more
appropriate.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35316
2022-05-25 13:29:04 -07:00
Gleb Smirnoff
23402c83f4 tests/unix_passfd: sending many and too many SCM_RIGHTS
o Exercise bounds checking when sending large set of file descriptors,
  that can't fit into single control mbuf.
o Exercise resource limits checks when receiving a large sets.
o Check that socket isn't left in a completely stuck state when we can't
  receive SCM_RIGHTS due to limits.  Current SOCK_STREAM socket would
  free the control, but leave the data in.  This seems to be a legit
  behavior for a stream socket, as we don't want holes in the data.

PR:			239250
Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35315
2022-05-25 13:28:40 -07:00
Emmanuel Vadot
e26ef41f79 backlight: Update cached value when getting the brightness
External events can cause the backlight level to change (AC adapter
plug/unplug for example) so cache the value there too.

PR:		257796
Sponsored by:	Beckhoff Automation GmbH & Co. KG
MFC after:	1 week
2022-05-25 16:50:25 +02:00