Commit graph

416 commits

Author SHA1 Message Date
Ed Maste 61639bb3fc libc: move NIS xdr_* symbols from rpc's to yp's Symbol.map
To fix WITHOUT_NIS build.  Building yp_xdr.c is gated by MK_NIS.

PR:		279270
Reported by:	peterj
Reported by:	matteo
Reported by:	Michael Dexter's Build Option Survey run
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45347
2024-05-24 16:47:37 -04:00
Assume-Zhan eb8ba6fb74
rpc: Fix typo in comment
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/995
2024-02-13 14:20:45 +08:00
Warner Losh a2f733abcf lib: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh 5b31cc94b1 sccs: Manual changes
For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh dc36d6f9bb lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Alan Somers 24938f9311 lib/libc/rpc: switch the per-fd structs in clnt_{dg,vc}.c to RB Trees
This saves oodles of memory, especially when "ulimit -n" is large.  It
also prevents a buffer overflow if getrlimit should fail.

Also replace per-fd condvars with mutexes to simplify the code.

PR:		274968
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597
2023-11-15 16:12:50 -07:00
Alan Somers a5c2f4e939 libc/libc/rpc: refactor some global variables
* Combine dg_fd_locks and dg_cv into one array.
* Similarly for vc_fd_locks and vc_cv
* Turn some macros into inline functions

This is a mostly cosmetic change to make refactoring these strutures in
a future commit easier.

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597
2023-11-15 16:12:50 -07:00
Brooks Davis 1ca63a8219 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42612
2023-11-15 17:51:03 +00:00
Warner Losh 559a218c9b libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385
2023-11-01 16:44:30 -06:00
Dag-Erling Smørgrav dc41de36ab libc: Fix missing or misspelled MLINKS.
Differential Revision:	https://reviews.freebsd.org/D42192
2023-10-18 16:07:46 +02:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Rick Macklem 032b04626b rpcb_clnt.c: Do not force use of UDP
Without this patch, the code in the rpcbind client forces
the use of UDP.  A comment notes that some rpcbind servers
only support UDP.  This makes NFSv3 mounts to Azure servers
impossible, since they require use of TCP for rpcbind.
Since the comment is very old (imported from NetBSD in 2001)
and I do not believe any UDP only rpcbind servers will
still exist, this patch comments out the code that forces
use of UDP, so that NFSv3 mounts to Azure servers can work.

For an NFSv3 mount, the "udp" mount option will still
make mount_nfs use UDP for rpcbind so that can be used
as a workaround for any old NFSv3 server that only
supports rpcbind over UDP (if any such server still exists).

I asked if doing this change is appropriate on freebsd-fs@
and I only got one reply (off list) that supported doing
the change.

PR:	267301
MFC after:	1 month
2022-11-13 12:16:06 -08:00
John Baldwin a2e41a585b libc rpc: Fix mismatches in prototypes for array bounds.
Various RPC functions used a bare pointer in function prototypes to
describe fixed-length buffer arguments but used a fixed-length array
in the function definition.  The manual page for these functions
describes the parameters as being fixed-length buffers, so update
the prototypes to match the definitions.

Reviewed by:	imp, emaste
Reported by:	GCC -Warray-parameter
Differential Revision:	https://reviews.freebsd.org/D36757
2022-09-28 14:01:36 -07:00
Gordon Bergling 5c49e1cbea rpc(3): Fix two typos in source code comments
- s/alloctaed/allocated/

Obtained from:	NetBSD
MFC after:	3 days
2022-04-02 09:33:24 +02:00
Gordon Bergling 066e393f8f libc: Fix a typo in a source code comment
- s/compnent/component/

MFC after:	3 days
2022-03-28 19:34:14 +02:00
Konstantin Belousov 6d06bc688e libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
Otherwise on mapper failure we goto error handler which expect
rpscoc_lock owned, but we do not.

PR:	261051
Reported by:	RyanCai <ryancaicse@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-01-09 07:36:06 +02:00
Konstantin Belousov 16b238b740 libc/rpc/getrpcent.c: Mark write-only variables as unused
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-29 17:39:50 +02:00
Gordon Bergling 0d55bc8eb2 rpc(3): Correct a few common typos in source code comments
- s/therfore/therefor/
- s/activte/active/

Obtained from:	NetBSD
MFC after:	3 days
2021-08-22 08:16:09 +02:00
Ceri Davies 1760799b4c Remove references to timed(8)
There are still references to timed(8) and timedc(8) in the base system,
which were removed in 2018.

PR: 255425
Reported by:	Ceri Davies <ceri at submonkey dot net>
Reviewed by:	ygy, gbe
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30232
2021-05-13 09:53:08 +02:00
Edward Tomasz Napierala 5299d64b2b libc: fix buffer overrun in getrpcport(3)
Reviewed By:	markj
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332
2021-01-31 21:42:02 +00:00
Brooks Davis 6671366a55 Fix -Wvoid-pointer-to-enum-cast warnings.
This pattern is used in callbacks with void * data arguments and seems
both relatively uncommon and relatively harmless.  Silence the warning
by casting through uintptr_t.

This warning is on by default in Clang 11.

Reviewed by:	arichardson
Obtained from:	CheriBSD (partial)
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24425
2020-04-15 18:15:58 +00:00
Mark Johnston a3a706387e Fix a use of an uninitialized pointer in xdr_rpcbs_rmtcalllist().
This appears to have been introduced in r173763.  Also fix the confusing
indentation that probably led to the bug in the first place.

PR:		243759
Diagnosed by:	martin@lispworks.com
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2020-02-05 16:10:09 +00:00
Konstantin Belousov 6b462d2762 Increase YPMAXRECORD to 16M to be compatible with Linux.
Since YP protocol definition uses the constant to declare
variable-size opaque byte strings, the change should be binary
compatible with existing installations which do not expose keys or
values larger than 1024 bytes.

All uses of local variables with YPMAXRECORD sizes were removed to
avoid insane stack use.  On the other hand, variables with static
lifetime should be fine and only result in increased VA use.

Glibc made same change, increasing the allowed length for keys and
values in YP to 16M, in 2013.

Reviewed by:	markj
Discussed with:	ian
Sponsored by:	Mellanox Technologies
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D20900
2019-08-12 20:27:33 +00:00
Brad Davis 34da9e3802 Fix CONFS to append the value in this case.
Approved by:	re (blanket, pkgbase), will (mentor)
2018-09-18 01:38:44 +00:00
Brad Davis 77e4a39103 Move rpc and netconfig to lib/libc/rpc/
This uses relative paths to make it more specific to avoid any potential
future problems with .PATH and leverages CONFS.

libc was picked as the destination location for these because of the syscalls
that use these files as the lowest level place they are referenced.

Approved by:	re (gjb), will (mentor)
Differential Revision:	https://reviews.freebsd.org/D17163
2018-09-17 19:20:50 +00:00
Eitan Adler 7ab39aa526 des_crypt.3: Fix typo.
Obtained from:	DragonflyBSD (a78d083cf561cf325e8f1a151251b8901159e2ce)
MFC After:	3 days
2018-03-07 09:31:27 +00:00
Pedro F. Giffuni 2614eccf45 su_data: correct macro expansion.
Protect su_data() users from strange macro expansion.

Obtained from:	linux libtirpc
2018-02-08 14:53:34 +00:00
Pedro F. Giffuni d915a14ef0 libc: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-25 17:12:48 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Pedro F. Giffuni df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Xin LI 94c5b2d124 Revert r300385 and r300624 which was false positive
reported by cppcheck.

dup_ncp() tries to allocate a buffer of MAXNETCONFIGLINE
as tmp, which is then assigned to p->nc_netid via strcpy,
so the free(p->nc_netid) would have correctly released
the memory in case nc_lookups() fails, therefore, the
allerged leak never existed.

MFC after:	3 days
2017-06-30 07:04:10 +00:00
Xin LI 091867a611 Fix use-after-free introduced in r300388.
In r300388, endnetconfig() was called on nc_handle which would release
the associated netconfig structure, which means tmpnconf->nc_netid
would be a use-after-free.

Solve this by doing endnetconfig() in return paths instead.

Reported by:	jemalloc via kevlo
Reviewed by:	cem, ngie (earlier version)
MFC after:	3 days
Differential Revision:    https://reviews.freebsd.org/D11288
2017-06-22 05:10:16 +00:00
Xin LI 6448ec89e7 * limit size of buffers to RPC_MAXDATASIZE
* don't leak memory
 * be more picky about bad parameters

From:

https://raw.githubusercontent.com/guidovranken/rpcbomb/master/libtirpc_patch.txt
https://github.com/guidovranken/rpcbomb/blob/master/rpcbind_patch.txt

via NetBSD.

Reviewed by:	emaste, cem (earlier version)
Differential Revision:	https://reviews.freebsd.org/D10922
MFC after:	3 days
2017-06-01 06:12:25 +00:00
Brooks Davis efa2501ed6 Support clnt_raw's use of FD_SETSIZE as a fake file descriptor.
Accomplish this by allocating space for it in __svc_xports and allowing
it to be registered.  The failure to allocate space was causing an
out-of-bounds read in svc_getreq_common().  The failure to register
caused PR 211804.

The bug was found with CHERI bounds checking.

PR:		211804
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Reviewed by:	ngie
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10528
2017-05-01 20:04:07 +00:00
Pedro F. Giffuni 9f36610f9e libc: provide some bounds-checking through reallocarray(3).
reallocarray(3) is a non portable extension that originated in OpenBSD.
Given that it is already in FreeBSD's libc it is useful for the cases
where reallocation involves a multiplication.

MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D9955
2017-03-12 16:03:34 +00:00
Pedro F. Giffuni 8e60fa95cb libc/rpc: replace comma with semicolon when pertinent.
Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

Detected with devel/coccinelle following a hint from DragonFlyBSD.

MFC after:	1 month
2016-08-09 19:20:53 +00:00
Bryan Drewery 77c7a21036 Use on crypto.x and rpc.x from the source tree.
This fixes the build when DESTDIR may be blank or not yet populated.
It also fixes reproducibility.

Submitted by:	brooks
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D6455
2016-06-28 19:53:16 +00:00
Pedro F. Giffuni 478eb9e9ca libc/rpc: Make use of some xdr_* macros. (part 2)
xdr_rpcproc, xdr_rpcprog and xdr_rpcvers were broken in older
versions of FreeBSD but fixed in r296394.  Give them some use
hoping they help make the code somewhat more readable.
2016-06-09 22:18:25 +00:00
Pedro F. Giffuni ea21823d9f libc/rpc: Make use of some xdr_* macros.
xdr_rpcprog and xdr_rpcvers were broken in older versions of FreeBSD
but were fixed in r296394. Give them some use hoping they help make
the code somewhat more readable.
2016-06-09 19:44:47 +00:00
Kevin Lo 88609a6a7a Fix the rpcb_getaddr() definition to match its declaration.
Submitted by:	Sebastian Huber <sebastian dot huber at embedded-brains dot de>
2016-06-09 14:33:00 +00:00
Enji Cooper 3304ba9d70 Test for strchr(3) returning NULL, not 0
MFC after: 3 days
Reported by: coccinelle
Sponsored by: EMC / Isilon Storage Division
2016-06-08 23:17:30 +00:00
Enji Cooper 8f5cc69027 Fix up r300385
I accidentally glossed over the fact that tmp is manipulated via strchr, so
if we tried to free `tmp` after r300385, it would have crashed.

Create a separate pointer (tmp2) to track the original allocation of `tmp`,
and free `tmp2` if `p->nc_lookups` can't be malloced

MFC after: 4 days
X-MFC with: r300385
Reported by: Coverity
CID: 1356026
Sponsored by: EMC / Isilon Storage Division
2016-05-24 19:52:05 +00:00
Enji Cooper 3c048026b5 Remove redundant NULLing of outbuf_pmap
If reallocf ever failed, outbuf_pmap would already be NULL

MFC after: 1 week
X-MFC with: r300620
Reported by: cem
Sponsored by: EMC / Isilon Storage Division
2016-05-24 18:53:06 +00:00