Skip to content

Commit 3f777e1

Browse files
committed
Merge tag 'cve-2020-11884' from emailed bundle
Pull s390 fix from Christian Borntraeger: "Fix a race between page table upgrade and uaccess on s390. This fixes CVE-2020-11884 which allows for a local kernel crash or code execution" * tag 'cve-2020-11884' from emailed bundle: s390/mm: fix page table upgrade vs 2ndary address mode accesses
2 parents 51184ae + 316ec15 commit 3f777e1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

arch/s390/lib/uaccess.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ mm_segment_t enable_sacf_uaccess(void)
6464
{
6565
mm_segment_t old_fs;
6666
unsigned long asce, cr;
67+
unsigned long flags;
6768

6869
old_fs = current->thread.mm_segment;
6970
if (old_fs & 1)
7071
return old_fs;
72+
/* protect against a concurrent page table upgrade */
73+
local_irq_save(flags);
7174
current->thread.mm_segment |= 1;
7275
asce = S390_lowcore.kernel_asce;
7376
if (likely(old_fs == USER_DS)) {
@@ -83,6 +86,7 @@ mm_segment_t enable_sacf_uaccess(void)
8386
__ctl_load(asce, 7, 7);
8487
set_cpu_flag(CIF_ASCE_SECONDARY);
8588
}
89+
local_irq_restore(flags);
8690
return old_fs;
8791
}
8892
EXPORT_SYMBOL(enable_sacf_uaccess);

arch/s390/mm/pgalloc.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,20 @@ static void __crst_table_upgrade(void *arg)
7070
{
7171
struct mm_struct *mm = arg;
7272

73-
if (current->active_mm == mm)
74-
set_user_asce(mm);
73+
/* we must change all active ASCEs to avoid the creation of new TLBs */
74+
if (current->active_mm == mm) {
75+
S390_lowcore.user_asce = mm->context.asce;
76+
if (current->thread.mm_segment == USER_DS) {
77+
__ctl_load(S390_lowcore.user_asce, 1, 1);
78+
/* Mark user-ASCE present in CR1 */
79+
clear_cpu_flag(CIF_ASCE_PRIMARY);
80+
}
81+
if (current->thread.mm_segment == USER_DS_SACF) {
82+
__ctl_load(S390_lowcore.user_asce, 7, 7);
83+
/* enable_sacf_uaccess does all or nothing */
84+
WARN_ON(!test_cpu_flag(CIF_ASCE_SECONDARY));
85+
}
86+
}
7587
__tlb_flush_local();
7688
}
7789

0 commit comments

Comments
 (0)