Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2548150imu; Thu, 29 Nov 2018 06:43:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/VbzxztQyakbB2B7o9q4S/FXa3jYwmu5GBlKSOQ/XCTyXCIL4UwztBtZLbO13qY6zLWjnEt X-Received: by 2002:a17:902:161:: with SMTP id 88mr1772864plb.306.1543502627002; Thu, 29 Nov 2018 06:43:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502626; cv=none; d=google.com; s=arc-20160816; b=T7h/CwOp8nQqr4NTe3eIp9LO+X0CFCn/g8MH1GXIOPvEbvtsav0TycU/b+LxVf8lwK cFst8HVuHPguHlh2EWVkmNRncsb0+AClNXMrpOGYq1yxj125YOXOsjCKi7j77SVvt+UU 1dzOUOZg4P/3Qt3K9qGfyH1ivn2gfAOA+tbGL983vVuD7XtkJ6k9cFOjUkjCi50RsKye yU/rFYSkjfR97ncmietvdYx83dLRTgJ3iWrAgYLRq0zrfMj9EO6u+icpAflRzytNIAPu Ewi3Cw5PGpJxjJo5LDHwcSNkp67nL7wxK1nfe0uqWjWS7X8EVFIWAfdGeT++woiSmfWk A7Pw== 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=Z5O20nr8KlGrwwN/aXMlpOcYORkm04tbIKhDhJv/9lw=; b=ZYBpN7mvffrIZl4TEZ6UpeR2Y4xpJ0kJIDGXbjQAKFbANTMq7eLxuh0Ugv0FoBPMw0 xnXxWQFmjB2/+skztTy9sS7mHyrjJoiQUm1usMU8YBHKuFwqw6UPqF/6oeQAJpml2zhQ MlN4BEZAbb+FL313MpY9iA+unxPkZwIv2V2eM9WmuW8LzwYJwjN9YdUkhUHa4Vwn6vqN REsfks758Zo/Hsk59PlZLsUQXm3i+dFI+mVtInhL5r8CsPNDZTfbAu6ge6m0NKilAW0K syX6k63FhBkdtKu34aR2pZ2XzLxs/pxkzwrruTymvApcCMUrhO6JEm2nTcQ4nnS7VMLt iH6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c9I0ivuF; 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 y10si2125020plt.406.2018.11.29.06.43.31; Thu, 29 Nov 2018 06:43:46 -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=c9I0ivuF; 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 S2387478AbeK3Br4 (ORCPT + 99 others); Thu, 29 Nov 2018 20:47:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:33988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728759AbeK3BdX (ORCPT ); Thu, 29 Nov 2018 20:33:23 -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 F0ECB213A2; Thu, 29 Nov 2018 14:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501671; bh=qP+H+ob7tYUhtZLwhSUYdR3Vv/+z4Eb65fLnCWAazXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9I0ivuF9MFvMt0X9Q0zjPwBttOVTim6j5vo8gswqC8jrqPrDd55vyViNG6MBOaWI S4sZGE3RcGofVchWzJ3aVWm4ZZ0WPzCnoJZi4Ff4khxI6H7N/eqcko4TWgoDyMArmn sBYIhUcfCo9wb7gqu5qc8psVtGIHqofAtgtkYaSM= 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.14 094/100] s390/mm: Check for valid vma before zapping in gmap_discard Date: Thu, 29 Nov 2018 15:13:04 +0100 Message-Id: <20181129140106.874898228@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@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.14-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/gmap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -689,6 +689,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); }