Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2523482imu; Thu, 29 Nov 2018 06:23:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/UlkeK7kRnclVdOnTTVIKne8xPqxKdrv/UOyRvPLw3PaFU+PpadM4Lyd7+ufO1Md61PwLZf X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr1599673plu.122.1543501383017; Thu, 29 Nov 2018 06:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501382; cv=none; d=google.com; s=arc-20160816; b=NNQai9Pr9+KVE/mysI7hyL88psMhCdktV67yWMHl+douxpQUdfqZATRVlcsRmwRrt5 t7UJYhfSeCWBlUAZECND4kaJ53ULr9L8r1Avao8VjyjkMOryjdykHPMr5uwudmTOHiYR dZl4j1zwPhGJw8Im5qxe2+3sDNs7Df7Dy2aeuLm0E0G+y7AMxMnUR35HLBQ4sT3bUcsc LrwVRaqI/Bvjn6fwlWoFezOuBOjCG1iWNlzNp7rZ48+CJT3l1BVC0jyfLS1nuhETf5GQ jzq++47NHRZcibtRSKlff3+jfQ9lF36V6aLcjk5eg+MrDfxLEifWdKPJIIPE1umZl0Qg aS/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oR+n2ETu49gs/B3Tuc7CP2y/BgMKxOAHFst7mfYzQN0=; b=Gaa/yfNVxnWnTROsmd0ZFdacchQZ8P8bdtdSVAZoFFfuYL00F+lj2ZYXofBj76ReH2 v9T2FkiBZLm5mbYLuXKN268ihd8EwKCt/sFoMJw6UnGUhMMORsOyf34bDlTXa6xln81W nI7Sp0zpYNE+P5ZihlGvbDrbOGOwk3fleg+101SIYK3JiLde6tqZT0/N9nuYJRGdjtPA g3/0jWIMQg7gRjL4+1vHKphxtUhEanphTKV0EBImAX5agEospaiCv/gR3JDq4k8VuDcO Qo8zkXzhBpHvj+f8yzDh+pkXucphtPoPAfHj4KpE2Z2jtCD2/hzy48TwGgWk/9udSgFZ YKWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TObjm8fd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205si2167417pfa.199.2018.11.29.06.22.47; Thu, 29 Nov 2018 06:23:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TObjm8fd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731281AbeK3BZc (ORCPT + 99 others); Thu, 29 Nov 2018 20:25:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:49088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731270AbeK3BZc (ORCPT ); Thu, 29 Nov 2018 20:25:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 245A821104; Thu, 29 Nov 2018 14:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501201; bh=5RB+Ge78ujoLgfRhw2DPUxe/6ymReWdIoDcPEcLiNQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TObjm8fdKmxPOrdUH0V/yBOj+7dzj6J+QqmfdGcvRAMBtLLk626gm6L5WohgD2ev7 vg2dX+/Bq1T4xGG3zHnX2eG2WkMb0bl4/u1VhvlrS9vfo+Tvs+DRcCFFag7/z+EzBg HILBw2zuOp8Pu6f3Zmit9vaIpya8gdgRc4886UPU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janosch Frank , David Hildenbrand , Dan Carpenter Subject: [PATCH 4.4 85/86] s390/mm: Check for valid vma before zapping in gmap_discard Date: Thu, 29 Nov 2018 15:12:50 +0100 Message-Id: <20181129140116.504805310@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Janosch Frank commit 1843abd03250115af6cec0892683e70cf2297c25 upstream. Userspace could have munmapped the area before doing unmapping from the gmap. This would leave us with a valid vmaddr, but an invalid vma from which we would try to zap memory. Let's check before using the vma. Fixes: 1e133ab296f3 ("s390/mm: split arch/s390/mm/pgtable.c") Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reported-by: Dan Carpenter Message-Id: <20180816082432.78828-1-frankja@linux.ibm.com> Signed-off-by: Janosch Frank Signed-off-by: Greg Kroah-Hartman --- arch/s390/mm/pgtable.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -637,6 +637,8 @@ void gmap_discard(struct gmap *gmap, uns vmaddr |= gaddr & ~PMD_MASK; /* Find vma in the parent mm */ vma = find_vma(gmap->mm, vmaddr); + if (!vma) + continue; size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK)); zap_page_range(vma, vmaddr, size, NULL); }