#
bcf4a7c7 |
| 26-Dec-2023 |
Mark Johnston <markj@FreeBSD.org> |
mps: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin() and related functions, start checking for errors from copyout() in the mps(4
mps: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin() and related functions, start checking for errors from copyout() in the mps(4) user command handler. This should make it easier to catch bugs.
Reviewed by: imp, asomers MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D43176
show more ...
|
Revision tags: release/14.0.0, release/13.2.0 |
|
#
7d154c4d |
| 22-Feb-2023 |
Alan Somers <asomers@FreeBSD.org> |
mprutil: "fix user reply buffer (64)..." warnings
Depending on the card's firmware version, it may return different length responses for MPI2_FUNCTION_IOC_FACTS. But the first part of the response
mprutil: "fix user reply buffer (64)..." warnings
Depending on the card's firmware version, it may return different length responses for MPI2_FUNCTION_IOC_FACTS. But the first part of the response contains the length of the rest, so query it first to get the length and then use that to size the buffer for the full response.
Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST. It only worked by luck before.
PR: 264848 Reported by: Julien Cigar <julien@perdition.city> MFC after: 1 week Sponsored by: Axcient Reviewed by: scottl, imp Differential Revision: https://reviews.freebsd.org/D38739
show more ...
|
#
685dc743 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
95ee2897 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
#
72aad3f9 |
| 01-Mar-2023 |
Alan Somers <asomers@FreeBSD.org> |
Fix kernel memory disclosures in mpr and mps
In every mpr and mps ioctl that copies kernel data to userland, validate that the requested length does not exceed the size of the kernel's buffer.
Note
Fix kernel memory disclosures in mpr and mps
In every mpr and mps ioctl that copies kernel data to userland, validate that the requested length does not exceed the size of the kernel's buffer.
Note that all of these ioctls already required root access.
MFC after: 2 weeks Sponsored by: Axcient Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D38842
show more ...
|
Revision tags: release/12.4.0, release/13.1.0 |
|
#
8276c414 |
| 28-Mar-2022 |
Ed Maste <emaste@FreeBSD.org> |
mpr/mps/mpt: verify cfg page ioctl lengths
*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a buffer of a caller-specified size, but copied to it a fixed size header. Add checks
mpr/mps/mpt: verify cfg page ioctl lengths
*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a buffer of a caller-specified size, but copied to it a fixed size header. Add checks that the size is at least the required minimum.
Note that the device nodes are owned by root:operator with 0640 permissions so the ioctls are not available to unprivileged users.
This change includes suggestions from scottl, markj and mav.
Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative; scottl reported the third case in mpt. Same issue found in mpr and mps after discussion with imp.
Reported by: Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative Reviewed by: imp, mav MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34692
show more ...
|
#
e30fceb8 |
| 02-Feb-2022 |
Warner Losh <imp@FreeBSD.org> |
mps: Use 64-bit chain structures
According to Broadcom, mixing 64-bit SGEs with 32-bit chain entries can lead to IOC Fault code 0x40000d04. This fault code has been observed to suddenly increase on
mps: Use 64-bit chain structures
According to Broadcom, mixing 64-bit SGEs with 32-bit chain entries can lead to IOC Fault code 0x40000d04. This fault code has been observed to suddenly increase on certain machines when the OCA firmware images are deployed. The hardware interprets all elements of a 64-bit SGE, even ones marked as 32-bit. Depending on the other bits, this will just work, but sometimes generate the above fault. Broadcom recommends this practice, and the Linux and NetBSD drivers follow it.
Rework the chaining code to use MPI2_SGE_CHAIN64 instead of MPI2_SGE_CHAIN32. Adjust MPS_SGC_SIZE from 8 to 12 to match the size of the new structure. Flag the structure as being 64-bits now. Since MPS_SGE64_SIZE and MPS_SGC_SIZE are the same now, mps_push_sge could be simplified (after the same fashion of mpr). The different number of cases collapse to whether or not there's room for the segments and if not we need a chain, however these changes haven't been made yet as the current code handles those cases properly with the new defines.
Made chain_busaddr 64-bits, even though we ask for all allocations to be below 4GB for this tag. Use it to set both parts of the CHAIN64 address rather than baking the 4GB assumption. Add asserts around the allocation to detect and BUSDMA bugs in allocation.
Remove asserts and associated comment in mpi_pre_fw_download and mpi_pre_fw_upload. The code does not, it seems, depend on this invariant. The mpr driver has similar code, no asserts and also doesn't depend on this.
Adjust comments to reflect the updated size.
Sponsored by: Netflix Reviewed by: scottl, mav Differential Revision: https://reviews.freebsd.org/D34016
show more ...
|
Revision tags: release/12.3.0, release/13.0.0 |
|
#
adc0dcc3 |
| 08-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
mpr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl
The device mapping table contains sc->max_devices entries, so only indices in [0, sc->max_devices) are valid.
MFC after: 3 days Sponsored b
mpr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl
The device mapping table contains sc->max_devices entries, so only indices in [0, sc->max_devices) are valid.
MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27964
show more ...
|
#
de828a91 |
| 08-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
mpr, mps: Fix a stack buffer overflow in the user passthru ioctl
Previously we copied in the request into a stack-allocated structure that could be smaller than the request size. Furthermore, we ch
mpr, mps: Fix a stack buffer overflow in the user passthru ioctl
Previously we copied in the request into a stack-allocated structure that could be smaller than the request size. Furthermore, we checked the request size only after doing the copyin.
Fix this by allocating a buffer to hold the request, then copying the buffer's contents into a command descriptor. This is a bit heavy-handed but I expect the overhead will not be noticeable. The approach of coping the header in first is susceptible to TOCTOU problems.
Reviewed by: imp Reported by: maxpl0it@protonmail.com MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27963
show more ...
|
Revision tags: release/12.2.0 |
|
#
74c781ed |
| 14-Sep-2020 |
Scott Long <scottl@FreeBSD.org> |
Refine the busdma template interface. Provide tools for filling in fields that can be extended, but also ensure compile-time type checking. Refactor common code out of arch-specific implementations
Refine the busdma template interface. Provide tools for filling in fields that can be extended, but also ensure compile-time type checking. Refactor common code out of arch-specific implementations. Move the mpr and mps drivers to this new API. The template type remains visible to the consumer so that it can be allocated on the stack, but should be considered opaque.
show more ...
|
#
1002529e |
| 12-Sep-2020 |
Scott Long <scottl@FreeBSD.org> |
Convert the mps driver to use busdma templates
|
#
742c5f20 |
| 02-Sep-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
mps: clean up empty lines in .c and .h files
|
#
c7aa572c |
| 31-Jul-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
#
17996960 |
| 31-Jul-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r363583 through r363738.
|
#
d2a5f081 |
| 27-Jul-2020 |
Mark Johnston <markj@FreeBSD.org> |
mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK).
PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.f
mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK).
PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25766
show more ...
|
Revision tags: release/11.4.0 |
|
#
562894f0 |
| 14-Apr-2020 |
Brooks Davis <brooks@FreeBSD.org> |
Centralize compatability translation macros.
Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h and replace existing definitation with includes where required. This eliminates d
Centralize compatability translation macros.
Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h and replace existing definitation with includes where required. This eliminates duplicate code and allows Linux and FreeBSD compatability headers to be included in the same files.
Input from: cem, jhb Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24275
show more ...
|
Revision tags: release/12.1.0, release/11.3.0 |
|
#
0269ae4c |
| 06-Jun-2019 |
Alan Somers <asomers@FreeBSD.org> |
MFHead @348740
Sponsored by: The FreeBSD Foundation
|
#
1a15d60d |
| 30-May-2019 |
Alexander Motin <mav@FreeBSD.org> |
Fix busy status leak in case of incorrect passthrough args.
MFC after: 1 week
|
#
808a5e94 |
| 01-Jan-2019 |
Scott Long <scottl@FreeBSD.org> |
Port over the SCSI sense handling fix from mpr(4) in r342528, and fix whitespace to match.
|
#
b7f1ee79 |
| 24-Dec-2018 |
Scott Long <scottl@FreeBSD.org> |
First step in refactoring and fixing the error recovery and task management code in the mpr and mps drivers. Eliminate duplicated code and fix some comments.
|
Revision tags: release/12.0.0, release/11.2.0 |
|
#
6469bdcd |
| 06-Apr-2018 |
Brooks Davis <brooks@FreeBSD.org> |
Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is close
Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options.
Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures.
Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files.
Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941
show more ...
|
#
96410703 |
| 06-Feb-2018 |
Scott Long <scottl@FreeBSD.org> |
Cache the value of the request and reply frame size since it's used quite a bit in the normal operation of the driver. Covert it to represent bytes instead of 32bit words. Fix what I believe to be
Cache the value of the request and reply frame size since it's used quite a bit in the normal operation of the driver. Covert it to represent bytes instead of 32bit words. Fix what I believe to be is a bug in this respect with the Tri-mode cards.
Sponsored by: Netflix
show more ...
|
#
e2997a03 |
| 06-Feb-2018 |
Kenneth D. Merry <ken@FreeBSD.org> |
Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.
In mp{r,s}_diag_register(), which is used to register diagnostic buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.
There w
Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.
In mp{r,s}_diag_register(), which is used to register diagnostic buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.
There were several issues here: o No checking of the bus_dmamap_load() return value. If the load failed or got deferred, mp{r,s}_diag_register() continued on as if nothing had happened. We now check the return value and bail out if it fails.
o No waiting for a deferred load callback. bus_dmamap_load() calls a supplied callback when the mapping is done. This is generally done immediately, but it can be deferred. mp{r,s}_diag_register() did not check to see whether the callback was already done before proceeding on. We now sleep until the callback is done if it is deferred.
o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the memory is allocated and loaded. This is necessary on some platforms to synchronize host memory that is going to be updated by a device.
Both drivers would also panic if the firmware was reinitialized while a diagnostic buffer operation was in progress. This fixes that problem as well. (The driver will reinitialize the firmware in various circumstances, but the problem I ran into was that the firmware would generate an IOC Fault due to a PCIe error.)
mp{r,s}var.h: Add a new structure, struct mpr_busdma_context, that is used for deferred busdma load callbacks.
Add a prototype for mp{r,s}_memaddr_wait_cb(). mp{r,s}.c: Add a new busdma callback function, mp{r,s}_memaddr_wait_cb(). This provides synchronization for callers that want to wait on a deferred bus_dmamap_load() callback.
mp{r,s}_user.c: In bus_dmamap_register(), add a call to bus_dmamap_sync() with the BUS_DMASYNC_PREREAD flag set after an allocation is loaded.
Also, check the return value of bus_dmamap_load(). If it fails, bail out. If it is EINPROGRESS, wait for the callback to happen. We use an interruptible sleep (msleep with PCATCH) and let the callback clean things up if we get interrupted.
In mpr_diag_read_buffer() and mps_diag_read_buffer(), call bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying the data out to make sure the data is in stable storage.
In mp{r,s}_post_fw_diag_buffer() and mp{r,s}_release_fw_diag_buffer(), check the reply to see whether it is NULL. It can be NULL (and the command non-NULL) if the controller gets reinitialized while we're waiting for the command to complete but the driver structures aren't reallocated. The driver structures generally won't be reallocated unless there is a firmware upgrade that changes one of the IOCFacts.
When freeing diagnostic buffers in mp{r,s}_diag_register() and mp{r,s}_diag_unregister(), zero/NULL out the buffer after freeing it. This will prevent a duplicate free in some situations.
Sponsored by: Spectra Logic Reviewed by: mav, scottl MFC after: 1 week Differential Revision: D13453
show more ...
|
#
82725ba9 |
| 23-Nov-2017 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Merge ^/head r325999 through r326131.
|
#
7282444b |
| 20-Nov-2017 |
Pedro F. Giffuni <pfg@FreeBSD.org> |
sys/dev: 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
sys/dev: 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.
show more ...
|