Skip to content

Commit

Permalink
kasan, sched/headers: Uninline kasan_enable/disable_current()
Browse files Browse the repository at this point in the history
<linux/kasan.h> is a low level header that is included early
in affected kernel headers. But it includes <linux/sched.h>
which complicates the cleanup of sched.h dependencies.

But kasan.h has almost no need for sched.h: its only use of
scheduler functionality is in two inline functions which are
not used very frequently - so uninline kasan_enable_current()
and kasan_disable_current().

Also add a <linux/sched.h> dependency to a .c file that depended
on kasan.h including it.

This paves the way to remove the <linux/sched.h> include from kasan.h.

Acked-by: Linus Torvalds <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Mar 2, 2017
1 parent 314ff78 commit af8601a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
10 changes: 2 additions & 8 deletions include/linux/kasan.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ static inline void *kasan_mem_to_shadow(const void *addr)
}

/* Enable reporting bugs after kasan_disable_current() */
static inline void kasan_enable_current(void)
{
current->kasan_depth++;
}
extern void kasan_enable_current(void);

/* Disable reporting bugs for current task */
static inline void kasan_disable_current(void)
{
current->kasan_depth--;
}
extern void kasan_disable_current(void);

void kasan_unpoison_shadow(const void *address, size_t size);

Expand Down
1 change: 1 addition & 0 deletions lib/sbitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <linux/sched.h>
#include <linux/random.h>
#include <linux/sbitmap.h>
#include <linux/seq_file.h>
Expand Down
10 changes: 10 additions & 0 deletions mm/kasan/kasan.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
#include "kasan.h"
#include "../slab.h"

void kasan_enable_current(void)
{
current->kasan_depth++;
}

void kasan_disable_current(void)
{
current->kasan_depth--;
}

/*
* Poisons the shadow memory for 'size' bytes starting from 'addr'.
* Memory addresses should be aligned to KASAN_SHADOW_SCALE_SIZE.
Expand Down

0 comments on commit af8601a

Please sign in to comment.