Skip to contentSkip to conversation

mm/page_alloc: Fix __alloc_size attribute for alloc_pages_exact_nid

PATCH In review Thibaut Sautereau 2 participants 2 messages Dec 14, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_alloc: Fix __alloc_size attribute for alloc_pages_exact_nid

From: Thibaut Sautereau <[email protected]>

The second parameter of alloc_pages_exact_nid is the one indicating the size of memory pointed by the returned pointer.

Fixes abd58f38dfb4 ("mm/page_alloc: add __alloc_size attributes for better bounds checking")
Cc Daniel Micay <[email protected]>
Cc Kees Cook <[email protected]>
Cc Levente Polyak <[email protected]>
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gfp.h +1 -1
index b976c4177299..8fcc38467af6 100644
@@ -624,7 +624,7 @@ extern unsigned long get_zeroed_page(gfp_t gfp_mask);
 
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask) __alloc_size(1);
 void free_pages_exact(void *virt, size_t size);
-__meminit void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) __alloc_size(1);
+__meminit void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) __alloc_size(2);
 
 #define __get_free_page(gfp_mask) \
 		__get_free_pages((gfp_mask), 0)
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Thibaut Sautereau

From: Thibaut Sautereau <[email protected]>

The second parameter of alloc_pages_exact_nid is the one indicating the size of memory pointed by the returned pointer.

Fixes abd58f38dfb4 ("mm/page_alloc: add __alloc_size attributes for better bounds checking")
Cc Daniel Micay <[email protected]>
Cc Kees Cook <[email protected]>
Cc Levente Polyak <[email protected]>

Thanks! Andrew, can you take this?

-Kees

Quoted 20 lines
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gfp.h +1 -1
index b976c4177299..8fcc38467af6 100644
@@ -624,7 +624,7 @@ extern unsigned long get_zeroed_page(gfp_t gfp_mask);
 
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask) __alloc_size(1);
 void free_pages_exact(void *virt, size_t size);
-__meminit void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) __alloc_size(1);
+__meminit void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) __alloc_size(2);
 
 #define __get_free_page(gfp_mask) \
 		__get_free_pages((gfp_mask), 0)
Signature · 1 line
2.34.1
Signature · 1 line
Kees Cook