| #
1390bba4
|
| 16-Nov-2025 |
Mark Johnston <markj@FreeBSD.org> |
file: Add a fdclose method
Consider a program that creates a unix socket pair, transmits both sockets from one to the other using an SCM_RIGHTS message, and then closes both sockets without external
file: Add a fdclose method
Consider a program that creates a unix socket pair, transmits both sockets from one to the other using an SCM_RIGHTS message, and then closes both sockets without externalizing the message. unp_gc() is supposed to handle cleanup, but it is only triggered by uipc_detach(), which runs when a unix socket is destroyed. Because the two sockets are internalized, their refcounts are positive, so uipc_detach() isn't called.
As a result, a userspace program can create an unbounded amount of garbage without triggering reclaim. Let's trigger garbage collection whenever a unix socket is close()d. To implement this, add new a fdclose file op and protocol op, and implement them accordingly. Since mqueuefs has a hack to hook into the file close path, convert it to use the new op as well.
Now, userspace can't create garbage without triggering reclamation.
Reviewed by: glebius, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D53744
show more ...
|
| #
9c35c447
|
| 13-Oct-2025 |
Zhenlei Huang <zlei@FreeBSD.org> |
kern: Use proper prototype for SYSINIT functions
MFC after: 1 week
|
| #
aba6f332
|
| 30-Apr-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: provide protocol method pr_kqfilter
Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D48919
|
| #
4a7f4f28
|
| 10-Feb-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: make pr_aio_queue the default method
Call it directly instead of each time calling pr_aio_queue_notsupp() and then doing the actual job. The only user of non default method was cxgbe(4).
sockets: make pr_aio_queue the default method
Call it directly instead of each time calling pr_aio_queue_notsupp() and then doing the actual job. The only user of non default method was cxgbe(4). It calls now into the default method in case of own method failure. This preserves existing behavior.
Reviewed by: markj, jhb Differential Revision: https://reviews.freebsd.org/D48863
show more ...
|
| #
b0580c7a
|
| 03-Feb-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: remove empty shim function sopoll()
|
| #
815f2a61
|
| 03-Feb-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: removed unused argument from sopoll()
|
| #
ef9ffb85
|
| 25-Nov-2024 |
Mark Johnston <markj@FreeBSD.org> |
kern: Make fileops and filterops tables const where possible
No functional change intended.
MFC after: 1 week
|
| #
bfd03046
|
| 03-Nov-2024 |
Mark Johnston <markj@FreeBSD.org> |
unix: Add support for atomically setting the socket mode
With this patch, it is possible to call fchmod() on a unix socket prior to binding it to the filesystem namespace, so that the mode is set at
unix: Add support for atomically setting the socket mode
With this patch, it is possible to call fchmod() on a unix socket prior to binding it to the filesystem namespace, so that the mode is set atomically. Without this, one has to call chmod() after bind(), leaving a window where threads can connect to the socket with the default mode. After bind(), fchmod() reverts to failing with EINVAL.
This interface is copied from Linux.
The behaviour of fstat() is unmodified, i.e., it continues to return the mode as set by soo_stat().
PR: 282393 Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D47361
show more ...
|
| #
1a8d1764
|
| 29-Mar-2024 |
Gleb Smirnoff <glebius@FreeBSD.org> |
inpcb: fully retire inp_ppcb pointer
Before a protocol specific control block started to embed inpcb in self (see 0aa120d52f3c, e68b3792440c, 483fe96511ec) this pointer used to point at it.
Retain
inpcb: fully retire inp_ppcb pointer
Before a protocol specific control block started to embed inpcb in self (see 0aa120d52f3c, e68b3792440c, 483fe96511ec) this pointer used to point at it.
Retain kf_sock_inpcb field in the struct kinfo_file in <sys/user.h>. The exp-run detected a minimal use of the field in ports: * sysutils/lsof - patched upstream * net-mgmt/netdata - patch accepted upstream * emulators/qemu-user-static - upstream master branch seems not using the field anymore We can keep the field around for some time, but eventually it may be reused for something else.
PR: 277659 (exp-run) Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D44491
show more ...
|
| #
f28526e9
|
| 19-Jan-2024 |
Konstantin Belousov <kib@FreeBSD.org> |
kcmp(2): implement for generic file types
Reviewed by: brooks, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D43518
|
| #
0fac350c
|
| 30-Nov-2023 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: don't malloc/free sockaddr memory on getpeername/getsockname
Just like it was done for accept(2) in cfb1e92912b4, use same approach for two simplier syscalls that return socket addresses.
sockets: don't malloc/free sockaddr memory on getpeername/getsockname
Just like it was done for accept(2) in cfb1e92912b4, use same approach for two simplier syscalls that return socket addresses. Although, these two syscalls aren't performance critical, this change generalizes some code between 3 syscalls trimming code size.
Following example of accept(2), provide VNET-aware and INVARIANT-checking wrappers sopeeraddr() and sosockaddr() around protosw methods.
Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D42694
show more ...
|
| #
fdafd315
|
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: 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.
Remov
sys: 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
show more ...
|
| #
29363fb4
|
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: 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 s
sys: 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
show more ...
|
| #
685dc743
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
ac4e3a27
|
| 14-Dec-2022 |
Andrew Gallatin <gallatin@FreeBSD.org> |
Unbreak the build when MAC is not defined
7a2c93b86ef7 removed the use of "error" when MAC was not defined, resulting in an unused variable error.
Sponsored by: Netflix Reviewed by: jhb
|
| #
7a2c93b8
|
| 14-Dec-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: provide sousrsend() that does socket specific error handling
Sockets have special handling for EPIPE on a write, that was spread out into several places. Treating transient errors is also
sockets: provide sousrsend() that does socket specific error handling
Sockets have special handling for EPIPE on a write, that was spread out into several places. Treating transient errors is also special - if protocol is atomic, than we should ignore any changes to uio_resid, a transient error means the write had completely failed (see d2b3a0ed31e).
- Provide sousrsend() that expects a valid uio, and leave sosend() for kernel consumers only. Do all special error handling right here. - In dofilewrite() don't do special handling of error for DTYPE_SOCKET. - For send(2), write(2) and aio_write(2) call into sousrsend() and remove error handling for kern_sendit(), soo_write() and soaio_process_job().
PR: 265087 Reported by: rz-rpi03 at h-ka.de Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35863
show more ...
|
| #
e3885a78
|
| 26-Aug-2022 |
John Baldwin <jhb@FreeBSD.org> |
soo_stat: Ensure error is always initialized.
In kernels without MAC, error is not set for sockets whose protocol layer does not implement the pr_sense hook.
Reported by: Jenkins (powerpc kernel bu
soo_stat: Ensure error is always initialized.
In kernels without MAC, error is not set for sockets whose protocol layer does not implement the pr_sense hook.
Reported by: Jenkins (powerpc kernel builds) Fixes: 7c04ca1fad67 sockets: for stat(2) on a socket don't report hiwat as block size
show more ...
|
| #
7c04ca1f
|
| 26-Aug-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: for stat(2) on a socket don't report hiwat as block size
The code appeared in d8392c6c39eb with not good explanation. It is very unlikely any software in the world needs that.
Differentia
sockets: for stat(2) on a socket don't report hiwat as block size
The code appeared in d8392c6c39eb with not good explanation. It is very unlikely any software in the world needs that.
Differential revision: https://reviews.freebsd.org/D36283
show more ...
|
| #
e7d02be1
|
| 17-Aug-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
protosw: refactor protosw and domain static declaration and load
o Assert that every protosw has pr_attach. Now this structure is only for socket protocols declarations and nothing else. o Merge
protosw: refactor protosw and domain static declaration and load
o Assert that every protosw has pr_attach. Now this structure is only for socket protocols declarations and nothing else. o Merge struct pr_usrreqs into struct protosw. This was suggested in 1996 by wollman@ (see 7b187005d18ef), and later reiterated in 2006 by rwatson@ (see 6fbb9cf860dcd). o Make struct domain hold a variable sized array of protosw pointers. For most protocols these pointers are initialized statically. Those domains that may have loadable protocols have spacers. IPv4 and IPv6 have 8 spacers each (andre@ dff3237ee54ea). o For inetsw and inet6sw leave a comment noting that many protosw entries very likely are dead code. o Refactor pf_proto_[un]register() into protosw_[un]register(). o Isolate pr_*_notsupp() methods into uipc_domain.c
Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36232
show more ...
|
| #
8c309d48
|
| 17-Jun-2022 |
Damjan Jovanovic <damjan.jov@gmail.com> |
struct kinfo_file changes needed for lsof to work using only usermode APIs`
Add kf_pipe_buffer_[in/out/size] fields to kf_pipe, and populate them.
Add a kf_kqueue struct to the kf_un union, to allo
struct kinfo_file changes needed for lsof to work using only usermode APIs`
Add kf_pipe_buffer_[in/out/size] fields to kf_pipe, and populate them.
Add a kf_kqueue struct to the kf_un union, to allow querying kqueue state, and populate it.
Populate the kf_sock_rcv_sb_state and kf_sock_snd_sb_state fields in kf_sock for INET/INET6 sockets, and populate all other fields for all transport layer protocols, not just TCP.
Bump __FreeBSD_version.
Differential revision: https://reviews.freebsd.org/D34184 Reviewed by: jhb, kib, se MFC after: 1 week
show more ...
|
| #
a8e286bb
|
| 03-Jun-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: use socket buffer mutexes in struct socket directly
Convert more generic socket code to not use sockbuf compat pointer. Continuation of 4328318445a.
|
| #
f0837393
|
| 31-May-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
soo_aio_*: use socket buffer mutexes in struct socket directly
A miss from commit 4328318445a.
|
| #
43283184
|
| 12-May-2022 |
Gleb Smirnoff <glebius@FreeBSD.org> |
sockets: use socket buffer mutexes in struct socket directly
Since c67f3b8b78e the sockbuf mutexes belong to the containing socket, and socket buffers just point to it. In 74a68313b50 macros that a
sockets: use socket buffer mutexes in struct socket directly
Since c67f3b8b78e the sockbuf mutexes belong to the containing socket, and socket buffers just point to it. In 74a68313b50 macros that access this mutex directly were added. Go over the core socket code and eliminate code that reaches the mutex by dereferencing the sockbuf compatibility pointer.
This change requires a KPI change, as some functions were given the sockbuf pointer only without any hint if it is a receive or send buffer.
This change doesn't cover the whole kernel, many protocols still use compatibility pointers internally. However, it allows operation of a protocol that doesn't use them.
Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35152
show more ...
|
| #
36fb3722
|
| 13-Apr-2022 |
John Baldwin <jhb@FreeBSD.org> |
kern: Move variables only used for MAC under #ifdef MAC.
|
| #
af40f9bf
|
| 14-Dec-2021 |
Mateusz Guzik <mjg@FreeBSD.org> |
socket: plug set-but-not-used vars
Sponsored by: Rubicon Communications, LLC ("Netgate")
|