mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-13 05:20:13 +00:00
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 f7f18e30b4 ("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 9cbacb834b ("powerpc: Don't ignore errors from
set_memory_{n}p() in __kernel_map_pages()")
- Commit 78cb0945f7 ("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
52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_SET_MEMORY_H
|
|
#define _ASM_POWERPC_SET_MEMORY_H
|
|
|
|
#define SET_MEMORY_RO 0
|
|
#define SET_MEMORY_RW 1
|
|
#define SET_MEMORY_NX 2
|
|
#define SET_MEMORY_X 3
|
|
#define SET_MEMORY_NP 4 /* Set memory non present */
|
|
#define SET_MEMORY_P 5 /* Set memory present */
|
|
#define SET_MEMORY_ROX 6
|
|
|
|
int change_memory_attr(unsigned long addr, int numpages, long action);
|
|
|
|
static inline int __must_check set_memory_ro(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_RO);
|
|
}
|
|
|
|
static inline int __must_check set_memory_rw(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_RW);
|
|
}
|
|
|
|
static inline int __must_check set_memory_nx(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_NX);
|
|
}
|
|
|
|
static inline int __must_check set_memory_x(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_X);
|
|
}
|
|
|
|
static inline int __must_check set_memory_np(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_NP);
|
|
}
|
|
|
|
static inline int __must_check set_memory_p(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_P);
|
|
}
|
|
|
|
static inline int __must_check set_memory_rox(unsigned long addr, int numpages)
|
|
{
|
|
return change_memory_attr(addr, numpages, SET_MEMORY_ROX);
|
|
}
|
|
#define set_memory_rox set_memory_rox
|
|
|
|
#endif
|