Skip to content

Commit 3919600

Browse files
committed
s390/mm: Fix potential use-after-free in __crst_table_upgrade()
The pointer to the mm_struct which is passed to __crst_table_upgrade() may only be dereferenced if it is identical to current->active_mm. Otherwise the current task has no reference to the mm_struct and it may already be freed. In such a case this would result in a use-after-free bug. Make sure this use-after-free scenario does not happen by moving the code, which dereferences the mm_struct pointer, after the check which verifies that the pointer is identical to current->active_mm, like it was before lazy ASCE handling was reimplemented. Fixes: 8b72f5a ("s390/mm: Reimplement lazy ASCE handling") Reviewed-by: Gerald Schaefer <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent f049a4f commit 3919600

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/s390/mm/pgalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ static void __crst_table_upgrade(void *arg)
4040
struct mm_struct *mm = arg;
4141
struct ctlreg asce;
4242

43-
asce.val = mm->context.asce;
4443
/* change all active ASCEs to avoid the creation of new TLBs */
4544
if (current->active_mm == mm) {
45+
asce.val = mm->context.asce;
4646
get_lowcore()->user_asce = asce;
4747
local_ctl_load(7, &asce);
4848
if (!test_thread_flag(TIF_ASCE_PRIMARY))

0 commit comments

Comments
 (0)