Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp715614imu; Fri, 25 Jan 2019 09:39:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN5rN41nkLF+jx5KptEXqf5aDHqtfqKhTZ7NUgRiVb9+BNKPDU4avsAeNJxHo8ExIuy26s8d X-Received: by 2002:a62:5f07:: with SMTP id t7mr11764989pfb.108.1548437955997; Fri, 25 Jan 2019 09:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548437955; cv=none; d=google.com; s=arc-20160816; b=HW6BxkoJ7JpMg3lvvNB2XXnNXEItAFi0uMwgMyhWvmJdAkWMbC19QHmy0Kvs4nEmeT 6eXUQ4XEY3cbe3ERvWWOMY4rKuLdVNGuE8piah4k7TFd90X+Ydaw4agKr6m/Pcb23I7E 7SIFcYFusuDm4/FrF6CxLjUwRbQMm2Xu+FeUSLK/wbvh2ohIrk3xk4XKAkVKHpz/OMcg X47+SULrXxYNi8nyHTZSW0MoeNbR1zRtBybmSZka1bsFqq2tN4mjnd/Sck8H3GQ2Rmbz IhQVjR1fEk9YAJ/bmM44Fhbvu6RJCpDWEPqboHz+RNMhskXvj48HwIAT65XPGRrDoxLq BBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=5fm7+VQclmc9hs1XdDfzoo0+kGTLRUZeg8UOcg8q+Z4=; b=H9BKErx0uU3PIfWbSor1RXy++BC2/kW/cGrcKunyOXHR1Bwq01Fds4/W1yth3Pvznf 0F0pUTZhsmja5xgB0xFcsVUuEjHjR+17kzMJYGNl0vV4hKIhtBrN6iwKER1iuuWKFwhB vy2l07OW0bCUFs7jsenGyFVPUaSHUdkjxNPYqs6+ysFWuY813t/gPnT1BDoAKunFse+2 bOnIQEcxcAD64+RZPpvNAUbjcrlZpY1Ho7EpQL87ouEL3m8LzLZCtcKnDAnmousyGFvc HdtX4gDqXAC36R8lzljaMHdfSSrhgdFq2knCvgYuXIG+pXSUu2DspZz0G+fGxVYqz+0k pWRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nf8Bb+7W; 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 u69si25884716pfj.219.2019.01.25.09.39.00; Fri, 25 Jan 2019 09:39:15 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nf8Bb+7W; 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 S1728736AbfAYRiq (ORCPT + 99 others); Fri, 25 Jan 2019 12:38:46 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:52506 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfAYRiq (ORCPT ); Fri, 25 Jan 2019 12:38:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5fm7+VQclmc9hs1XdDfzoo0+kGTLRUZeg8UOcg8q+Z4=; b=nf8Bb+7W8x8wxgblLvy6oWMic d652mU0FzZk0JJee7uTAu8bH38PuCNnOgXPoWfLnj6NvmVvMVGjnWFKC+RDBigMq35LO4lvc7D7dn rkSem+D3vPoXfBabKSOPe+i9kSlzYTl2Lay6bBxCfYHkojLqgj3vawCoDKa9BbKQ4kYWJdGX0iNUC HdjdIt518XQF7vHcGAI2CShiycADvgCzYmkWMrvXwq4giB+5GXJPlzdqeL4br4whw8XZp0nVtlG62 cCL2HclCSzKdzKjbuibSwZTUrnauEnJ7RfLH3cMctor6SHckglSa9UgEI145lPqlCPIHzgqNhDHcz EJkl3+VbQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gn5R9-0000hr-Ei; Fri, 25 Jan 2019 17:38:39 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Rik van Riel , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , kernel-hardening@lists.openwall.com, Kees Cook , Michael Ellerman Subject: [PATCH] mm: Prevent mapping slab pages to userspace Date: Fri, 25 Jan 2019 09:38:27 -0800 Message-Id: <20190125173827.2658-1-willy@infradead.org> X-Mailer: git-send-email 2.14.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's never appropriate to map a page allocated by SLAB into userspace. A buggy device driver might try this, or an attacker might be able to find a way to make it happen. Signed-off-by: Matthew Wilcox --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index e11ca9dd823f..ce8c90b752be 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1451,7 +1451,7 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, spinlock_t *ptl; retval = -EINVAL; - if (PageAnon(page)) + if (PageAnon(page) || PageSlab(page)) goto out; retval = -ENOMEM; flush_dcache_page(page); -- 2.20.1