]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
memfd: implement get_id for memfd_luo
authorPasha Tatashin <pasha.tatashin@soleen.com>
Thu, 26 Mar 2026 16:39:42 +0000 (16:39 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 18 Apr 2026 07:10:49 +0000 (00:10 -0700)
Memfds are identified by their underlying inode.  Implement get_id for
memfd_luo to return the inode pointer.  This prevents the same memfd from
being managed twice by LUO if the same inode is pointed by multiple file
objects.

Link: https://lore.kernel.org/20260326163943.574070-3-pasha.tatashin@soleen.com
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Cc: David Matlack <dmatlack@google.com>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memfd_luo.c

index bc7f4f045edff7cfc82b390a0052780f0cdbcaf5..9130e6ce396d8f65b5ee0f2a971256b2974fc545 100644 (file)
@@ -560,6 +560,11 @@ static bool memfd_luo_can_preserve(struct liveupdate_file_handler *handler,
        return shmem_file(file) && !inode->i_nlink;
 }
 
+static unsigned long memfd_luo_get_id(struct file *file)
+{
+       return (unsigned long)file_inode(file);
+}
+
 static const struct liveupdate_file_ops memfd_luo_file_ops = {
        .freeze = memfd_luo_freeze,
        .finish = memfd_luo_finish,
@@ -567,6 +572,7 @@ static const struct liveupdate_file_ops memfd_luo_file_ops = {
        .preserve = memfd_luo_preserve,
        .unpreserve = memfd_luo_unpreserve,
        .can_preserve = memfd_luo_can_preserve,
+       .get_id = memfd_luo_get_id,
        .owner = THIS_MODULE,
 };