From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 40E4D3858401 for ; Wed, 5 Jun 2024 18:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40E4D3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 40E4D3858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717612937; cv=none; b=MXfDI71BTj2lbsLc4NLdtyopSJuMvQNK1AfBN/Ndnb4pI1VA5/WaAIA6prIVPcjmaQiWKzQFmxnBQmWOqjohS/oZ/U9F3JWo3Kz1xjkB92cgayrCv3yFxlxFF85RqwvCxAKUHCcHI2IE4U3rIDQ+1vDbMCPFzDoGQj6R0dlwsLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717612937; c=relaxed/simple; bh=9NAtyUHlMcolaYfUcxhhuoTfTtQDfBtdW4scfO0QJZ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=S+QNNWZzHtT0Z0y2VfoJxhZcVQEY/C/2McjYnAeJ5EL7ebBjJoFCFQE4+++kCB0Szvxi76dYL/vdrBgSbtSDkVfRbJyrG63DuUu+dTnhFLFB0FOsjpSnR5CmkxZG4gD/xyhapCAropPdXALeJeHg4EYcCfpgK8NvoZto2UhEKPo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717612935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=bPSvcuzvKTnrT8LqviU5xtHeeqk9F0TUFm3i6jOUMj4=; b=JWebq7BAmk6PEN7r2tpyWoNbeHF9mTzLGIpUKMOpzCpJb1ckMKD/ram87bQDRsBDIw2Ze3 l+mFLaNqLgcw8qufy30/aGgaH/9QXW0zGgs1BW8ttSXUhm/qQ7O7RHSwZeEuoWLWJ+JczQ X1yqgiHcuSHSGV/1VQNNX7Gncm8176c= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-mfvoMtrIPMidcQXLdakpBQ-1; Wed, 05 Jun 2024 14:42:14 -0400 X-MC-Unique: mfvoMtrIPMidcQXLdakpBQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2FCE195E930 for ; Wed, 5 Jun 2024 18:42:13 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.10.130]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0A700300060C; Wed, 5 Jun 2024 18:42:12 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.16.1/8.16.1) with ESMTP id 455IgBRg117121; Wed, 5 Jun 2024 14:42:11 -0400 From: DJ Delorie To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: Re: Update mmap() flags and errors lists In-Reply-To: <875xunzyf9.fsf@oldenburg3.str.redhat.com> (message from Florian Weimer on Wed, 05 Jun 2024 08:38:50 +0200) Date: Wed, 05 Jun 2024 14:42:11 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Florian Weimer writes: > What I meant is that they aren't part of . So they aren't. We define the shift macros, though... Removed. >> I would assume it interacts with MAP_SHARED_VALIDATE exactly as >> documented. Creates a shared fixed mapping, unless the kernel doesn't >> support MAP_FIXED_NOREPLACE, then errors. > > The question is if MAP_FIXED_NOREPLACE can be silently treated as > MAP_FIXED. I wouldn't think so. If the kernel supports it, it automatically includes MAP_FIXED. If the kernel doesn't support it, it's ignored. You'd have to pass MAP_FIXED | MAP_FIXED_NOREPLACE to get the "silent" treatment. If you needed MAP_PRIVATE | MAP_FIXED_NOREPLACE I suppose you'd have to do a test mapping with MAP_SHARED_VALIDATE | MAP_FIXED_NOREPLACE first, to see if the running kernel supports it. But this is the case for *any* flag. > Ahh, this refers to mlock/MAP_LOCKED? Please say so. We shouldn't > discuss mandatory locking support. Ok, I'll take out mentions of these locks. I assume this is different than the mlock() and MAP_LOCKED locks, yes? >>>> +@item EBADF >>>> + >>>> +The @var{fd} passes is invalid, and a valid file descriptor is required. >>> >>> Is a file descriptor ever required? >> >> If mapping a file, yes. That's the default ;-) > > Ah, right. Do we say anywhere that the fd argument is ignored for > MAP_ANONYMOUS? Yes. I reworded it a bit. @item MAP_ANONYMOUS @itemx MAP_ANON This flag tells the system to create an anonymous mapping, not connected to a file. @var{filedes} and @var{offset} are ignored, and the region is initialized with zeros. >>>> +@item EOVERFLOW >>>> + >>>> +Either the offset into the file causes the page counts to exceed the >>>> +range of a 32 bit number, or the offset requested exceeds the length >>>> +of the file. >>> >>> The reference to page size may be incorrect. I think it's a fixed >>> offset regardless of page size on systems that can't pass a 64-bit file >>> offset. >> >> The code I was looking at was talking about having 2^32 *pages* mapped. > > See MMAP2_PAGE_UNIT. On most architectures, it's fixed at 4096, > regardless of page size. > > And it turns out that we do not check that the offset argument fits into > 32 bits after dividing by MMAP2_PAGE_UNIT (on targets where this > matters). The documentation implies we should return EOVERFLOW in this > case. /* offset overflow? */ if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) return -EOVERFLOW; the man pages describe it thusly: EOVERFLOW On 32-bit architecture together with the large file extension (i.e., using 64-bit off_t): the number of pages used for length plus number of pages used for offset would overflow unsigned long (32 bits). I reworded it to be a bit more correct and at the same time vague ;-)