Skip to content

Commit

Permalink
zsmalloc: calling zs_map_object() from irq is a bug
Browse files Browse the repository at this point in the history
Use BUG_ON(in_interrupt()) in zs_map_object().  This is not a new
BUG_ON(), it's always been there, but was recently changed to VM_BUG_ON().
There are several problems there.  First, we use use per-CPU mappings
both in zsmalloc and in zram, and interrupt may easily corrupt those
buffers.  Second, and more importantly, we believe it's possible to start
leaking sensitive information.  Consider the following case:

-> process P
	swap out
	 zram
	  per-cpu mapping CPU1
	   compress page A
-> IRQ

	swap out
	 zram
	  per-cpu mapping CPU1
	   compress page B
	    write page from per-cpu mapping CPU1 to zsmalloc pool
	iret

-> process P
	    write page from per-cpu mapping CPU1 to zsmalloc pool  [*]
	return

* so we store overwritten data that actually belongs to another
  page (task) and potentially contains sensitive data. And when
  process P will page fault it's going to read (swap in) that
  other task's data.

Link: http://lkml.kernel.org/r/20170929045140.4055-1-sergey.senozhatsky@gmail.com
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
sergey-senozhatsky authored and hnaz committed Oct 4, 2017
1 parent deb2622 commit 3595f96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
* pools/users, we can't allow mapping in interrupt context
* because it can corrupt another users mappings.
*/
WARN_ON_ONCE(in_interrupt());
BUG_ON(in_interrupt());

/* From now on, migration cannot move the object */
pin_tag(handle);
Expand Down

0 comments on commit 3595f96

Please sign in to comment.