From 3e3e85a2c00b8a573f17b56daec2460cb2c9ba7d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 1 Oct 2024 12:56:06 +0000 Subject: [PATCH] Revert "pid: Replace struct pid 1-element array with flex-array" This reverts commit 5ea9dcfcd96bd0fb9b3c040c361ec31f896c5225 which is commit b69f0aeb068980af983d399deafc7477cec8bc04 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Id78fddc05ab98cf79beff0adc409fbc588f7499f Signed-off-by: Greg Kroah-Hartman --- include/linux/pid.h | 2 +- kernel/pid.c | 7 ++----- kernel/pid_namespace.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index bf3af54de616..343abf22092e 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -67,7 +67,7 @@ struct pid /* wait queue for pidfd notifications */ wait_queue_head_t wait_pidfd; struct rcu_head rcu; - struct upid numbers[]; + struct upid numbers[1]; }; extern struct pid init_struct_pid; diff --git a/kernel/pid.c b/kernel/pid.c index b28f928af8d4..9efcf7178b01 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -662,11 +662,8 @@ void __init pid_idr_init(void) idr_init(&init_pid_ns.idr); - init_pid_ns.pid_cachep = kmem_cache_create("pid", - struct_size((struct pid *)NULL, numbers, 1), - __alignof__(struct pid), - SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT, - NULL); + init_pid_ns.pid_cachep = KMEM_CACHE(pid, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); } static struct file *__pidfd_fget(struct task_struct *task, int fd) diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index a575fabf697e..1daadbefcee3 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -47,7 +47,7 @@ static struct kmem_cache *create_pid_cachep(unsigned int level) return kc; snprintf(name, sizeof(name), "pid_%u", level + 1); - len = struct_size((struct pid *)NULL, numbers, level + 1); + len = sizeof(struct pid) + level * sizeof(struct upid); mutex_lock(&pid_caches_mutex); /* Name collision forces to do allocation under mutex. */ if (!*pkc)