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 806AC4921B0 for ; Thu, 22 Jan 2026 15:45:34 +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=1769096734; cv=none; b=KjgX5zXJsIDoZax754UigMN6/t1749+8E2iZQth9NesqW8KPwCFGMaEu9K8Mg3WUmplbDpAu+vko9DByA0ruDbaSMEUf/Pdk7CxK47s+bjIIZhdz0fnBkMWXSdf5S7kIk3yTn89BPpazWtfyeKkR+b7/Y38Qoqw9Nn0YOhFyw18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769096734; c=relaxed/simple; bh=IEtFMgBTxuSlWSZBb+7iamkhUKr36/S0WZZoOua7U2Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HEylyP3tmLO3y7l8ob5GPhjzgg4yT+1BqMXGAoN7tQR64OXBEAs0xzHgvlgTe5gt3VW4jQcwfC5HXNOn//HEmvoccwBHOpOklMcPO1U3JpE35i4fmkUVNs8LcLV3u0HapdyG2CIxjQ88LI5SozDoEU3TGHQuX5zLZ6Yjk8kbOMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NWcEMUdh; 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="NWcEMUdh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BEB4C116C6; Thu, 22 Jan 2026 15:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769096733; bh=IEtFMgBTxuSlWSZBb+7iamkhUKr36/S0WZZoOua7U2Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NWcEMUdh5QS34sLusHqI+/BYARn57kwFbF8rP9yqxQSVYQbTThev2SdrQzP0kr839 nvFrSTjyQWTzTAhcZv94wXzIHasKGh8rjTvXlg3u7dzTqmgl/nOIuprC3GuEAyirQ1 CNQCazkH14D7dQK7xzzvQ4yCg5Zi+VXuc4EnPsQA6ZKD3AMMbZZGppdYMnf0jqjkK0 ph5AJzN+KilJfXaK4DxZcRxvTWanRrXl44SAgj4gun2I+Y5vi9vO/DOiTiSuKzgLxQ 7CfrQD/FjBBLpBkFYkpb7sNkhIA45tHlzwwUt1Ly6gzq2OQaytZbCPGuBYKIgGor5O jxrtmSokqMNBA== Date: Thu, 22 Jan 2026 17:45:27 +0200 From: Mike Rapoport To: Pratyush Yadav Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Pasha Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] mm: memfd_luo: use memfd_alloc_file() instead of shmem_file_setup() Message-ID: References: <20260122151842.4069702-1-pratyush@kernel.org> <20260122151842.4069702-3-pratyush@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260122151842.4069702-3-pratyush@kernel.org> On Thu, Jan 22, 2026 at 04:18:40PM +0100, Pratyush Yadav wrote: > From: "Pratyush Yadav (Google)" > > When restoring a memfd, the file is created using shmem_file_setup(). > While memfd creation also calls this function to get the file, it also > does other things: > > 1. The O_LARGEFILE flag is set on the file. If this is not done, > writes on the memfd exceeding 2 GiB fail. > > 2. FMODE_LSEEK, FMODE_PREAD, and FMODE_PWRITE are set on the file. > This makes sure the file is seekable and can be used with pread() and > pwrite(). > > 3. Initializes the security field for the inode and makes sure that > inode creation is permitted by the security module. > > Currently, none of those things are done. This means writes above 2 GiB > fail, pread(), and pwrite() fail, and so on. lseek() happens to work > because file_init_path() sets it because shmem defines fop->llseek. > > Fix this by using memfd_alloc_file() to get the file to make sure the > initialization sequence for normal and preserved memfd is the same. > > Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd") > Signed-off-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) > --- > mm/memfd_luo.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c > index 4f6ba63b4310..01a72e4d3ef6 100644 > --- a/mm/memfd_luo.c > +++ b/mm/memfd_luo.c > @@ -78,6 +78,7 @@ > #include > #include > #include > +#include > #include "internal.h" > > static int memfd_luo_preserve_folios(struct file *file, > @@ -443,8 +444,7 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args) > if (!ser) > return -EINVAL; > > - file = shmem_file_setup("", 0, VM_NORESERVE); > - > + file = memfd_alloc_file("", 0); > if (IS_ERR(file)) { > pr_err("failed to setup file: %pe\n", file); > return PTR_ERR(file); > -- > 2.52.0.457.g6b5491de43-goog > -- Sincerely yours, Mike.