The source for the Linux kernel used in Windows Subsystem for Linux 2 (WSL2)
Перейти к файлу
Len Baker 40f231e75a nl80211: prefer struct_size over open coded arithmetic
As noted in the "Deprecated Interfaces, Language Features, Attributes,
and Conventions" documentation [1], size calculations (especially
multiplication) should not be performed in memory allocator (or similar)
function arguments due to the risk of them overflowing. This could lead
to values wrapping around and a smaller allocation being made than the
caller was expecting. Using those allocations could lead to linear
overflows of heap memory and other misbehaviors.

So, use the struct_size() helper to do the arithmetic instead of the
argument "size + count * size" in the kzalloc() functions.

Also, take the opportunity to refactor the memcpy() call to use the
flex_array_size() helper.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210919114040.41522-1-len.baker@gmx.com
[remove unnecessary variable]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-09-23 13:38:11 +02:00
Documentation net: wwan: iosm: devlink fw flashing & cd collection documentation 2021-09-20 10:03:37 +01:00
LICENSES
arch Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-09-17 12:40:21 -07:00
block
certs
crypto
drivers mlxsw: spectrum_router: Start using new trap adjacency entry 2021-09-22 14:35:02 +01:00
fs qnx4: avoid stringop-overread errors 2021-09-15 13:56:37 -07:00
include devlink: Make devlink_register to be void 2021-09-22 14:15:12 +01:00
init memblock: introduce saner 'memblock_free_ptr()' interface 2021-09-14 13:23:22 -07:00
ipc ipc: remove memcg accounting for sops objects in do_semtimedop() 2021-09-14 10:22:11 -07:00
kernel Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-09-17 12:40:21 -07:00
lib Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-09-17 12:40:21 -07:00
mm memblock: introduce saner 'memblock_free_ptr()' interface 2021-09-14 13:23:22 -07:00
net nl80211: prefer struct_size over open coded arithmetic 2021-09-23 13:38:11 +02:00
samples
scripts Merge branch 'gcc-min-version-5.1' (make gcc-5.1 the minimum version) 2021-09-13 10:43:04 -07:00
security
sound
tools selftests: mptcp: add mptcp getsockopt test cases 2021-09-18 14:20:01 +01:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS Compiler Attributes improvements: 2021-09-12 16:09:26 -07:00
Makefile Merge branch 'gcc-min-version-5.1' (make gcc-5.1 the minimum version) 2021-09-13 10:43:04 -07:00
README

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.