Skip to content

Commit

Permalink
powerpc: Add __must_check to set_memory_...()
Browse files Browse the repository at this point in the history
After the following powerpc commits, all calls to set_memory_...()
functions check returned value.
- Commit 8f17bd2 ("powerpc: Handle error in mark_rodata_ro() and
mark_initmem_nx()")
- Commit f7f18e3 ("powerpc/kprobes: Handle error returned by
set_memory_rox()")
- Commit 009cf11 ("powerpc: Don't ignore errors from
set_memory_{n}p() in __kernel_map_pages()")
- Commit 9cbacb8 ("powerpc: Don't ignore errors from
set_memory_{n}p() in __kernel_map_pages()")
- Commit 78cb094 ("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: KSPP#7
Signed-off-by: Christophe Leroy <[email protected]>
  • Loading branch information
chleroy authored and intel-lab-lkp committed Sep 8, 2024
1 parent a5a670d commit 9705f15
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions arch/powerpc/include/asm/set_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@

int change_memory_attr(unsigned long addr, int numpages, long action);

static inline int set_memory_ro(unsigned long addr, int numpages)
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 set_memory_rw(unsigned long addr, int numpages)
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 set_memory_nx(unsigned long addr, int numpages)
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 set_memory_x(unsigned long addr, int numpages)
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 set_memory_np(unsigned long addr, int numpages)
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 set_memory_p(unsigned long addr, int numpages)
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 set_memory_rox(unsigned long addr, int numpages)
static inline int __must_check set_memory_rox(unsigned long addr, int numpages)
{
return change_memory_attr(addr, numpages, SET_MEMORY_ROX);
}
Expand Down

0 comments on commit 9705f15

Please sign in to comment.