Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933212AbdIHNXK (ORCPT ); Fri, 8 Sep 2017 09:23:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36266 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933197AbdIHNXG (ORCPT ); Fri, 8 Sep 2017 09:23:06 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Schwidefsky Subject: [PATCH 4.12 33/43] s390/mm: fix BUG_ON in crst_table_upgrade Date: Fri, 8 Sep 2017 15:19:21 +0200 Message-Id: <20170908131827.767209358@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170908131826.555428826@linuxfoundation.org> References: <20170908131826.555428826@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1479 Lines: 49 4.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Schwidefsky commit 8ab867cb0806a8e195de161fd8883a0578d1d050 upstream. A 31-bit compat process can force a BUG_ON in crst_table_upgrade with specific, invalid mmap calls, e.g. mmap((void*) 0x7fff8000, 0x10000, 3, 32, -1, 0) The arch_get_unmapped_area[_topdown] functions miss an if condition in the decision to do a page table upgrade. [ms: Backport to 4.12, minor context change] Fixes: 9b11c7912d00 ("s390/mm: simplify arch_get_unmapped_area[_topdown]") Signed-off-by: Martin Schwidefsky Signed-off-by: Greg Kroah-Hartman --- arch/s390/mm/mmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -119,7 +119,8 @@ arch_get_unmapped_area(struct file *filp return addr; check_asce_limit: - if (addr + len > current->mm->context.asce_limit) { + if (addr + len > current->mm->context.asce_limit && + addr + len <= TASK_SIZE) { rc = crst_table_upgrade(mm); if (rc) return (unsigned long) rc; @@ -183,7 +184,8 @@ arch_get_unmapped_area_topdown(struct fi } check_asce_limit: - if (addr + len > current->mm->context.asce_limit) { + if (addr + len > current->mm->context.asce_limit && + addr + len <= TASK_SIZE) { rc = crst_table_upgrade(mm); if (rc) return (unsigned long) rc;