From patchwork Fri Jan 25 17:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10781747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2206C746 for ; Fri, 25 Jan 2019 17:39:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E3DC2F92F for ; Fri, 25 Jan 2019 17:39:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C4B2F9CE; Fri, 25 Jan 2019 17:39:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 2F33A2F92F for ; Fri, 25 Jan 2019 17:39:06 +0000 (UTC) Received: (qmail 21876 invoked by uid 550); 25 Jan 2019 17:39:05 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 21839 invoked from network); 25 Jan 2019 17:39:04 -0000 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==; 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 X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Kees Cook Acked-by: Pekka Enberg --- 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);