Commit b4d70a61 authored by Heiko Carstens's avatar Heiko Carstens
Browse files

s390/mm: use invalid asce for user space when switching to init_mm



Currently only idle_task_exit() explicitly switches (switch_mm) to
init_mm. This causes the kernel asce to be loaded into cr7 and
therefore it would be used for potential user space accesses.

This is currently no problem since idle_task_exit() is nearly the last
thing a CPU executes before it is taken down. However things might
change - and therefore make sure that always the invalid asce is used
for cr7 when active_mm is init_mm.

This makes sure that all potential user space accesses will fail,
instead of accessing kernel address space.

Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 454efcf8
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -76,6 +76,9 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
{
{
	int cpu = smp_processor_id();
	int cpu = smp_processor_id();


	if (next == &init_mm)
		S390_lowcore.user_asce = s390_invalid_asce;
	else
		S390_lowcore.user_asce = next->context.asce;
		S390_lowcore.user_asce = next->context.asce;
	cpumask_set_cpu(cpu, &next->context.cpu_attach_mask);
	cpumask_set_cpu(cpu, &next->context.cpu_attach_mask);
	/* Clear previous user-ASCE from CR7 */
	/* Clear previous user-ASCE from CR7 */