Skip to contentSkip to conversation

zsmalloc: calling zs_map_object() from irq is a bug

PATCH In review Sergey Senozhatsky 3 participants 5 messages Sep 20, 2017 – Sep 28, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zsmalloc: calling zs_map_object() from irq is a bug

Use BUG_ON(in_interrupt()) in zs_map_object(). Calling this function from IRQ is a bug, because we use per-CPU mappings and interrupt may corrupt those buffers.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -1
index 7c38e850a8fc..685049a9048d 100644
@@ -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);
Signature · 1 line
2.14.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Sergey Senozhatsky

Use BUG_ON(in_interrupt()) in zs_map_object(). Calling this function from IRQ is a bug, because we use per-CPU mappings and interrupt may corrupt those buffers.

IMHO, corruption the buffer would be not enough to be a BUG_ON which stop the system fully so user loses any chances to shut down smooth/hunt it down.

More serious thing of our case is that it can leak other user's data by overwriting, which is more concern I am thinking now.

So,

Thanks!

#2 lore raw
Quoted 11 lines · Minchan Kim
Quoted 5 lines · Sergey Senozhatsky

Use BUG_ON(in_interrupt()) in zs_map_object(). Calling this function from IRQ is a bug, because we use per-CPU mappings and interrupt may corrupt those buffers.

IMHO, corruption the buffer would be not enough to be a BUG_ON which stop the system fully so user loses any chances to shut down smooth/hunt it down.

Quoted 6 lines

More serious thing of our case is that it can leak other user's data by overwriting, which is more concern I am thinking now.

So,

thanks.

	-ss
maintainer
#3 lore raw
In reply to Minchan Kim
Quoted 5 lines · On Wed, 20 Sep 2017 15:47:39 +0900 Minchan Kim <[email protected]> wrote:
Quoted 4 lines · Sergey Senozhatsky

Use BUG_ON(in_interrupt()) in zs_map_object(). Calling this function from IRQ is a bug, because we use per-CPU mappings and interrupt may corrupt those buffers.

Quoted 9 lines
Quoted 1 line

IMHO, corruption the buffer would be not enough to be a BUG_ON which stop the system fully so user loses any chances to shut down smooth/hunt it down.

More serious thing of our case is that it can leak other user's data by overwriting, which is more concern I am thinking now.

In an off-list email Linus has basically stated that all new uses of BUG_ON should include words in the changelog or code comments explaining why it is justifiable to kill the machine when the condition triggers.

So can we please have a v2 with the appropriate comment?

#4 lore raw
Quoted 15 lines · Andrew Morton
Quoted 5 lines · Sergey Senozhatsky
Quoted 4 lines

Use BUG_ON(in_interrupt()) in zs_map_object(). Calling this function from IRQ is a bug, because we use per-CPU mappings and interrupt may corrupt those buffers.

Quoted 9 lines
Quoted 1 line

IMHO, corruption the buffer would be not enough to be a BUG_ON which stop the system fully so user loses any chances to shut down smooth/hunt it down.

More serious thing of our case is that it can leak other user's data by overwriting, which is more concern I am thinking now.

Quoted 6 lines

In an off-list email Linus has basically stated that all new uses of BUG_ON should include words in the changelog or code comments explaining why it is justifiable to kill the machine when the condition triggers.

So can we please have a v2 with the appropriate comment?

ah, OK. will follow up.

	-ss