[lkml]   [2017]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.14 129/164] zsmalloc: calling zs_map_object() from irq is a bug
4.14-stable review patch.  If anyone has any objections, please let me know.


From: Sergey Senozhatsky <>

[ Upstream commit 1aedcafbf32b3f232c159b14cd0d423fcfe2b861 ]

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

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

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

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

* 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.

Signed-off-by: Sergey Senozhatsky <>
Acked-by: Minchan Kim <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Sasha Levin <>
Signed-off-by: Greg Kroah-Hartman <>
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1349,7 +1349,7 @@ void *zs_map_object(struct zs_pool *pool
* 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 */

 \ /
  Last update: 2017-12-12 13:52    [W:0.388 / U:1.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site