Revert "pid: Replace struct pid 1-element array with flex-array"

This reverts commit 5ea9dcfcd9 which is
commit b69f0aeb06 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 <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-10-01 12:56:06 +00:00
parent 524ae3c9d3
commit 3e3e85a2c0
3 changed files with 4 additions and 7 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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)