LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2 0/3] staging/rtl8192u: Prefer kcalloc over open coded arithmetic
@ 2021-08-24  7:25 Len Baker
  2021-08-24  7:25 ` [PATCH v2 1/3] staging/rtl8192u: Avoid CamelCase in names of variables Len Baker
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Len Baker @ 2021-08-24  7:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kees Cook
  Cc: Len Baker, Dan Carpenter, Michael Straube, Lee Jones,
	linux-staging, linux-kernel, linux-hardening

The main reason of this patch serie is to avoid size calculations
(especially multiplication) in memory allocator function arguments due
to the risk of them overflowing [1]. 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.

At the same time, take the opportunity to refactor the function avoiding
CamelCase in the name of variables and moving some initializations to
the variables definition block.

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

Changelog v1 -> v2
- Split the CamelCase refactoring and the moving of initializations in
  two separate commits (Kees Cook).
- Link to the documentation to clarify the change in the 3/3 patch (Kees
  Cook).
- Modify the commit message to clarify in the 3/3 patch that these
  changes are not dynamic sizes but it is best to do the change to keep
  the open-coded math idiom out of code (Kees Cook).

Len Baker (3):
  staging/rtl8192u: Avoid CamelCase in names of variables
  staging/rtl8192u: Initialize variables in the definition block
  staging/rtl8192u: Prefer kcalloc over open coded arithmetic

 drivers/staging/rtl8192u/r819xU_phy.c | 92 +++++++++++++--------------
 1 file changed, 44 insertions(+), 48 deletions(-)

--
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-24  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24  7:25 [PATCH v2 0/3] staging/rtl8192u: Prefer kcalloc over open coded arithmetic Len Baker
2021-08-24  7:25 ` [PATCH v2 1/3] staging/rtl8192u: Avoid CamelCase in names of variables Len Baker
2021-08-24  8:59 ` [PATCH v2 2/3] staging/rtl8192u: Initialize variables in the definition block Len Baker
2021-08-24  9:00 ` [PATCH v2 3/3] staging/rtl8192u: Prefer kcalloc over open coded arithmetic Len Baker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).