From nobody Sun Feb 8 12:36:30 2026 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 D16953F0751 for ; Thu, 22 Jan 2026 15:18:59 +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=1769095139; cv=none; b=h0DZpEfxv6uRmdq5c92UeKuzMJgeleqZHCNLOduKu/nZQ0BZ/Dgjop8cXeQMk6rw8xvlVhGlPzhHtAky4w/2A0OQ/p3Gd9rql8+yBcgnq5We7zcOnBp2LMnhoFqIqnC1nEgCVTCDSSpk+sD5/KPmgtiucdzSLrf7fMLhj7E+tvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769095139; c=relaxed/simple; bh=272BvbxC7euhCsy4Z4uBhOtqpvh5RkKjXvXKDX/+ojY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F3Dr567qSlek+CEU9gEpmR2hccQPeVOo46neyhCO+3g2we9ZHBV/XjhAibnW4BZeA3TJGtjMPNu/5/cEM9UsfxGA+S4eR39BgiteeX4Z6zCwoKm2rq5uhml8IsgzV7ojuzW6aEHCtNT3fVd7v6/FUcZFLG5p9KS51G0TGMFTLes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F2B/t0Bt; 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="F2B/t0Bt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18692C4AF0B; Thu, 22 Jan 2026 15:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769095139; bh=272BvbxC7euhCsy4Z4uBhOtqpvh5RkKjXvXKDX/+ojY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2B/t0BtpaipEuqECr6q2CJUfcQms0HLxJ1OR2GUvVK3VTqXTupSVgtZ393faJZS7 dQHSzB5HL5WVRoPI4ukuPgq0d/qGc7gxjesKU+pdoSlachfAsOmjvl5EJQtZvZ98cf Gp2gxyG+vB+3v1oSUkc9y0Rh8oIjWfDS/aWB/NydQt1SjKfF7jsTWJZCSF9q4wDsww 7qizAlroyUkBBvubpL9dkVQsVt1+hSTdmt0fq6l7LUBAv8jv4z5PTv1UZZCFrnO2KG Rp3XuvFMJSQIO+AGJDB+u0tQRtAgTYNvF4hTXVH0vo5/zcIP1tQMXwmuCIG/0JvOKV Nn8gSvDHKY5+g== From: Pratyush Yadav To: Hugh Dickins , Baolin Wang , Andrew Morton , Pasha Tatashin , Mike Rapoport , Pratyush Yadav Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] memfd: export alloc_file() Date: Thu, 22 Jan 2026 16:18:39 +0100 Message-ID: <20260122151842.4069702-2-pratyush@kernel.org> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog In-Reply-To: <20260122151842.4069702-1-pratyush@kernel.org> References: <20260122151842.4069702-1-pratyush@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Pratyush Yadav (Google)" The Live Update Orchestrator's (LUO) memfd preservation works by preserving all the folios of a memfd, re-creating an empty memfd on the next boot, and then inserting back the preserved folios. Currently it creates the file by directly calling shmem_file_setup(). This leaves out other work done by alloc_file() like setting up the file mode, flags, or calling the security hooks. Export alloc_file() to let memfd_luo use it. Rename it to memfd_alloc_file() since it is no longer private and thus needs a subsystem prefix. Signed-off-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Pasha Tatashin --- include/linux/memfd.h | 6 ++++++ mm/memfd.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/memfd.h b/include/linux/memfd.h index cc74de3dbcfe..c328a7b356d0 100644 --- a/include/linux/memfd.h +++ b/include/linux/memfd.h @@ -17,6 +17,7 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff= _t idx); * to by vm_flags_ptr. */ int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr); +struct file *memfd_alloc_file(const char *name, unsigned int flags); #else static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned in= t a) { @@ -31,6 +32,11 @@ static inline int memfd_check_seals_mmap(struct file *fi= le, { return 0; } + +static inline struct file *memfd_alloc_file(const char *name, unsigned int= flags) +{ + return ERR_PTR(-EINVAL); +} #endif =20 #endif /* __LINUX_MEMFD_H */ diff --git a/mm/memfd.c b/mm/memfd.c index ab5312aff14b..f032c6052926 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -456,7 +456,7 @@ static char *alloc_name(const char __user *uname) return ERR_PTR(error); } =20 -static struct file *alloc_file(const char *name, unsigned int flags) +struct file *memfd_alloc_file(const char *name, unsigned int flags) { unsigned int *file_seals; struct file *file; @@ -520,5 +520,5 @@ SYSCALL_DEFINE2(memfd_create, return PTR_ERR(name); =20 fd_flags =3D (flags & MFD_CLOEXEC) ? O_CLOEXEC : 0; - return FD_ADD(fd_flags, alloc_file(name, flags)); + return FD_ADD(fd_flags, memfd_alloc_file(name, flags)); } --=20 2.52.0.457.g6b5491de43-goog