]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agolibkiconv: address memory leak in not-found cases
Ed Maste [Wed, 21 Apr 2021 17:45:27 +0000 (13:45 -0400)]
libkiconv: address memory leak in not-found cases

Found in "Understanding and Detecting Disordered Error Handling with
Precise Function Pairing" by Qiushi Wu et al.

Reviewed by: imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29896

(cherry picked from commit 3cfd08c1c74058451a02bac35307bf7fa509c617)

3 years agoFix rtsock sockaddr alignment.
Alexander V. Chernikov [Tue, 27 Apr 2021 08:04:19 +0000 (08:04 +0000)]
Fix rtsock sockaddr alignment.

b31fbebeb3 introduced alloc_sockaddr_aligned() which, in fact,
 failed to produce aligned addresses.

Reported by: Oskar Holmlund <oskar.holmlund at yahoo.com>
MFC after: immediately

(cherry picked from commit 25682e6a495fc6669d799bb64acdaf14d653173e)

3 years agowlanstats: fix build
Sofian Brabez [Tue, 20 Apr 2021 18:31:48 +0000 (18:31 +0000)]
wlanstats: fix build

Add -Wno-cast-align to the CFLAGS to fix the build of wlanstats

Approved by: adrian
MFC after: 1 week

(cherry picked from commit b8be8094958a01255f5430bd6a36ff936bdd53c3)

3 years agoiwnstats: fix build with clang and allow install under /usr/local/sbin
Sofian Brabez [Tue, 20 Apr 2021 17:58:46 +0000 (17:58 +0000)]
iwnstats: fix build with clang and allow install under /usr/local/sbin

iwnstats was not compiling because of some issues raised by the clang
compiler due to -Werror. As a tool it is not connected to world build.

Add missing field "barker_mrc" initialization in struct
iwn_sensitivity_limits for -Wmissing-field-initializers, remove unused
pointer *is on iwn_stats_*_print functions and unused variables for
-Wunused-parameter and -Wunused-variable.

The value for field "barker_mrc" of struct iwn2030_sensitivity_limits
was obtained from linux 3.2 wireless/iwlwifi driver code (iwl-2000.c:115
.barker_corr_th_min_mrc = 390).

Also set BINDIR in Makefile to make it possible to install under
/usr/local/sbin/iwnstats as it require super user.

Reviewed by: adrian
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29800

(cherry picked from commit 561d34d70596b455c6a513431f8ad007076f90c5)

3 years agoFix race in case of device destruction.
Alexander Motin [Tue, 13 Apr 2021 15:19:10 +0000 (11:19 -0400)]
Fix race in case of device destruction.

During device destruction it is possible that open() succeed, but
fdevname() return NULL, that can't be assigned to string variable.
Fix that by adding explicit NULL check.

Also while there switch from fdevname() to fdevname_r().

Sponsored by: iXsystems, Inc.
MFC after: 2 weeks

(cherry picked from commit e49d3eb40324eaffaa13b93f2c4173dfa04dfa34)

3 years ago__FreeBSD_version: update the references to the doc tree
Ka Ho Ng [Thu, 22 Apr 2021 09:36:22 +0000 (17:36 +0800)]
__FreeBSD_version: update the references to the doc tree

Update the reference of which file to update in the doc tree when
bumping __FreeBSD_version.

This change is to catch up with commit f8fed61b80 in the doc repository.

Approved by: lwhsu (mentor), philip (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29920

(cherry picked from commit 7c707c7c25ad361f911716c31d22f5722f4dffc9)

3 years agovnode_pager_setsize.9: Some clarifications on the manpage
Ka Ho Ng [Sun, 11 Apr 2021 06:45:37 +0000 (14:45 +0800)]
vnode_pager_setsize.9: Some clarifications on the manpage

A number of changes:
- Clarifies the locking rules when calling the routine.
- Correct the description regarding the content range to be purged.
- Document the effects on page fault handler.

MFC with: 86a52e262a6f
Sponsored by: The FreeBSD Foundation
Reviewed by: bcr, kib
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D29637

(cherry picked from commit b77f5f5553e8ac7868b4b234a36bda3cf2db0907)

3 years agoDocument vnode_pager_setsize(9)
Ka Ho Ng [Wed, 7 Apr 2021 11:00:31 +0000 (19:00 +0800)]
Document vnode_pager_setsize(9)

Sponsored by: The FreeBSD Foundation
Reviewed by: bcr
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D29408

(cherry picked from commit 86a52e262a6faf75ee34eaa801f6d8ddaad20733)

3 years agoUse makefs(8) in release VM-image generation instead of md(4) and newfs.
Nathan Whitehorn [Thu, 25 Feb 2021 02:16:56 +0000 (21:16 -0500)]
Use makefs(8) in release VM-image generation instead of md(4) and newfs.

Using makefs instead reduces the privileges needed to build VM images,
simplifies the script (no need to copy files to a fresh image at the end),
and improves portability by allowing generation of cross-endian images.
As a result of the last, this patch also adds support for generation of
powerpc64 and powerpc64le VM images.

No other changes to the output. Tested and working for both amd64 and
powerpc64 targets.

Reviewed by: gjb
Differential Revision: https://reviews.freebsd.org/D28912

(cherry picked from commit 1ca8842f3ad9725863c9affc044d1974a51818a9)

3 years agoAllocate extra inodes in makefs when leaving free space in UFS images.
Nathan Whitehorn [Tue, 6 Apr 2021 17:43:29 +0000 (13:43 -0400)]
Allocate extra inodes in makefs when leaving free space in UFS images.

By default, makefs(8) has very few spare inodes in its output images,
which is fine for static filesystems, but not so great for VM images
where many more files will be added. Make makefs(8) use the same
default settings as newfs(8) when creating images with free space --
there isn't much point to leaving free space on the image if you
can't put files there. If no free space is requested, use current
behavior of a minimal number of available inodes.

Reviewed by: manu
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D29492

(cherry picked from commit afb6a168f8ee08ac74769464726c396fbef83d0b)

3 years agocxgbe: Ignore doomed virtual interfaces when updating the clip table.
John Baldwin [Mon, 12 Apr 2021 21:36:40 +0000 (14:36 -0700)]
cxgbe: Ignore doomed virtual interfaces when updating the clip table.

A doomed VI does not have a valid ifnet.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

(cherry picked from commit 45d5c28439f2464dd5022abb0dd53f9da649686c)

3 years agoiscsi: Kick threads out of iscsi_ioctl() during unload.
John Baldwin [Mon, 12 Apr 2021 20:56:16 +0000 (13:56 -0700)]
iscsi: Kick threads out of iscsi_ioctl() during unload.

iscsid can be sleeping in iscsi_ioctl() causing the destroy_dev() to
sleep forever if iscsi.ko is unloaded while iscsid is running.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

(cherry picked from commit 89df484739efe93b52da467f35255ae538bb946b)

3 years agocxgbe: Add counters for iSCSI PDUs transmitted via TOE.
John Baldwin [Mon, 12 Apr 2021 20:56:04 +0000 (13:56 -0700)]
cxgbe: Add counters for iSCSI PDUs transmitted via TOE.

Sponsored by: Chelsio Communications

(cherry picked from commit 568e69e4eb0ad1a5c69d8ea4592a4314bd6b6679)

3 years agocxgbe: Make the TOE TLS stats per-queue instead of per-port.
John Baldwin [Fri, 26 Mar 2021 22:05:44 +0000 (15:05 -0700)]
cxgbe: Make the TOE TLS stats per-queue instead of per-port.

This avoids some atomics by using counter_u64 for TX and relying on
existing single-threading (single ithread per rxq) for RX.

Sponsored by: Chelsio Communications

(cherry picked from commit fe496dc02a9a276d940e72bbd155dc256a34076f)

3 years agocxgbe: Add a struct sge_ofld_txq type.
John Baldwin [Fri, 26 Mar 2021 22:05:31 +0000 (15:05 -0700)]
cxgbe: Add a struct sge_ofld_txq type.

This type mirrors struct sge_ofld_rxq and holds state for TCP offload
transmit queues.  Currently it only holds a work queue but will
include additional state in future changes.

Sponsored by: Chelsio Communications

(cherry picked from commit 077ba6a845fab8f1d3bd83e07f61730f202a46fc)

3 years agocxgbei: Enter network epoch and set vnet around t4_push_pdus().
John Baldwin [Mon, 22 Mar 2021 16:59:16 +0000 (09:59 -0700)]
cxgbei: Enter network epoch and set vnet around t4_push_pdus().

Sponsored by: Chelsio Communications

(cherry picked from commit 90c74b2b6004bc50f89378ac689fd179aa2d2ad6)

3 years agocxgbe ddp: Use CPL_COOKIE_DDP* instead of DDP_BUF*_INVALIDATED.
John Baldwin [Mon, 22 Mar 2021 16:59:09 +0000 (09:59 -0700)]
cxgbe ddp: Use CPL_COOKIE_DDP* instead of DDP_BUF*_INVALIDATED.

This avoids mixing the use of two different enums which modern C
compilers warn about.

Sponsored by: Chelsio Communications

(cherry picked from commit 017902fc5f07114e7baba94bb4720c8b41ddea0f)

3 years agocxgbei: Pass ULP submode directly to set_ulp_mode_iscsi().
John Baldwin [Mon, 22 Mar 2021 16:59:02 +0000 (09:59 -0700)]
cxgbei: Pass ULP submode directly to set_ulp_mode_iscsi().

Sponsored by: Chelsio Communications

(cherry picked from commit 8855ed61b5b7de94744fc415e5f049fee342d6b5)

3 years agocxgbei: Move some function prototypes to cxgbei.h.
John Baldwin [Mon, 22 Mar 2021 16:58:54 +0000 (09:58 -0700)]
cxgbei: Move some function prototypes to cxgbei.h.

Sponsored by: Chelsio Communications

(cherry picked from commit 45eed2331e8f796a6c315374d85a9485a29e2536)

3 years agocxgbei: Set vnet around tcp_drop() in do_rx_iscsi_ddp().
John Baldwin [Mon, 22 Mar 2021 16:58:28 +0000 (09:58 -0700)]
cxgbei: Set vnet around tcp_drop() in do_rx_iscsi_ddp().

Sponsored by: Chelsio Communications

(cherry picked from commit 52c11c3f744c8a68fb71a1343e8ffb4a9f70072a)

3 years agoFix a typo in a comment: frame -> framework.
John Baldwin [Tue, 16 Mar 2021 22:33:20 +0000 (15:33 -0700)]
Fix a typo in a comment: frame -> framework.

Sponsored by: Chelsio Communications

(cherry picked from commit 86e352c934e5af49866d13a79ddb7c6fbf090cb9)

3 years agoccr: Disable requests on port 1 when needed to workaround a firmware bug.
John Baldwin [Fri, 12 Mar 2021 18:35:56 +0000 (10:35 -0800)]
ccr: Disable requests on port 1 when needed to workaround a firmware bug.

Completions for crypto requests on port 1 can sometimes return a stale
cookie value due to a firmware bug.  Disable requests on port 1 by
default on affected firmware.

Sponsored by: Chelsio Communications

(cherry picked from commit 5fe0cd6503d34d23c98e9e1ff7bf10340218a5ec)

3 years agoccr: Add per-port stats of queued and completed requests.
John Baldwin [Fri, 12 Mar 2021 18:35:32 +0000 (10:35 -0800)]
ccr: Add per-port stats of queued and completed requests.

Sponsored by: Chelsio Communications

(cherry picked from commit 9c5137beb5f28292410888d0770bdf24c15e1312)

3 years agoccr: Set the RX channel ID correctly in work requests.
John Baldwin [Fri, 12 Mar 2021 18:35:05 +0000 (10:35 -0800)]
ccr: Set the RX channel ID correctly in work requests.

These fixes are only relevant for requests on the second port.  In
some cases, the crypto completion data, completion message, and
receive descriptor could be written in the wrong order.

- Add a separate rx_channel_id that is a copy of the port's rx_c_chan
  and use it when an RX channel ID is required in crypto requests
  instead of using the tx_channel_id.

- Set the correct rx_channel_id in the CPL_RX_PHYS_ADDR used to write
  the crypto result.

- Set the FID to the first rx queue ID on the adapter rather than the
  queue ID of the first rx queue for the port.

- While here, use tx_chan to set the tx_channel_id though this is
  identical to the previous value.

Reported by: Chelsio QA
Sponsored by: Chelsio Communications

(cherry picked from commit 8f885fd1f38159a06db82d680fa259f358e9f872)

3 years agocxgbe(4): Read the rx 'c' channel for a port and make it available.
Navdeep Parhar [Fri, 26 Feb 2021 02:10:52 +0000 (18:10 -0800)]
cxgbe(4): Read the rx 'c' channel for a port and make it available.

Sponsored by: Chelsio Communications

(cherry picked from commit dfff1de729bd73004404863b7f9e8a9bda7b0f04)

3 years agoHandle negative return values from syncache_expand().
John Baldwin [Wed, 17 Feb 2021 21:28:04 +0000 (13:28 -0800)]
Handle negative return values from syncache_expand().

These errors do not clear so to NULL, so the existing check was
treating these failures as success.  The rest of do_pass_establish()
then tried to use the listen socket as if it was a connection socket
newly created by syncache_expand().

In addition, for negative return values, do not send a RST to the
peer.

Reported by: Sony Arpita Das @ Chelsio
Sponsored by: Chelsio Communications

(cherry picked from commit 1deaad936417ed2315476718fbd2648de08585bf)

3 years agolinuxkpi: Remove unneeded {} in atomic_dec_and_lock_irqsave()
Neel Chauhan [Mon, 26 Apr 2021 15:25:33 +0000 (08:25 -0700)]
linuxkpi: Remove unneeded {} in atomic_dec_and_lock_irqsave()

(cherry picked from commit e657f3de6dc29147b5373d2cc2cc47e580931e30)

3 years agolinuxkpi: Elimiate brackets on return in spinlock.h
Neel Chauhan [Mon, 26 Apr 2021 15:16:48 +0000 (08:16 -0700)]
linuxkpi: Elimiate brackets on return in spinlock.h

(cherry picked from commit c8de6e20150a3c10575a27532a25b00342a7f452)

3 years agolinuxkpi: Implement atomic_dec_and_lock_irqsave()
Neel Chauhan [Mon, 26 Apr 2021 15:15:49 +0000 (08:15 -0700)]
linuxkpi: Implement atomic_dec_and_lock_irqsave()

This is needed by the drm-kmod 5.5 update.

Reviewed by: hselasky, manu
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29988

(cherry picked from commit ce65353ac1a17677bef03e96df8da967c9086743)

3 years agolinuxkpi: Implement the wait_event_interruptible macro
Neel Chauhan [Mon, 26 Apr 2021 15:12:18 +0000 (08:12 -0700)]
linuxkpi: Implement the wait_event_interruptible macro

This is needed by the drm-kmod 5.5 update and is similar in logic to the
existing wait_event_killable macro.

Reviewed by: hselasky, manu
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29987

(cherry picked from commit 057f145aae9a3528ccd722c8f566d740d5cafcbb)

3 years agoports.7: Add an example of setting variables for selected ports
Mateusz Piotrowski [Sat, 16 Jan 2021 23:10:44 +0000 (00:10 +0100)]
ports.7: Add an example of setting variables for selected ports

Reviewed by: crees
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28202

(cherry picked from commit c0e41dff700cf8a4a06000f19bd2342cd6fe284d)

3 years agoFix zgrep --version
Mateusz Piotrowski [Tue, 13 Apr 2021 10:12:53 +0000 (12:12 +0200)]
Fix zgrep --version

"zgrep --version" is expected to print the version information in the
same way as "zgrep -V". However, the case handling the --version flag
is never reached, so "zgrep --version" prints:
    zgrep: missing pattern
instead of:
    grep (BSD grep, GNU compatible) 2.6.0-FreeBSD

Reviewed by: yuripv
Approved by: yuripv (src)
Differential Revision: https://reviews.freebsd.org/D29813

(cherry picked from commit 16e0391f8e2124eb85af984204548cf841648db5)

3 years ago[fib algo] Do not print algo attach/detach message on boot
Alexander V. Chernikov [Sun, 25 Apr 2021 08:51:57 +0000 (08:51 +0000)]
[fib algo] Do not print algo attach/detach message on boot

MFC after: 1 day

(cherry picked from commit c23385612da5dd3195a9b73bfb22bd969dbd26c2)

3 years agoMake gcc happy by initializing error in rib_handle_ifaddr_info().
Alexander V. Chernikov [Sun, 25 Apr 2021 08:44:20 +0000 (08:44 +0000)]
Make gcc happy by initializing error in rib_handle_ifaddr_info().

(cherry picked from commit a81e2e7890c2fce2a74dbb859e6855e0414a6ea1)

3 years agoImprove debugging output on routing tests failure.
Alexander V. Chernikov [Fri, 23 Apr 2021 21:28:38 +0000 (21:28 +0000)]
Improve debugging output on routing tests failure.

Most of the routing tests create per-test VNET, making
 it harder to repeat the failure with CLI tools.
Provide an additional route/nexthop data on failure.

Differential Revision: https://reviews.freebsd.org/D29957
Reviewed by: kp
MFC after: 2 weeks

(cherry picked from commit bddae5c8a64dc6b292198945cbe676bb2158d438)

3 years agoRelax rtsock message restrictions.
Alexander V. Chernikov [Mon, 19 Apr 2021 20:49:18 +0000 (20:49 +0000)]
Relax rtsock message restrictions.

Address multiple issues with strict rtsock message validation.

D28668 "normalisation" approach was based on the assumption that
 we always have at least "standard" sockaddr len.
It turned out to be false - certain older applications like quagga
 or routed abuse sin[6]_len field and set it to the offset to the
 first fully-zero bit in the mask. It is impossible to normalise
 such sockaddrs without reallocation.

With that in mind, change the approach to use a distinct memory
 buffer for the altered sockaddrs. This allows supporting the older
 software while maintaining the guarantee on the "standard" sockaddrs.

PR: 255273,255089
Differential Revision: https://reviews.freebsd.org/D29826
MFC after: 3 days

(cherry picked from commit b31fbebeb3d59af359a3417cddfbcf666b2c56c9)

3 years agoImprove error reporting in rtsock.c
Alexander V. Chernikov [Mon, 19 Apr 2021 20:36:41 +0000 (20:36 +0000)]
Improve error reporting in rtsock.c

MFC after: 3 days

(cherry picked from commit 758c9d54d44f8ce957570b8c2ef6d1b3f28a792d)

3 years agoFix typo in rtsock_common.h
Alexander V. Chernikov [Mon, 19 Apr 2021 20:24:42 +0000 (20:24 +0000)]
Fix typo in rtsock_common.h

MFC after: 3 days

(cherry picked from commit 37c0f4a2077739e735732374d67525cf6de36d21)

3 years agoFib algo: extend KPI by allowing algo to set datapath pointers.
Alexander V. Chernikov [Thu, 15 Apr 2021 17:44:11 +0000 (18:44 +0100)]
Fib algo: extend KPI by allowing algo to set datapath pointers.

Some algorithms may require updating datapath and control plane
 algo pointers after the (batched) updates.

Export fib_set_datapath_ptr() to allow setting the new datapath
 function or data pointer from the algo.
Add fib_set_algo_ptr() to allow updating algo control plane
 pointer from the algo.
Add fib_epoch_call() epoch(9) wrapper to simplify freeing old
 datapath state.

Reviewed by: zec
Differential Revision: https://reviews.freebsd.org/D29799
MFC after: 1 week

(cherry picked from commit e2f79d9e518f885bf875f6613e70af39b7c397de)

3 years agolinuxkpi: reduce number of stray mm_struct allocations
Konstantin Belousov [Thu, 11 Mar 2021 06:48:22 +0000 (08:48 +0200)]
linuxkpi: reduce number of stray mm_struct allocations

(cherry picked from commit fad437ba612a7c19f5cf1633e2d0d1c44d4dd478)

3 years agolinuxkpi: guarantee allocations of task and mm for interrupt threads
Konstantin Belousov [Thu, 11 Mar 2021 06:34:42 +0000 (08:34 +0200)]
linuxkpi: guarantee allocations of task and mm for interrupt threads

(cherry picked from commit 165ba13fb806c8596f868981883631a5ee78d6c8)

3 years agolinuxkpi: some style, wrap too long lines
Konstantin Belousov [Thu, 11 Mar 2021 06:08:51 +0000 (08:08 +0200)]
linuxkpi: some style, wrap too long lines

(cherry picked from commit 4ce1f6162e9eb576ac40f24b8538f55e83ef5eb4)

3 years agoixgbe: Clarify index name in ixgbe_mc_filter_apply
Kevin Bowling [Sat, 17 Apr 2021 01:17:43 +0000 (18:17 -0700)]
ixgbe: Clarify index name in ixgbe_mc_filter_apply

"It looks like it would be less confusing to rename 'count' to
something like 'idx', since that's what it's used for in this
function."

Reviewed by: erj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29798

(cherry picked from commit 21afed4b1d18578aa8c9fa31e9e677971f8b4300)

3 years agonfsd: fix replies from session cache for multiple retries
Rick Macklem [Sat, 10 Apr 2021 22:50:25 +0000 (15:50 -0700)]
nfsd: fix replies from session cache for multiple retries

Recent testing of network partitioning a FreeBSD NFSv4.1
server from a Linux NFSv4.1 client identified problems
with both the FreeBSD server and Linux client.

Commit 05a39c2c1c18 fixed replying with the cached reply in
in the session slot if same session slot sequence#.
However, the code uses the reply and, as such,
will fail for a subsequent retry of the RPC.
A subsequent retry would be an extremely rare event,
but this patch fixes this, so long as m_copym(..M_NOWAIT)
does not fail, which should also be a rare event.

This fix affects the exceedingly rare case where a NFSv4
client retries a non-idempotent RPC, such as a lock
operation, multiple times.  Note that retries only occur
after the client has needed to create a new TCP connection,
with a new TCP connection for each retry.

(cherry picked from commit 22cefe3d8378f58adcdbb2c7589b9f30c2a38315)

3 years agompt(4): Remove incorrect S/G segments limits.
Alexander Motin [Sat, 17 Apr 2021 14:41:35 +0000 (10:41 -0400)]
mpt(4): Remove incorrect S/G segments limits.

First, two of those four checks are unreachable.
Second, I don't believe there should be ">=" instead of ">".
Third, bus_dma(9) already returns the same EFBIG if ">".

This fixes false I/O errors in worst S/G cases with maxphys >= 2MB.

MFC after: 1 week

(cherry picked from commit 0f29396e493bd87ffa6a63fcb602b12e79d21a1e)

3 years agoCirrus-CI: use FreeBSD 13.0 image for base system CI build
Ed Maste [Mon, 19 Apr 2021 18:36:21 +0000 (14:36 -0400)]
Cirrus-CI: use FreeBSD 13.0 image for base system CI build

We generally want to build and test on the highest release version, and
FreeBSD 13.0 also brings some performance benefits.

Reviewed by: lwhsu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29842

(cherry picked from commit 407abff2b91847e23711625ad7c69c17e99b3d1d)

3 years agolex: Use NULL instead of 0 for pointers
Jung-uk Kim [Thu, 11 Feb 2021 23:31:53 +0000 (18:31 -0500)]
lex: Use NULL instead of 0 for pointers

Note araujo tried to fix it in r298241 but he only touched generated
files for bootstrap.  This commit properly fixes the problem.

(cherry picked from commit 34e67bb5977049afb3e965b52b86ac12ea4899b4)

3 years agoflex: Regen bootstrap files
Jung-uk Kim [Mon, 19 Apr 2021 18:20:51 +0000 (14:20 -0400)]
flex: Regen bootstrap files

This also partially reverts r326025 (8a16b7a18f5d).  I do not see any
point of adding SPDX tag in generated file.

Submitted by: Dan McGregor <dan.mcgregor@usask.ca> (initial version)
Differential Revision: https://reviews.freebsd.org/D28596

(cherry picked from commit 686cf5468c4a85c2a6385cdbab2383900876a41d)

3 years agoreadelf: return error in case of invalid file
Ed Maste [Fri, 23 Apr 2021 15:37:49 +0000 (11:37 -0400)]
readelf: return error in case of invalid file

GNU readelf exits with an error for a number of invalid file cases.
Previously ELF Tool Chain readelf always exited with 0.  Now we exit 1
upon detecting an error with one or more input files, but in any case
all of them are processed.

This should catch common failure cases.  We still do not report an error
for some types of malformed ELF files, but this is consistent with GNU
readelf.

PR: 252727
Reviewed by: jkoshy, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29377

(cherry picked from commit ea444392bb5b351c930f28a02a4e68f51b25ba69)

3 years agosysctl vm.objects: report backing object and swap use
Konstantin Belousov [Thu, 15 Apr 2021 09:27:02 +0000 (12:27 +0300)]
sysctl vm.objects: report backing object and swap use

(cherry picked from commit ecfbddf0cde3d4151217e3eb2d7c5388a423d397)

3 years agosysctl_handle_string: do not malloc when SYSCTL_IN cannot fault
Konstantin Belousov [Sun, 18 Apr 2021 16:09:30 +0000 (19:09 +0300)]
sysctl_handle_string: do not malloc when SYSCTL_IN cannot fault

(cherry picked from commit 4342ba184c15f3b8912e95f93fe313731963f065)

3 years agovn_open_vnode(): handle error when fp == NULL
Konstantin Belousov [Mon, 19 Apr 2021 10:25:30 +0000 (13:25 +0300)]
vn_open_vnode(): handle error when fp == NULL

PR: 255119

(cherry picked from commit 54f98c4dbf9b1203a4e3e1b13fd0738441226991)

3 years agolinkat(2): check NIRES_EMPTYPATH on the first fd arg
Konstantin Belousov [Mon, 19 Apr 2021 13:35:25 +0000 (16:35 +0300)]
linkat(2): check NIRES_EMPTYPATH on the first fd arg

(cherry picked from commit 578c26f31c0c90c9e6b2f7125a8539c307a51dff)

3 years agoO_PATH: allow vnode kevent filter on such files
Konstantin Belousov [Wed, 7 Apr 2021 18:31:48 +0000 (21:31 +0300)]
O_PATH: allow vnode kevent filter on such files

(cherry picked from commit bbf7a4e878ed6828d13c7029c128a7e60dc25391)

3 years agoO_PATH: Allow to open symlink
Konstantin Belousov [Wed, 7 Apr 2021 03:23:25 +0000 (06:23 +0300)]
O_PATH: Allow to open symlink

(cherry picked from commit f9b923af34a6749c7703b957742f33cc02a485a2)

3 years agoMake files opened with O_PATH to not block non-forced unmount
Konstantin Belousov [Sat, 3 Apr 2021 18:55:11 +0000 (21:55 +0300)]
Make files opened with O_PATH to not block non-forced unmount

(cherry picked from commit a5970a529c2d952714f20e4bc6e529c74fd2b3b5)

3 years agoopen(2): Implement O_PATH
Konstantin Belousov [Thu, 18 Mar 2021 10:41:47 +0000 (12:41 +0200)]
open(2): Implement O_PATH

(cherry picked from commit 8d9ed174f3afba5f114742447e622fc1173d4774)

3 years agoAdd AT_EMPTY_PATH for several *at(2) syscalls
Konstantin Belousov [Sun, 7 Mar 2021 14:29:09 +0000 (16:29 +0200)]
Add AT_EMPTY_PATH for several *at(2) syscalls

(cherry picked from commit 509124b62616f73dcdc42263ee109392dafafd99)

3 years agovfs_vnops.c: Make vn_statfile() non-static
Konstantin Belousov [Thu, 18 Mar 2021 10:41:07 +0000 (12:41 +0200)]
vfs_vnops.c: Make vn_statfile() non-static

(cherry picked from commit 437c241d0c78f77a9d9e54494a353db01ce1a3de)

3 years agoStyle.
Konstantin Belousov [Thu, 18 Mar 2021 10:40:20 +0000 (12:40 +0200)]
Style.

(cherry picked from commit 42be0a7b10b14113ba9c4e4a738e8f20e235b736)

3 years agoAT_RESOLVE_BENEATH is bsd-specific
Konstantin Belousov [Thu, 11 Mar 2021 15:07:02 +0000 (17:07 +0200)]
AT_RESOLVE_BENEATH is bsd-specific

(cherry picked from commit d51b4b0aac43d9d25f7eb3f17b2d3034a5c851d8)

3 years agob_vflags update requries bufobj lock
Konstantin Belousov [Tue, 13 Apr 2021 10:22:56 +0000 (13:22 +0300)]
b_vflags update requries bufobj lock

(cherry picked from commit e3d675958539eee899d42438f5b46a26f3c64902)

3 years agorealtimer_expire: avoid proc lock recursion when called from itimer_proc_continue()
Konstantin Belousov [Tue, 13 Apr 2021 13:47:24 +0000 (16:47 +0300)]
realtimer_expire: avoid proc lock recursion when called from itimer_proc_continue()

(cherry picked from commit 5cc1d199412ead0b4c234e21e881a31ef893a4f0)

3 years agofilt_timerexpire: avoid process lock recursion
Konstantin Belousov [Tue, 13 Apr 2021 14:25:11 +0000 (17:25 +0300)]
filt_timerexpire: avoid process lock recursion

(cherry picked from commit 75c5cf7a720f5a73f17aff60adbc4a7b2fa86f84)

3 years agoStop arming kqueue timers on knote owner suspend or terminate
Konstantin Belousov [Fri, 5 Mar 2021 23:29:08 +0000 (01:29 +0200)]
Stop arming kqueue timers on knote owner suspend or terminate

(cherry picked from commit 2fd1ffefaa4d2cd99a19f866a949cb2cd58ef998)

3 years agoAdd helper for kqueue timers callout scheduling
Konstantin Belousov [Fri, 5 Mar 2021 23:31:20 +0000 (01:31 +0200)]
Add helper for kqueue timers callout scheduling

(cherry picked from commit 533e5057ed2503013643bf8450588e4aa58c2b7e)

3 years agoStop arming realtime posix process timers on suspend or terminate
Konstantin Belousov [Thu, 11 Mar 2021 08:16:51 +0000 (10:16 +0200)]
Stop arming realtime posix process timers on suspend or terminate

(cherry picked from commit 4d27d8d2f3b8ae4ef3efc86b220c7ff2dbdbac5a)

3 years agoStop arming periodic process timers on suspend or terminate
Konstantin Belousov [Fri, 5 Mar 2021 21:19:35 +0000 (23:19 +0200)]
Stop arming periodic process timers on suspend or terminate

(cherry picked from commit dc47fdf1319f18be1aadbcdef17c721a83415d84)

3 years agopseudofs: limit writes to 1M
Konstantin Belousov [Tue, 13 Apr 2021 19:48:44 +0000 (22:48 +0300)]
pseudofs: limit writes to 1M

(cherry picked from commit 5edf7227ec339f651c7328e63df323f6ef10345f)

3 years agosbuf_uionew(): sbuf_new() takes int as length
Konstantin Belousov [Tue, 13 Apr 2021 19:12:19 +0000 (22:12 +0300)]
sbuf_uionew(): sbuf_new() takes int as length

(cherry picked from commit 116f26f947b8bbf868dcd85d79226406029a45ee)

3 years agonfs client: depend on xdr
Konstantin Belousov [Tue, 13 Apr 2021 11:47:20 +0000 (14:47 +0300)]
nfs client: depend on xdr

(cherry picked from commit 8cca7b7f28feaf0c5e2dfedb985ae334a4013ef6)

3 years agolink(2): correct descriptor name in AT_RESOLVE_BENEATH description
Konstantin Belousov [Tue, 30 Mar 2021 21:56:28 +0000 (00:56 +0300)]
link(2): correct descriptor name in AT_RESOLVE_BENEATH description

(cherry picked from commit c78e124535febc6c0bc7c0756b42d6b845428d2e)

3 years agoptrace: restructure comments around reparenting on PT_DETACH
Konstantin Belousov [Sun, 11 Apr 2021 09:06:21 +0000 (12:06 +0300)]
ptrace: restructure comments around reparenting on PT_DETACH

(cherry picked from commit a091c353235e0ee97d2531e80d9d64e1648350f4)

3 years agoptrace: remove dead call to FIX_SSTEP()
Konstantin Belousov [Sun, 11 Apr 2021 09:02:34 +0000 (12:02 +0300)]
ptrace: remove dead call to FIX_SSTEP()

(cherry picked from commit 9d7e450b64f1e605c718fba0f357d49541c8147b)

3 years agoamd64 linux64: use x86_clear_dbregs()
Konstantin Belousov [Fri, 9 Apr 2021 23:22:48 +0000 (02:22 +0300)]
amd64 linux64: use x86_clear_dbregs()

(cherry picked from commit 2f1588474768f61f3a983af207e753bd0340a9e7)

3 years agox86: use x86_clear_dbregs() on fork
Konstantin Belousov [Fri, 9 Apr 2021 23:20:55 +0000 (02:20 +0300)]
x86: use x86_clear_dbregs() on fork

(cherry picked from commit 290b0d123ae2136ad84b268cd1884b1624d1d37f)

3 years agoamd64: clear debug registers on execing 32bit native binary
Konstantin Belousov [Fri, 9 Apr 2021 23:23:54 +0000 (02:23 +0300)]
amd64: clear debug registers on execing 32bit native binary

(cherry picked from commit d50adfec9ee73e88e8d365525f1acef2c1db798a)

3 years agoamd64: clear debug registers on execing 32bit Linux binary
Konstantin Belousov [Fri, 9 Apr 2021 23:25:06 +0000 (02:25 +0300)]
amd64: clear debug registers on execing 32bit Linux binary

(cherry picked from commit 94172affa43af15fe3b50293a96c292eca30c386)

3 years agox86: add x86_clear_dbregs() helper
Konstantin Belousov [Fri, 9 Apr 2021 23:19:23 +0000 (02:19 +0300)]
x86: add x86_clear_dbregs() helper

(cherry picked from commit a8b75a57c9b2cb3388746f097a55086a0f8c5d38)

3 years agortld_lock.h: add some comments about versioning of struct RtldLockInfo
Konstantin Belousov [Sun, 11 Apr 2021 08:12:48 +0000 (11:12 +0300)]
rtld_lock.h: add some comments about versioning of struct RtldLockInfo

(cherry picked from commit 9b33518ada2ebda727ca3c7979cdcdb30716f737)

3 years agortld: make dlerror() thread-local
Konstantin Belousov [Wed, 7 Apr 2021 22:02:33 +0000 (01:02 +0300)]
rtld: make dlerror() thread-local

(cherry picked from commit 4d9128da54f8f8e2a29190ffb18880c4f116a205)

3 years agortld: workaround for broken ABI
Konstantin Belousov [Sat, 10 Apr 2021 12:32:24 +0000 (15:32 +0300)]
rtld: workaround for broken ABI

(cherry picked from commit 08bfbd43594b7642de0d2487550f36b0ee1eceba)

3 years agortld: unstaticise lockinfo and obj_from_addr()
Konstantin Belousov [Sat, 10 Apr 2021 12:30:59 +0000 (15:30 +0300)]
rtld: unstaticise lockinfo and obj_from_addr()

(cherry picked from commit 4d7f08c84bcfcd75ba23b06e07a8e5dba1d4a44f)

3 years agortld: use _get_tp() in __tls_get_addr()
Konstantin Belousov [Wed, 7 Apr 2021 03:49:28 +0000 (06:49 +0300)]
rtld: use _get_tp() in __tls_get_addr()

(cherry picked from commit e8b9c508b7ae5be618ada089103468c400e465cd)

3 years agortld: avoid recursing on rtld_bind_lock for write
Konstantin Belousov [Tue, 6 Apr 2021 19:02:23 +0000 (22:02 +0300)]
rtld: avoid recursing on rtld_bind_lock for write

(cherry picked from commit 7cb32a0d03437f881169b1c55cce89cf70ed43dd)

3 years agortld: allow to use tls_get_addr_slow() from context where rtld_bind_lock is locked
Konstantin Belousov [Tue, 6 Apr 2021 18:56:58 +0000 (21:56 +0300)]
rtld: allow to use tls_get_addr_slow() from context where rtld_bind_lock is locked

(cherry picked from commit 89508048424837ffdb32c8444dab02261711f77d)

3 years agortld: style tls_get_addr_slow
Konstantin Belousov [Tue, 6 Apr 2021 18:55:10 +0000 (21:55 +0300)]
rtld: style tls_get_addr_slow

(cherry picked from commit 85d846b369f4d8c0033993d3d1307779d3b9aa62)

3 years agolibc dl_iterate_phdr(): dlpi_tls_data is wrong
Konstantin Belousov [Mon, 5 Apr 2021 03:38:07 +0000 (06:38 +0300)]
libc dl_iterate_phdr(): dlpi_tls_data is wrong

(cherry picked from commit dbd2053026a6af28adb1aa32e27603ae0d4efea6)

3 years agolibc: implement __tls_get_addr() for static binaries
Konstantin Belousov [Mon, 5 Apr 2021 03:29:47 +0000 (06:29 +0300)]
libc: implement __tls_get_addr() for static binaries

(cherry picked from commit ca46b5698e8ac38ab45d781d592700be59e7de97)

3 years agolibc: add _get_tp() private function
Konstantin Belousov [Mon, 5 Apr 2021 03:30:35 +0000 (06:30 +0300)]
libc: add _get_tp() private function

(cherry picked from commit 06d8a116bd6b6f70b8aedc6a6a2c4085c53f63ac)

3 years agortld: define TLS_DTV_OFFSET on all architectures
Konstantin Belousov [Wed, 7 Apr 2021 06:25:34 +0000 (09:25 +0300)]
rtld: define TLS_DTV_OFFSET on all architectures

(cherry picked from commit 99c2ce7ef12f0852f25155d1d6718beccafbae0e)

3 years agolibc: include rtld.h into static implementations of rtld interface
Konstantin Belousov [Mon, 5 Apr 2021 03:41:46 +0000 (06:41 +0300)]
libc: include rtld.h into static implementations of rtld interface

(cherry picked from commit 7f7489eba391a858b3930a34e7749d642b374c5c)

3 years agolibc: constify dummy error message string for dlfcn
Konstantin Belousov [Mon, 5 Apr 2021 04:14:39 +0000 (07:14 +0300)]
libc: constify dummy error message string for dlfcn

(cherry picked from commit 93c14c55ec0da311dc09c1c8c1c7ecd5f2fae51a)

3 years agortld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc
Konstantin Belousov [Mon, 5 Apr 2021 04:12:22 +0000 (07:12 +0300)]
rtld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc

(cherry picked from commit 34ca6025ddfea9899024eb6e7617091c5bc5149a)

3 years agortld/x86/reloc.c: style
Konstantin Belousov [Wed, 7 Apr 2021 06:12:10 +0000 (09:12 +0300)]
rtld/x86/reloc.c: style

(cherry picked from commit f61ecf60cfce6172df803a9e5e099aab2d4aedcd)

3 years agortld_lock.h: remove tautological extern's
Konstantin Belousov [Mon, 5 Apr 2021 04:11:49 +0000 (07:11 +0300)]
rtld_lock.h: remove tautological extern's

(cherry picked from commit 38e0610df7d5cd5ddd43a477c139ec6ce342c5c2)

3 years agortld dl_iterate_phdr(): dlpi_tls_data is wrong
Konstantin Belousov [Mon, 5 Apr 2021 03:05:44 +0000 (06:05 +0300)]
rtld dl_iterate_phdr(): dlpi_tls_data is wrong

(cherry picked from commit d36d6816151705907393889d661cbfd25c630ca8)

3 years agolinuxkpi: remove erronously committed diff save file
Konstantin Belousov [Tue, 6 Apr 2021 00:42:13 +0000 (03:42 +0300)]
linuxkpi: remove erronously committed diff save file

(cherry picked from commit 5b3b19db7305f8255f021d6f8d94d17ab778660f)

3 years agolinuxkpi: drop single-use variable
Konstantin Belousov [Tue, 30 Mar 2021 08:46:42 +0000 (11:46 +0300)]
linuxkpi: drop single-use variable

(cherry picked from commit 8011fb795baa59ba14371d6db5ab661a5db77615)

3 years agolinuxkpi: avoid counting per-thread use for the embedded linux cdevs
Konstantin Belousov [Tue, 30 Mar 2021 08:45:24 +0000 (11:45 +0300)]
linuxkpi: avoid counting per-thread use for the embedded linux cdevs

(cherry picked from commit f6b108837e7df7d7bfb35ec447f7cb62afa79441)