From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 907C7C10F03 for ; Fri, 22 Mar 2019 13:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5AECD21873 for ; Fri, 22 Mar 2019 13:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553260788; bh=5jxII4wK9gKIOV/hSd0iUi57DZsnQBCIrJFg/6+fNok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AVLZFMRrRSnpiFIxG9OWgUdKib4cUv03ia9Pon4/ITilVCtFp6rTbE/ThhkdI6Q6i QhfWSW9wYzufhkVjMBlcXl+/fD72rGPCSJ8jl8ft7nvBWMjK0FWRln3qUE2M1p0gHM CzF6kcMB03d7hg8ZCmT8f++VT0+BLyn86ZgQLyTs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbfCVLW0 (ORCPT ); Fri, 22 Mar 2019 07:22:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:49168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728789AbfCVLWZ (ORCPT ); Fri, 22 Mar 2019 07:22:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 997852190A; Fri, 22 Mar 2019 11:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253745; bh=5jxII4wK9gKIOV/hSd0iUi57DZsnQBCIrJFg/6+fNok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJrXadRieEKlBW0nnIIrnLX4Fu2lAsCtcyHO2Mzx/8EhcvMjeG3IDhkXLH67yYKq0 5pAFBLLSdbjz24HU/CpBWmwmsPNtezO38uCnnhGC6Ud+4wzWPyC0oBeCSDfG9A+5nD Xk/dgYdzhhFuL3OMt8MEHafULBjNhF+RvEGtr3xI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Jann Horn , Linus Torvalds Subject: [PATCH 3.18 042/134] mm: enforce min addr even if capable() in expand_downwards() Date: Fri, 22 Mar 2019 12:14:15 +0100 Message-Id: <20190322111212.941263501@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jann Horn commit 0a1d52994d440e21def1c2174932410b4f2a98a1 upstream. security_mmap_addr() does a capability check with current_cred(), but we can reach this code from contexts like a VFS write handler where current_cred() must not be used. This can be abused on systems without SMAP to make NULL pointer dereferences exploitable again. Fixes: 8869477a49c3 ("security: protect from stack expansion into low vm addresses") Cc: stable@kernel.org Signed-off-by: Jann Horn Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/mmap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2292,12 +2292,11 @@ int expand_downwards(struct vm_area_stru { struct vm_area_struct *prev; unsigned long gap_addr; - int error; + int error = 0; address &= PAGE_MASK; - error = security_mmap_addr(address); - if (error) - return error; + if (address < mmap_min_addr) + return -EPERM; /* Enforce stack_guard_gap */ gap_addr = address - stack_guard_gap;