Commit Graph

4235 Commits

Author SHA1 Message Date
Dmitry Chagin
673bce11ce linux(4): Copyout actual size of addr to the user space in accept().
Differential Revision:	https://reviews.freebsd.org/D34727
2022-04-11 23:33:27 +03:00
Dmitry Chagin
bb0f644cd6 linux(4): Limit user-supplied sockaddr length in recvfrom().
Differential Revision:	https://reviews.freebsd.org/D34726
2022-04-11 23:32:28 +03:00
Dmitry Chagin
68bfaefb3d linux(4): Remove unnecessary PTRIN(). 2022-04-11 23:32:02 +03:00
Dmitry Chagin
cf312f799a linux(4): Handle SO_DOMAIN in getsockopt syscall.
Differential revision:	https://reviews.freebsd.org/D34714
2022-04-11 23:31:28 +03:00
Dmitry Chagin
bb46e9b510 linux(4): Prevent an attempt to copy an uninitialized source address.
PR:			259380
MFC after:		3 days
2022-04-11 23:29:45 +03:00
Fernando Apesteguía
0f2041a5b0 [linprocfs] add sys/kernel/random/boot_id
This file holds a UUID that is invariant for every boot. In our case, it is
invariant per mount.

PR:	262369
Reported by:	sodynet1@gmail.com
Approved by:	dchagin@
Differential Revision:	https://reviews.freebsd.org/D34860
2022-04-11 18:23:28 +02:00
Bjoern A. Zeeb
978f25e840 LinuxKPI: 802.11: add ieee80211_beacon_get_tim(), ieee80211_sn_sub()
Add a dummy implementation for ieee80211_beacon_get_tim().
Add the implementation for ieee80211_sn_sub().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-08 21:05:06 +00:00
Bjoern A. Zeeb
97f2e93a66 LinuxKPI: add ALIGN_DOWN()
Add ALIGN_DOWN as rounddown2() along ALIGN() which is implemented as
roundup2().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	manu, hselasky (now with less ())
Differential Revision: https://reviews.freebsd.org/D34844
2022-04-08 18:27:49 +00:00
Bjoern A. Zeeb
170acccf1e LinuxKPI: 802.11: further fix RSSI calculations
60970a328e did one half of the job
of making rssi relative to nf and numbers for radiotap were fine.
net80211 internally works with .5 dBm units thus we need to apply a
* 2 to the value we pass in to c_rssi;  leave a comment explaining.

Note: it is only ifconfig in user space which re-adjust it for printing
or contrib/wpa for calculations.  Other applications getting values
from kernel also have to apply the maths.

In collaboration with:	J.R. Oldroyd (fbsd opal.com)
Sponsored by:		The FreeBSD Foundation
MFC after:		3 days
2022-04-08 11:06:58 +00:00
Bjoern A. Zeeb
9df5f29caf LinuxKPI: skbuff: handle dev_alloc_skb() correctly
dev_alloc_skb() comapred to alloc_skb() reserves some headroom
at the beginning of the skb which is used by drivers.
Split the code for the two cases and reserve NET_SKB_PAD space,
which should at least be 32 octets.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-07 20:55:53 +00:00
Dmitry Chagin
0938d04a2c linux(4): Fix a typo in itimerspec conversion routine.
MFC after:	3 days
2022-04-06 17:40:00 +03:00
Warner Losh
132b00f906 linuxkpi: move io_mapping_create_wc to .c
Move io_mapping_create_wc to .c because it encodes the size of struct
io_mapping so we move this from the client module to the linuxkpi
module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34776
2022-04-04 23:06:37 -06:00
Warner Losh
2bf3361d56 linuxkpi: Move lkpi_pcim_iomap_devres_find to .c file
lkpi_pcim_iomap_devres_find encodes the size of struct pcim_iomap_devres
in the code, so move from .h to .c to move from client driver to
linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34775
2022-04-04 23:06:29 -06:00
Warner Losh
36b5c44002 linuxkpi: Move pci_alloc_irq_vectors to .c file
pci_alloc_irq_vectors encodes the size of struct msix_entry
into its code. Move from .h to .c to move this knowledge from
client modules to linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34774
2022-04-04 23:06:21 -06:00
Warner Losh
1cdb25340f linuxkpi: Move pci_request_region and _lkpi_pci_iomap into .c
Both pci_request_region and _lkpi_pci_iomap encode the size of struct
pci_mmio_region into their code. Move from .h to .c files to move that
knowledge from the client drivers into the linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34773
2022-04-04 23:06:14 -06:00
Warner Losh
3ea682e21e linuxkpi: Move lkpi_pci_devres_get_alloc into .c file
lkpi_pci_devres_get_alloc encodes the struct pci_devres into its
code. Move from .h file to .c file to move this knowledge into linuxkpi
module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34772
2022-04-04 23:06:06 -06:00
Warner Losh
aca0bcbca3 linuxkpi: Move cdev_alloc into .c file
Move cdev_alloc into linux_compat.c since it encodes the size of struct
linux_cdev into the client modules otherwise.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34771
2022-04-04 23:05:59 -06:00
Warner Losh
58e6719ca0 linuxkpi: Remove write only variable from lkpi_iicbb_reset
Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34770
2022-04-04 23:05:52 -06:00
Warner Losh
1341ac9f9c linuxkpi: Move class_create to .c file
class_create encodes the size of struct class into the generated
code. Move from .h file to .c file to move this knowledge from the
client modules that call this into the linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34769
2022-04-04 23:05:43 -06:00
Warner Losh
702b687503 linuxkpi: Move device_create_groups_vargs to linux_compat.c
device_create_groups_vargs encodes the size of struct device. Move
definition from .h to .c to move this size into the linuxkpi module
rather than encoding it in all client driver modules.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34768
2022-04-04 23:05:36 -06:00
Warner Losh
36929b5584 linuxkpi: move kobject_create to .c file
kobject_create knows the size of struct kobject. Move it to
linux_compat.c so this knowledge is confined to the loadable module and
not the clients.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34767
2022-04-04 23:05:26 -06:00
Bjoern A. Zeeb
e86707418c LinuxKPI: PCI: add counter for linux_dma_map_phys_common() errors
LinuxKPI is asking for single-segment mappings.  Some (wireless) drivers
are using this to map multi-pages and our busdma framework is not very
friendly to that as single-segments [D31823].  Add a counter so we can
track when this happens to gather more information.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D34715
2022-04-03 23:05:47 +00:00
Bjoern A. Zeeb
60970a328e LinuxKPI: 802.11: fix RSSI (and NF)
As in 4a22cd6c4e nf and rss should be
signed and not unsigned.  Change the types in the header and while
here change a magic number to a define as done elsewhere (value does
not change).

When calculating c_rssi we need to make it relative so subtract nf.
And while here improve the debug output.

This will hopefully fix ifconfig wlanN list scan S:N output which
tools use to chose a BSSID and help net80211 internal calculations.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-01 22:31:23 +00:00
Dmitry Chagin
bafe3b8804 linsysfs: plug set-but-not-used vars.
MFC after:	2 weeks
2022-03-31 23:49:26 +03:00
Dmitry Chagin
09d60bfae5 linux(4): Cleanup empty lines.
MFC after:		2 weeks
2022-03-31 21:23:12 +03:00
Dmitry Chagin
4e1e83461b linux(4): Fix KASSERT message.
MFC after:		2 weeks
2022-03-31 21:22:31 +03:00
Dmitry Chagin
d6ccce0aa2 linux(4): readlink should fail if bufzis <= 0.
MFC after:		2 weeks
2022-03-31 21:21:41 +03:00
Dmitry Chagin
b7df7b987e linprocfs: Add /proc/self/oom_score_adj.
To avoid annoyng messages from LTP test suites add the simple
implementation of /proc/self/oom_score_adj which is do nothing.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D34710
MFC after:		2 weeks
2022-03-31 21:04:44 +03:00
Dmitry Chagin
d5dc757e84 linux(4): Add compat.linux32.emulate_i386 knob.
Historically 32-bit Linuxulator under amd64 emulated the real i386
behavior. Since 3d8dd983 the old i386 Linux world can't be used under
amd64 Linuxulator as it don't know anything about amd64 machine (which
is returned now by newuname() syscall). So, add a knob to allow to swith
the behavior and use i386 Linux binaries on amd64.
Set knob to the new behavior as I think this is common to the modern
Linux distros.

Reviewed by:		Pau Amma (doc), emaste
Differential revision:	https://reviews.freebsd.org/D34708
MFC after:		2 weeks
2022-03-31 21:01:09 +03:00
Dmitry Chagin
099fa2feb3 linux(4): Fixup miscalculation of d_off of struct dirent in getdents() syscalls.
Avoid calculating d_off value as it is specific to the underlying filesystem
and can be used by others API, like lseek(), seekdir() as input offset.

Differential revision:  https://reviews.freebsd.org/D31551
MFC after:		2 weeks
2022-03-31 20:50:09 +03:00
Dmitry Chagin
9103c5582a linux(4): wait4() returns ESRCH if pid is INT_MIN.
Weird and undocumented patch was added to the Linux kernel in 2017,
fixes wait403 LTP test.

MFC after:	2 weeks
2022-03-31 20:49:39 +03:00
Dmitry Chagin
5bcf0f7cd7 linux(4): Rid unused defines from linux_mib.
Reviewed by:		trasz
Differential revision:  https://reviews.freebsd.org/D31591
MFC after:		2 weeks
2022-03-31 20:45:12 +03:00
Dmitry Chagin
4e3aefb923 linux(4): Fixup waitid handling P_PGID idtype.
Since Linux 5.4, if id is zero, then wait for any child that is in the same
process grop as the caller's process group.

Differential revision:  https://reviews.freebsd.org/D31567
MFC after:		2 weeks
2022-03-31 20:44:00 +03:00
Dmitry Chagin
be1e4a0bdf linux(4): Return ENOSYS for unsupported P_PIDFD waitid idtype.
Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31559
MFC after:		2 weeks
2022-03-31 20:42:42 +03:00
Dmitry Chagin
c7ef7c3fac linux(4): Add support for __WALL wait option bit.
As FreeBSD does not have __WALL option bit analogue explicitly set all
possible option bits to emulate Linux __WALL wait option bit.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31555
MFC after:		2 weeks
2022-03-31 20:42:03 +03:00
Dmitry Chagin
d7e1e138ec linux(4): Fixup options value validation in linux_waitid().
Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31554
MFC after:		2 weeks
2022-03-31 20:41:19 +03:00
Dmitry Chagin
2fd480b318 linux(4): Eliminate bogus options value check validation.
The kernel do it for us.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31553
MFC after:		2 weeks
2022-03-31 20:41:02 +03:00
Dmitry Chagin
0c6b1ff7de linux(4): Consolidate wait* facility into linux_common_wait().
Also fix bug in waitid() implementation, use wru_self not wru_children.

Differential revision:  https://reviews.freebsd.org/D31552
MFC after:		2 weeks
2022-03-31 20:40:22 +03:00
Bjoern A. Zeeb
86220d3cbd LinuxKPI: 802.11: fix compat code for i386
Compiling another driver on i386 revealed two problems:
- ieee80211_tx_info.status.status_driver_data space needs to be
  calculated.  While a pointer is 32bit vm_paddr_t is 64 bit on i386
  so we didn't fit more than one of these in but needed more space.
- the arguments to ieee80211_txq_get_depth() are expected to
  unsigned long and not uint64_t.

No user noticable changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-03-31 17:29:53 +00:00
Ed Maste
8299f9a5c1 compat32: add size CTASSERTs for non-amd64 cases
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34712
2022-03-30 13:25:25 -04:00
Ed Maste
f90cd1ae30 Clear non-x86 compat stat syscall kernel stack memory disclosure
32-bit architectures other than i386 have 64-bit time_t which results
in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes
of padding.  Zero the padding holes in struct stat32 and struct
freebsd11_stat32.

i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding.

Found by inspection, prompted by a report by Reno Robert of Trend Micro
Zero Day Initiative.  The originally reported issue (ZDI-CAN-14538) is
already fixed in all supported FreeBSD versions (it was addressed
incidentally as part of the 64-bit inode project).

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34709
2022-03-29 16:10:04 -04:00
Emmanuel Vadot
1aca8a6ec6 linuxkpi: Add for_each_sgtable_dma_sg and for_each_sgtable_dma_page
Variants of for_each_sg/for_each_sg_dma_page but they operate on sgtable
structs.
Needed by drm v5.10

MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-03-29 13:19:32 +02:00
Emmanuel Vadot
1acf9b2770 linuxkpi: Implement dma_max_mapping_size
Simply returns SCATTERLIST_MAX_SEGMENT.
Needed by drm v5.10

MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-03-29 13:19:32 +02:00
Brooks Davis
8601fca789 sysent: regen for syscallarg_t 2022-03-28 19:43:03 +01:00
Emmanuel Vadot
2192bc3255 linuxkpi: Change irq_work_queue to return a bool
This was changed in Linux v5.10

MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co .KG
2022-03-28 18:31:31 +02:00
Emmanuel Vadot
17ee6aca65 linuxkpi: Add llnode member in struct irq_work
This was added in Linux v5.8 and started to be used in drm code in v5.9

MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-03-28 14:49:39 +02:00
Eric van Gyzen
aca2a7faca stack_zero is not needed before stack_save
The man page was recently clarified to commit to this contract.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-03-25 20:10:38 -05:00
Dmitry Chagin
ff39d74aa9 linux(4): Add AT_NO_AUTOMOUNT to statx.
Specific to Linux AT_NO_AUTOMOUNT flag tells the kernel to not automount the
terminal component of pathname if it is a directory that is an automount point.
As it is the default for FreeBSD silencly ignore this flag.

glibc-2.34 uses this flag in the stat64 system calls which is used by i386.

Reviewed by:		trasz
Differential revision:  https://reviews.freebsd.org/D31524
MFC after:		2 weeks
2022-03-25 17:54:23 +03:00
Dmitry Chagin
aae8ae5ea5 linprocfs: Eliminate bogus comment (KSE).
Reviewed by:		trasz, emaste
Differential revision:	https://reviews.freebsd.org/D31525
MFC after:		2 weeks
2022-03-25 17:53:08 +03:00
Bjoern A. Zeeb
9d9ba2b79b LinuxKPI: 802.11: cleanup debugging
Cleanup some debugging.  Rename the global variable to be less
generic.  Hide all debugging behind #ifdef for now and turn off.
Rename the debugging sysctl so we can start adding more to the
subtree.

There is a need to change that wildly grown infrastructure into
something more homogenic soon but this should do for 13.1.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-03-24 19:13:45 +00:00