Received: from fhigh-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58A94363C55 for ; Thu, 21 May 2026 08:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779352636; cv=none; b=LDbtL+vVaylyQdFiRkWpy3gbpBJ1hpysF9bR9eCfjGMa/5c+75KLSlpeXHTGnCoMS+temIU5/B8ryFhxb5OCvY+FHqC+orq6ouMyAt8yniEodLZS2g2YG1IwmAZLAVb016y1PKZvAxwjb8utmbtfUvsNcEEPArIXUbVqHngMqlw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779352636; c=relaxed/simple; bh=XO7s3PogGSqAtiohDJKPSrMK6XckUenkjIrSK4nw42U=; h=MIME-Version:Date:From:To:Message-Id:In-Reply-To:References: Subject:Content-Type; b=JrHSmz/6a8Mlo0gE2wVEelpW7bR1EffD2+TBE2UdpH8uzi/h/TPpdff/Ye6C1u24SJI6094NhJJuBZAXs/nyJSVq97OrN9CoZD9L3tY4oL7tOY6SbGF3tScN1fx1peLj9xqXAgSMNmVEgxmZhw6c6bHAQNORjW/LDXGBfPsmzOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=NaJGIJ5R; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RCNRQz/f; arc=none smtp.client-ip=202.12.124.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="NaJGIJ5R"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RCNRQz/f" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 5CF0F7A00DD; Thu, 21 May 2026 04:37:13 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-04.internal (MEProxy); Thu, 21 May 2026 04:37:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1779352633; x=1779439033; bh=KoXfksjtOuPpWflfbfNiTBgddSHnoYBcPCXTP9uDtV4=; b= NaJGIJ5R4ZFNjpy4Ysa0nIy/ayo6O4DLvlvpRmwNpwvW37LA3wn5LiTpRWdgSAYW mNOKRm90DrN8PXM+KlXeg5hOpie52Dxd8vGMYpPMd2zgH4oVPgNbcEPTjcLbtO6c sxhC2o3N+YtdQJunKLjEBK3SMh+NBNpi95fsLs9QGGfpkFMrwHO5EiW3US3QJNGw MAc89/0966xcttBv44GP80m3hczFj8Zg9l507/E7Kv9hWsPKyrIPTeX3j3Jv1lhR d5h7jM0mtacPFD8FBQeDExUZtwuElZ2TIzr6qtvG2OutgEEhUVHry1I92R/dvhEC mxsIVyJh+us9iuz6L2hqRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1779352633; x=1779439033; bh=K oXfksjtOuPpWflfbfNiTBgddSHnoYBcPCXTP9uDtV4=; b=RCNRQz/fDmC5peiWe BSOv39qMRsz+8c3FjTVVuXfImD8LXPl3TRj51QQePETtZSxGZQNal2cQFDSnHOaj kQIl8QH038UyLPwij0FVdHG6iSSYJNSw5B98NwBaRWZ9ARzB39uvg4WmyXOI02+Y MEZdQbT0N230DCvLNS9LzvJsj42QmnlcQcfA60C+Wcu9Z/2r0aMvpUsoTff55Drk QDqbKT/sgL6agYpWHe3EWt4cxCdLRwcSGTtJ+tKyDUTeYJIcl0JydBFey9M3quNy IHi4BxVk4O4nkE+4iz/SQwtqUCNykHUO9dPvwvRbm4JZyY1Fd4lm58zxVUoktNX6 biAbw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddugeejtdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdetrhhnugcu uegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtthgvrh hnpefhkeeltdfffefhgffhteetheeuhffgteeghfdtueefudeuleetgfehtdejieffhfen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrhhnug esrghrnhgusgdruggvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopegvrhhrohhrvdejsehgmhgrihhlrdgtohhmpdhrtghpthhtohepsghrrg hunhgvrheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepughrihdquggvvhgvlheslhhi shhtshdrfhhrvggvuggvshhkthhophdrohhrghdprhgtphhtthhopehlihhnuhigqdhfsh guvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id EBB59182007A; Thu, 21 May 2026 04:37:12 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: Aw18F5Y_n0hN Date: Thu, 21 May 2026 10:36:52 +0200 From: "Arnd Bergmann" To: "Dan Carpenter" , linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Christian Brauner" Message-Id: In-Reply-To: References: Subject: Re: FOP_UNSIGNED_OFFSET abuse Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, May 21, 2026, at 09:09, Dan Carpenter wrote: > Is there a point to FOP_UNSIGNED_OFFSET now that everyone is on 64bit? > I thought the flag was for back in the day where we it was a huge deal > to access 4GB instead of 2GB. > > It's mostly used in DRM. drm_open_helper() forces you to set the flag > but drm_read() ignores the offset so I don't understand the point of > this. As far as I understand it, this is needed specifically for character devices with an mmap() file operation that encodes information in the high offset bits, see be83bbf80682 ("mmap: introduce sane default mmap limits"). For /dev/kmem, this is is needed to access the actual kernel memory on architectures that map it to negative addresses, and this one actually does llseek/read/write up to U64_MAX, which would be useful on 32-bit compat tasks reading 64-bit kernel memory, and we could probably just not do that. For the mmap() interface, I see that things are a bit messy in multiple ways: - DRM drivers on 32-bit kernels need this to mmap() GEM buffer objects that have a file offset just above ULONG_MAX, which is the limit in file_mmap_size_max() for character devices. As you pointed out, llseek/read/write does not have this limit. - mmap2() can never map up to ULLONG_MAX even with the flag, but is in practice limited to 2^44 (ULONG_MAX << 12) when FOP_UNSIGNED_OFFSET is set. - compat_mmap() checks against the 64-bit MAX_LFS_FILESIZE and ULONG_MAX in file_mmap_ok(), so it's actually able to map beyond these limits. I suppose this is not a bug itself, but is unexpected. - MAX_LFS_FILESIZE itself is defined as "((loff_t)ULONG_MAX << PAGE_SHIFT)" on 32-bit systems, but mmap2() actually uses a fixed 12 bit shift rather than PAGE_SHIFT on most architectures with a compile-time page size choice. Arnd