From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 13275314D0D for ; Mon, 4 May 2026 08:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777881906; cv=none; b=jx/nobc6VdDhfkTIAlr/AUocM7hjYPuCtaES6YlGF5gBsxGcsIEznPn5KgBK/9vpJbIQ23AnQyYsKA+AvGwBBrMPUg3mBuQ2/vc6qqCRyE0oiiZRXeKIct1l1d5jwXwnm/kS7Ae/byB2rB0dfT6TebXedZqu6gaUbzAsSFCoJkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777881906; c=relaxed/simple; bh=sgw7LcPcgijPezjeAjo0c0NIT2NcMK72lK9lat7L4gU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=AlVPX1S/y7GDyvI5ShrraubtKQyuRoAdnAU31d4dMfr4MKRrhQDlZ1M6QYWitsvd3zIDsvfprtKnKJan0+9lEy57o23AVL8H4Qt1ZbP0elRzkZoyhOCv3+8wdPe7CSC3jGavelWUNAGDNdIZXw7RNgIWPTzreJ5okpyGbJBImI4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=clZ63vox; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="clZ63vox" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DABCC2BCB8; Mon, 4 May 2026 08:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777881905; bh=sgw7LcPcgijPezjeAjo0c0NIT2NcMK72lK9lat7L4gU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=clZ63voxCVThA2Nayvoz6O+UjlaA9DDU4Mg62Y9ygdASi3msfm1CYKGs+EcrWNGBQ lHa5GoSoNErp+EGBY2I/bUxz+SXw4R7WTmY/U3Kv63VZr1iQJ7ZGNHOCIbPoC+XSw6 We7p6jpbb+JUT2RJ14DRdJ+bwwvWJJpPf/T5RjMpLPsx+jwXhDbC8ewjXrjh+buNwm k/BIyAUEXM3fqEHRIvYnohEL8e1IMenHmlyS5jaPCNvBjCGfaK74GtBX3gTFbc+sXn 2r9xtNjKPPzeBlb2gTkAMynxUc9I6hF83hwP0aVQYiP5Jc/UgSiiLgy2kOl9rl3yWy eBromN4hOqA3g== From: Pratyush Yadav To: Pasha Tatashin Cc: David CARLIER , akpm@linux-foundation.org, pratyush@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm/memfd_luo: reject memfds whose page count exceeds UINT_MAX In-Reply-To: (Pasha Tatashin's message of "Fri, 1 May 2026 19:38:34 +0000") References: <20260423125648.152113-1-devnexen@gmail.com> Date: Mon, 04 May 2026 10:05:03 +0200 Message-ID: <2vxzo6iv38i8.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, May 01 2026, Pasha Tatashin wrote: > On 05-01 20:26, David CARLIER wrote: >> On 2026-05-01 18:59, Pasha Tatashin wrote: >> > I think, the fix should be first done at memfd_pin_folios() to >> change >> > max_folios to 'long' or 'unsigned long', and then just updated >> > memfd_luo.c to match. >> >> Even with memfd_pin_folios() widened, memfd_luo_preserve_folios() >> still >> kvmalloc_objs()s the folios array up front -- at UINT_MAX entries >> that's >> already ~32 GiB of pointer array, which won't realistically succeed. >> So >> the guard here still makes sense, just on allocation grounds rather than >> interface truncation. >> >> Happy to widen memfd_pin_folios() as a separate patch, but I'd keep >> the >> -EFBIG check regardless. Or did you have a different shape in mind? > > Ah, Good point about kvmalloc_objs(), I am not against this, even though > it is a very theoretical issue. Yeah. I plan to get rid of the pinning anyway and do this via the page cache directly (might be easier said than done though), so this should be fine for now I think. I suspect we might run into a lot more problems if we get a memfd like this anyway. Reviewed-by: Pratyush Yadav > > Reviewed-by: Pasha Tatashin -- Regards, Pratyush Yadav