NetBSD Problem Report #50986

From martin@duskware.de  Sun Mar 20 12:53:40 2016
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 464877ABDF
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 20 Mar 2016 12:53:40 +0000 (UTC)
Date: Sun, 20 Mar 2016 13:53:37 CET
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: pax_aslr_mmap() may produce out of bounds results
X-Send-Pr-Version: 3.95

>Number:         50986
>Category:       kern
>Synopsis:       pax_aslr_mmap() may produce out of bounds results
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 20 12:55:00 +0000 2016
>Closed-Date:    Tue May 24 20:22:45 +0000 2016
>Last-Modified:  Tue May 24 20:22:45 +0000 2016
>Originator:     Martin Husemann
>Release:        NetBSD 7.99.26
>Organization:
The NetBSD foundation, Inc.
>Environment:
System: NetBSD night-owl.duskware.de 7.99.26 NetBSD 7.99.26 (NIGHT-OWL) #393: Fri Mar 11 14:19:47 CET 2016 martin@night-owl.duskware.de:/usr/src/sys/arch/amd64/compile/NIGHT-OWL amd64
Architecture: x86_64
Machine: amd64
>Description:

When ASLR is enabled, sys_mmap() will invoke pax_aslr_mmap() to randomize
the mapping VA. This, however, may move the VA outside of the vmspaces valid
range (as pax_aslr_mmap is completely agnostic to any limits) and no further
checking is done (like a call to range_test).

This may lead to lock ups later in uvm_mmap() when pmap_enter() fails for
the mapping (due to an invalid address) and the process goes into an
infinite wait on "flt_pmfail2".

>How-To-Repeat:

on sparc64:
cp /bin/hostname /tmp
paxctl +A /tmp/hostname
/tmp/hostname

and be lucky if you only get a segfault.

>Fix:
Make the randomization inside ASLR aware of vmpspace limits.

Unrelated to that, the "flt_pmfail2" should probably not happen for this
kind of inherently persistent failures (depending on pmap_enter() return
value).

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Tue, 24 May 2016 20:22:45 +0000
State-Changed-Why:
Christos fixed it


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.