NetBSD Problem Report #55541

From www@netbsd.org  Tue Aug  4 23:31:58 2020
Return-Path: <www@netbsd.org>
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 "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 78A6C1A9217
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  4 Aug 2020 23:31:58 +0000 (UTC)
Message-Id: <20200804233157.A7F5E1A923A@mollari.NetBSD.org>
Date: Tue,  4 Aug 2020 23:31:57 +0000 (UTC)
From: coypu@sdf.org
Reply-To: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Subject: mmap(2) needs some updates
X-Send-Pr-Version: www-1.0

>Number:         55541
>Category:       kern
>Synopsis:       mmap(2) needs some updates
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 04 23:35:00 +0000 2020
>Last-Modified:  Wed Aug 05 15:20:01 +0000 2020
>Originator:     coypu
>Release:        NetBSD 9.99.69
>Organization:
>Environment:
NetBSD planets 9.99.69 NetBSD 9.99.69 (GENERIC) #1: Wed Aug  5 02:06:58 IDT 2020  fly@planets:/cvs/obj/sys/arch/amd64/compile/GENERIC amd64

>Description:
mmap(2) says:

If addr is non-zero, it is used as a hint to the system.

Without conditionalizing this on MAP_FIXED.

Additionally, the behaviour of MAP_TRYFIXED might be wrong from the actual behaviour. Two people recalled it as being "if the mapping already exists, fail", because MAP_FIXED unmaps the previous mapping.

The manual page, however, claims it would take "addr" as a hint in this situation.

Should confirm that the two people are right, then update the manual page for this.
>How-To-Repeat:

>Fix:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/55541: mmap(2) needs some updates
Date: Wed, 5 Aug 2020 18:19:53 +0300

 I'm not etnirely sure what your concern is.

 On Tue, Aug 04, 2020 at 23:35:01 +0000, coypu@sdf.org wrote:

 > If addr is non-zero, it is used as a hint to the system.
 > 
 > Without conditionalizing this on MAP_FIXED.

 I wonder if you are reading "MAP_FIXED" as implied by "hint" and then
 think it's a bug that it's implied and not explicit.  But I'm not sure
 it is the case.

 SUS says:

   When MAP_FIXED is set in the flags argument, the implementation is
   informed that the value of pa shall be addr, exactly. [...]

   When MAP_FIXED is not set, the implementation uses addr in an
   implementation-defined manner to arrive at pa. [...]

 I think hint is vague^Wbroad enough to be just the right word here.


 > Additionally, the behaviour of MAP_TRYFIXED might be wrong from the
 > actual behaviour. Two people recalled it as being "if the mapping
 > already exists, fail", because MAP_FIXED unmaps the previous
 > mapping.
 >
 > The manual page, however, claims it would take "addr" as a hint in
 > this situation.

 As I said, I don't think "hint" is a problem in general.  The bigger
 problem here is IMO the phrase "normally protected" which is very
 ambiguous.

 -uwe

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.