]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
orangefs: add usercopy whitelist to orangefs_op_cache
authorZiyi Guo <n7l8m4@u.northwestern.edu>
Thu, 12 Feb 2026 02:08:06 +0000 (02:08 +0000)
committerMike Marshall <hubcap@omnibond.com>
Tue, 7 Apr 2026 15:22:18 +0000 (11:22 -0400)
orangefs_op_cache is created with kmem_cache_create(), which provides
no usercopy whitelist. orangefs_devreq_read() copies the tag and upcall
fields directly from slab objects to userspace via copy_to_user(). With
CONFIG_HARDENED_USERCOPY enabled, this triggers usercopy_abort().

Switch to kmem_cache_create_usercopy() with a whitelist covering the
tag and upcall fields, matching the pattern already used by
orangefs_inode_cache in super.c.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/orangefs-cache.c

index e75e173a918622b1c213c4e3862631fb29a2fa9a..0bdb99e8974479a967dceb70a6ab7b8380fc61b4 100644 (file)
@@ -19,10 +19,14 @@ static struct kmem_cache *op_cache;
 
 int op_cache_initialize(void)
 {
-       op_cache = kmem_cache_create("orangefs_op_cache",
+       op_cache = kmem_cache_create_usercopy("orangefs_op_cache",
                                     sizeof(struct orangefs_kernel_op_s),
                                     0,
                                     0,
+                                        offsetof(struct orangefs_kernel_op_s, tag),
+                                        offsetof(struct orangefs_kernel_op_s, upcall) +
+                                            sizeof(struct orangefs_upcall_s) -
+                                                offsetof(struct orangefs_kernel_op_s, tag),
                                     NULL);
 
        if (!op_cache) {