| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nvlist_check_header() validated nvlh_size for overflow before
performing conversion. An mallicous user can set
NV_FLAG_BIG_ENDIAN in the header and craft nvlh_size so that
the orginall value passes the check, but after the conversion the
sizeof(nvlist_header) + size can overflow.
This can lead to a heap buffer overflow.
Approved by: so
Security: FreeBSD-SA-26:17.libnv
Security: CVE-2026-35547
Fixes: 36fa90dbde0060aacb5677d0b113ee168e839071
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56342
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A string array is represented by a set of nul-terminated strings
concatenated together. For each string, we check to see if there's a
nul terminator at the end, taking care to avoid going past the end of
the buffer. However, the code fails to handle the possibility that
size == 0 at the end of an iteration, leading to underflow.
Fix the length check.
Reported by: Ilja van Sprundel <ivansprundel@ioactive.com>
Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53069
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Suppose an nvlist nvl belongs to a parent nvlist or nvlist array. In
this case, nvl contains a pointer to its container. This trips up
nvlist_send(nvl) and nvlist_dump(nvl), which intuitively should only
operate on nvl and its nvpairs. In particular, both of these functions
will traverse to nvl's parent and start sending/dumping the parent's
nvpairs, which results in assertion failures or nonsensical output,
respectively.
Reviewed by: oshogbo
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D52360
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Switch to using sys/stdarg.h for va_list type and va_* builtins.
Make an attempt to insert the include in a sensible place. Where
style(9) was followed this is easy, where it was ignored, aim for the
first block of sys/*.h headers and don't get too fussy or try to fix
other style bugs.
Reviewed by: imp
Exp-run by: antoine (PR 286274)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
|
| |
|
|
| |
Reported by: Milosz Kaniewski <milosz.kaniewski@gmail.com>
|
| |
|
|
| |
Differential Revision: https://reviews.freebsd.org/D46131
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
During unpacking, we ensure that we do not read beyond the
declared size. However, unpack uses a function that copies
null-terminated strings. Prior to this commit, if the last string
was not null-terminated, it could result in copying data into a
buffer smaller than the allocated size.
Security: FreeBSD-24:09.libnv
Security: CVE-2024-45288
Security: CAP-03
Reported by: Synacktiv
Sponsored by: The Alpha-Omega Project
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46138
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ensure that the calculation of size of array doesn't
overflow.
Security: FreeBSD-24:09.libnv
Security: CVE-2024-45287
Security: CAP-02
Reported by: Synacktiv
Reported by: Taylor R Campbell (NetBSD)
Sponsored by: The Alpha-Omega Project
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46131
|
| |
|
|
|
|
|
|
|
| |
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
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When SOCK_DGRAM is used, a portion of the datagram is discarded during
the initial recv() when getting the nvlist_header.
To workaround this, use MSG_PEEK for the initial recv() when using a
datagram socket.
Add tests for SOCK_DGRAM with nvlist_send()/nvlist_recv().
Differential Revision: https://reviews.freebsd.org/D32722
|
| |
|
|
| |
Differential Revision: https://reviews.freebsd.org/D32721
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a nvlist(9) is converted into a binary buffer by nvlist_pack(9),
the host endianness is encoded in the nvlist_header of the binary
buffer. The nvlist_unpack(9) function converts a given binary buffer
to an nvlist. In the conversion process the endianness encoded in the
nvlist_header is evaluated and -- should the encoded endianness differ
from the endianess of the decoding host -- endianness conversion is
applied to nvlist_header and nvpair_header elements as well as
to some nvpair values.
In 2015 @oshogbo extended libnv with array support (in 347a39b).
The unpacking code misses the possible need to convert the endianness
of the nvph_nitems element of nvpair_headers.
The patch (re)enables libnv to unpack nvlists regardless of the
endianness of the packing host.
Pull Request: https://github.com/freebsd/freebsd-src/pull/528
|
| |
|
|
|
|
|
| |
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).
Sponsored by: The FreeBSD Foundation
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we had a multiple nvlist, during nvlist_pack, we calculated the size
of every nvlist separately. For example, if we had a nvlist with three
nodes each containing another (A contains B, and B contains C), we first
calculated the size of nvlist A (which contains B, C), then we calculate
the size of B (which contains C, notice that we already did the
calculation of B, when we calculate A), and finally C. This means that
this calculation was O(N!). This was done because each time we pack
nvlist, we have to put its size in the header
(the separate header for A, B, and C).
To not break the ABI and to reduce the complexity of nvlist_size,
instead of calculating the nvlist size when requested,
we track the size of each nvlist.
Reported by: pjd, kp
Tested by: kp
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
44c125c4cebc2fd87c6260b90eddae11201f5232 switched the nvlist allocations
to be M_WAITOK, but this precludes the use in non-sleepable contexts.
(E.g. with a nonsleepable lock held).
All callers for these allocation functions already cope with memory
alloation failures, so there's no reason to allow sleeping during
allocations.
Reviewed by: melifaro, oshogbo
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29556
|
| |
|
|
| |
Notes:
svn path=/head/; revision=362666
|
| |
|
|
|
|
|
|
|
|
| |
It can't be a static one.
Reported by: jenkins
MFC after: 2 weeks
Notes:
svn path=/head/; revision=346115
|
| |
|
|
|
|
|
|
|
|
|
| |
When building libnv without a debug those arguments are no longer used
because assertions will be changed to NOP.
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC after: 2 weeks
Notes:
svn path=/head/; revision=346113
|
| |
|
|
|
|
|
|
|
|
|
| |
When building libnv without a debug those arguments are no longer used
because assertions will be changed to NOP.
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC after: 2 weeks
Notes:
svn path=/head/; revision=346112
|
| |
|
|
|
|
|
| |
Reported by: jenkins
Notes:
svn path=/head/; revision=344236
|
| |
|
|
|
|
|
|
|
|
|
|
| |
In r343986 we introduced a double free. The structure was already
freed fixed in the r302966. This problem was introduced
because the GitHub version was out of sync with the FreeBSD one.
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC with: r343986
Notes:
svn path=/head/; revision=344235
|
| |
|
|
|
|
|
|
|
| |
Free the data array for NV_TYPE_DESCRIPTOR_ARRAY case.
MFC after: 2 weeks
Notes:
svn path=/head/; revision=343987
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nvpair_create_stringv: free the temporary string; this fix affects
nvlist_add_stringf() and nvlist_add_stringv().
nvpair_remove_nvlist_array (NV_TYPE_NVLIST_ARRAY case): free the chain
of nvpairs (as resetting it prevents nvlist_destroy() from freeing it).
Note: freeing the chain in nvlist_destroy() is not sufficient, because
it would still leak through nvlist_take_nvlist_array(). This affects
all nvlist_*_nvlist_array() use
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
Reported by: clang/gcc ASAN
MFC after: 2 weeks
Notes:
svn path=/head/; revision=343986
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libnv used fcntl(fd, F_GETFL) to test whether fd is a valid file
descriptor. Aside from being racy, this check requires CAP_FCNTL
rights on fd. Instead, use fcntl(fd, F_GETFD), which does not require
any capability rights.
Also remove some redundant fd_is_valid() checks to avoid extra system
calls; in many cases we were performing this check immediately before
dup()ing the descriptor.
Reviewed by: cem, oshogbo (previous version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17963
Notes:
svn path=/head/; revision=340408
|
| |
|
|
|
|
|
|
| |
Approved by: oshogbo
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=335382
|
| |
|
|
|
|
|
|
| |
Approved by: emaste, oshogbo
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=335380
|
| |
|
|
|
|
|
|
|
|
| |
gcc doesn't explode. Feel free to fix this correctly or whatever for
gcc builds.
This *should* quiesce tinderbox after r335347 for the gcc builds.
Notes:
svn path=/head/; revision=335379
|
| |
|
|
|
|
|
|
|
|
| |
The nvlist_append_{bool,number,string,nvlist,descriptor}_array() functions
allows to dynamically extend array stored in the nvlist.
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
Notes:
svn path=/head/; revision=335347
|
| |
|
|
|
|
|
|
|
|
| |
When we are removing element form the nvlist we should also clean parent,
because the array is not a part of the nvlist anymore.
Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
Notes:
svn path=/head/; revision=335344
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
All information which are need for those operations is already stored in
the cookie.
We decided not to bump libnv version because this API is not used yet in the
base system.
Reviewed by: pjd
Notes:
svn path=/head/; revision=335343
|
| |
|
|
|
|
|
| |
Pointed out by: pjd@
Notes:
svn path=/head/; revision=335342
|
| |
|
|
|
|
|
|
|
|
| |
The name was inconsistent with rest of the library.
No functional change intended.
Pointed out by: pjd@
Notes:
svn path=/head/; revision=335341
|
| |
|
|
|
|
|
| |
MFC after: 2 weeks
Notes:
svn path=/head/; revision=328474
|
| |
|
|
| |
Notes:
svn path=/head/; revision=328164
|
| |
|
|
|
|
|
|
|
|
| |
Those function can be used when we are iterating over nvlist to reduce
amount of extra variables we need to declare.
MFC after: 1 month
Notes:
svn path=/head/; revision=325019
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In rS323851, some casts were adjusted in calls to nvlist_next() and
nvlist_get_pararr() in order to make scan-build happy. I think these changes
just confused scan-build into not reporting the strict-aliasing violation.
For example, nvlist_xdescriptors() is causing nvlist_next() to write to its
local variable nvp of type nvpair_t * using the lvalue *cookiep of type
void *, which is not allowed. Given the APIs of nvlist_next(),
nvlist_get_parent() and nvlist_get_pararr(), one possible fix is to create a
local void *cookie in nvlist_xdescriptors() and other places, and to convert
the value to nvpair_t * when necessary. This patch implements that fix.
Reviewed by: oshogbo
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12760
Notes:
svn path=/head/; revision=325017
|
| |
|
|
|
|
|
|
|
|
|
| |
allocation fails.
Submitted by: pjd@
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323860
|
| |
|
|
|
|
|
|
|
| |
Submitted by: pjd@ and oshogbo@
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323859
|
| |
|
|
|
|
|
|
|
|
|
|
| |
initialize nvp on every loop iteration and the code under 'fail'(!) label
detects success by checking of nvp != NULL.
Submitted by: pjd@
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323858
|
| |
|
|
|
|
|
|
|
|
| |
Submitted by: pjd@
MFC after: 1 month
Found by: scan-build
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323856
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
to 'fail' on error it was treated as success, because nvp!=NULL. Fix this
by not handling success under 'fail' label and by using separate variable
for parent nvpair.
If we succeeded to allocate nvlist, but failed to allocated nvpair we
would leak nvls[ii] on return. Destroy it when we cannot allocate nvpair,
before we goto fail.
Submitted by: pjd@ and oshogbo@ (minor changes)
Found by: scan-build
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323854
|
| |
|
|
|
|
|
|
|
| |
Submitted by: pjd@ and oshogbo@
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323853
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
initially NULL, which is not possible. Change the loop to
'do {} while (array != NULL)' to satisfy scan-build and assert that
array really cannot be NULL just in case.
Submitted by: pjd@
Found by: scan-build
MFC after: 1 month
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323852
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Make scan-build happy by casting to 'void *' instead of 'void **'.
Submitted by: pjd@
MFC after: 1 month
Found by: scan-build and cppcheck
Sponsored by: Wheel Systems
Notes:
svn path=/head/; revision=323851
|
| |
|
|
|
|
|
|
| |
Remove unused arguments in a macro.
Remove unused typedef.
Notes:
svn path=/head/; revision=304909
|
| |
|
|
|
|
|
|
|
|
|
| |
cnv API is a set of functions for managing name/value pairs by cookie.
The cookie can be obtained by nvlist_next(), nvlist_get_parent() or
nvlist_get_pararr() function. This patch also includes unit tests.
Submitted by: Adam Starak <starak.adam@gmail.com>
Notes:
svn path=/head/; revision=304908
|
| |
|
|
| |
Notes:
svn path=/head/; revision=303529
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When we change nvl_array_next to NULL it means that we want to destroy or
take nvlist_array. The nvpair, which stores next nvlist of nvlist_array element
is no longer needed and can be freed.
Submitted by: Adam Starak <starak.adam@gmail.com>
MFC after: 1 week
Notes:
svn path=/head/; revision=302966
|
| |
|
|
|
|
|
|
| |
Submitted by: Adam Starak <starak.adam@gmail.com>
MFC after: 1 week
Notes:
svn path=/head/; revision=302965
|