Skip to contentSkip to conversation

Patch "s390/guarded storage: fix possible memory corruption" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Nov 25, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

s390/guarded storage: fix possible memory corruption

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
s390-guarded-storage-fix-possible-memory-corruption.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From fa1edf3f63c05ca8eacafcd7048ed91e5360f1a8 Mon Sep 17 00:00:00 2001

From: Heiko Carstens <[email protected]>
Date: Mon, 11 Sep 2017 11:24:22 +0200
Subject: s390/guarded storage: fix possible memory corruption

From: Heiko Carstens <[email protected]>

commit fa1edf3f63c05ca8eacafcd7048ed91e5360f1a8 upstream.

For PREEMPT enabled kernels the guarded storage (GS) code contains a possible use-after-free bug. If a task that makes use of GS exits, it will execute do_exit() while still enabled for preemption.

That function will call exit_thread_runtime_instr() via exit_thread(). If exit_thread_gs() gets preempted after the GS control block of the task has been freed but before the pointer to it is set to NULL, then save_gs_cb(), called from switch_to(), will write to already freed memory.

Avoid this and simply disable preemption while freeing the control block and setting the pointer to NULL.

Fixes 916cda1aa1b4 ("s390: add a system call for guarded storage")
---
 arch/s390/kernel/guarded_storage.c |    2 ++
 1 file changed, 2 insertions(+)
arch/s390/kernel/guarded_storage.c +2 -0
@@ -14,9 +14,11 @@
 
 void exit_thread_gs(void)
 {
+	preempt_disable();
 	kfree(current->thread.gs_cb);
 	kfree(current->thread.gs_bc_cb);
 	current->thread.gs_cb = current->thread.gs_bc_cb = NULL;
+	preempt_enable();
 }
 
 static int gs_enable(void)

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/s390-guarded-storage-fix-possible-memory-corruption.patch queue-4.14/s390-disassembler-add-missing-end-marker-for-e7-table.patch queue-4.14/s390-fix-transactional-execution-control-register-handling.patch queue-4.14/s390-runtime-instrumention-fix-possible-memory-corruption.patch queue-4.14/s390-noexec-execute-kexec-datamover-without-dat.patch