Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Add __must_check to set_memory_...()

After the following powerpc commits, all calls to set_memory_...()
functions check returned value.
- Commit 8f17bd2f4196 ("powerpc: Handle error in mark_rodata_ro() and
mark_initmem_nx()")
- Commit f7f18e30b468 ("powerpc/kprobes: Handle error returned by
set_memory_rox()")
- Commit 009cf11d4aab ("powerpc: Don't ignore errors from
set_memory_{n}p() in __kernel_map_pages()")
- Commit 9cbacb834b4a ("powerpc: Don't ignore errors from
set_memory_{n}p() in __kernel_map_pages()")
- Commit 78cb0945f714 ("powerpc: Handle error in mark_rodata_ro() and
mark_initmem_nx()")

All calls in core parts of the kernel also always check returned value,
can be looked at with following query:

$ git grep -w -e set_memory_ro -e set_memory_rw -e set_memory_x -e set_memory_nx -e set_memory_rox `find . -maxdepth 1 -type d | grep -v arch | grep /`

It is now possible to flag those functions with __must_check to make
sure no new unchecked call it added.

Link: https://github.com/KSPP/linux/issues/7
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/775dae48064a661554802ed24ed5bdffe1784724.1725723351.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
2abbd6d5 19e0a70e

+7 -7
+7 -7
arch/powerpc/include/asm/set_memory.h
··· 12 12 13 13 int change_memory_attr(unsigned long addr, int numpages, long action); 14 14 15 - static inline int set_memory_ro(unsigned long addr, int numpages) 15 + static inline int __must_check set_memory_ro(unsigned long addr, int numpages) 16 16 { 17 17 return change_memory_attr(addr, numpages, SET_MEMORY_RO); 18 18 } 19 19 20 - static inline int set_memory_rw(unsigned long addr, int numpages) 20 + static inline int __must_check set_memory_rw(unsigned long addr, int numpages) 21 21 { 22 22 return change_memory_attr(addr, numpages, SET_MEMORY_RW); 23 23 } 24 24 25 - static inline int set_memory_nx(unsigned long addr, int numpages) 25 + static inline int __must_check set_memory_nx(unsigned long addr, int numpages) 26 26 { 27 27 return change_memory_attr(addr, numpages, SET_MEMORY_NX); 28 28 } 29 29 30 - static inline int set_memory_x(unsigned long addr, int numpages) 30 + static inline int __must_check set_memory_x(unsigned long addr, int numpages) 31 31 { 32 32 return change_memory_attr(addr, numpages, SET_MEMORY_X); 33 33 } 34 34 35 - static inline int set_memory_np(unsigned long addr, int numpages) 35 + static inline int __must_check set_memory_np(unsigned long addr, int numpages) 36 36 { 37 37 return change_memory_attr(addr, numpages, SET_MEMORY_NP); 38 38 } 39 39 40 - static inline int set_memory_p(unsigned long addr, int numpages) 40 + static inline int __must_check set_memory_p(unsigned long addr, int numpages) 41 41 { 42 42 return change_memory_attr(addr, numpages, SET_MEMORY_P); 43 43 } 44 44 45 - static inline int set_memory_rox(unsigned long addr, int numpages) 45 + static inline int __must_check set_memory_rox(unsigned long addr, int numpages) 46 46 { 47 47 return change_memory_attr(addr, numpages, SET_MEMORY_ROX); 48 48 }