Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp578267img; Fri, 22 Mar 2019 04:25:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqkL6d9snWTy7x2BkHAOnvx0l9gHQVh1tfNJ6u4M2eqORYgQcszYR3G5YLEikQWAV+tyF6 X-Received: by 2002:a17:902:8d89:: with SMTP id v9mr9110304plo.254.1553253943387; Fri, 22 Mar 2019 04:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253943; cv=none; d=google.com; s=arc-20160816; b=JOTDZBrbJE5Hbdh1ITF1FBTzzeMP22x4224pcsORxC5+T9aGU6ofiaFhshPrpxA4si YgLqRtie1Js51dQGR7f060YYI1OCWX6Ehngu5VYPEZ6BRXJPElvKnprZEaAg3zjdOW7J ex3XaGhG5iJ2lQIfcPGP2wch/3ADSEsFn5DZszxxIqX4GA9nIL/1SKKbsDcHL26yGMuz ZEqHUbTlaHbQJtjVwtLmZGBwojqNKBzHlI+IGWAzqqzlIvE+lPe+XMpdKXkMy+G30Zn1 duVSnrcuuGgvPRZwkBt8QjesOZQMsCdcwZTXucAMZt1zArIBRuC/Nr3R+cokwpQr+1t6 C+/g== 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=RAKC14ZGeF2hEev0hvelxWIrSnXljKzrYH3tOc4POCY=; b=X2sZ+VW0IFuTbF+LVTJEHpmeGrH8C2v00hs7ycufO5sqMljTqgO8jMtnny8mA8aOee /G976COu/5sy4uHzJzjujbYjBTMpDebyNNtSHRxwYsG2lvn5ReM3PeCKl08zRFPhurRs nHRpSV7mh5u3JX9T1ywQIVadcrA0UdvBPm3FgveXELzNdfs5ribLCh/SjFJSVQ3MyyRU J2bQfkhfojRePLKHL2U4VE7OywkJIAbPcC2YwEGt+moc+12NpA/DMzhF9bscT7hF4RWa fUlm9ZXAWwL3fHnZ88m+ZpLh1QoqGRmIX/Heg/6rK5A4XC1Tqbyb8imJlFAVhADNh7hE UvLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QJrXadRi; 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 p19si6838820plq.29.2019.03.22.04.25.26; Fri, 22 Mar 2019 04:25:43 -0700 (PDT) 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=QJrXadRi; 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 S1728344AbfCVLW3 (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:29 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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;