linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] bitmap: Fix return values to be unsigned
@ 2022-05-17 21:22 Kees Cook
  2022-05-17 21:22 ` [PATCH v2 1/2] " Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kees Cook @ 2022-05-17 21:22 UTC (permalink / raw)
  To: Yury Norov
  Cc: Kees Cook, Christophe de Dinechin, Rasmus Villemoes,
	Alexey Dobriyan, Andy Shevchenko, Andrew Morton, Zhen Lei,
	linux-kernel, linux-hardening

Hi,

As mentioned in the last patch:

Both nodemask and bitmap routines had mixed return values that provided
potentially signed results that could never happen. This was leading to
the compiler getting confusing about the range of possible return values
(it was thinking things could be negative where they could not be). Fix
all the nodemask and bitmap routines that should be returning unsigned
(or bool) values. Silences GCC 12 warnings:

 mm/swapfile.c: In function ‘setup_swap_info’:
 mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds of ‘struct plist_node[]’ [-Werror=array-bounds]
  2291 |                                 p->avail_lists[i].prio = 1;
       |                                 ~~~~~~~~~~~~~~^~~
 In file included from mm/swapfile.c:16:
 ./include/linux/swap.h:292:27: note: while referencing ‘avail_lists’
   292 |         struct plist_node avail_lists[]; /*
       |                           ^~~~~~~~~~~

This splits up the patch into the bitmap and nodemask halves, and drops
a needless change to the random node helper.

I note that Alexey and Rasmus touched on this area in the past, fixing
up node ids to be unsigned:

ce0725f78a56 ("numa: make "nr_online_nodes" unsigned int")
b9726c26dc21 ("numa: make "nr_node_ids" unsigned int")
33c4fa8c6763 ("linux/nodemask.h: update bitmap wrappers to take unsigned int")

If anyone else would like to carry this, please let me know. I'm happy
to carry it in my tree.

-Kees

Kees Cook (2):
  bitmap: Fix return values to be unsigned
  nodemask: Fix return values to be unsigned

 include/linux/bitmap.h   | 14 +++++++-------
 include/linux/nodemask.h | 38 +++++++++++++++++++-------------------
 lib/bitmap.c             | 28 ++++++++++++++--------------
 lib/nodemask.c           |  2 +-
 4 files changed, 41 insertions(+), 41 deletions(-)

-- 
2.32.0


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

end of thread, other threads:[~2022-05-18  0:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 21:22 [PATCH v2 0/2] bitmap: Fix return values to be unsigned Kees Cook
2022-05-17 21:22 ` [PATCH v2 1/2] " Kees Cook
2022-05-17 21:22 ` [PATCH v2 2/2] nodemask: " Kees Cook
2022-05-17 22:15   ` Yury Norov
2022-05-17 22:21 ` [PATCH v2 0/2] bitmap: " Yury Norov
2022-05-18  0:56   ` Kees Cook

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).