I noticed that, in struct pid in
pid.h,
the member numbers is defined as an array of size 1.
struct pid
{
refcount_t count;
unsigned int level;
spinlock_t lock;
/* lists of tasks that use this pid */
struct hlist_head tasks[PIDTYPE_MAX];
struct hlist_head inodes;
/* wait queue for pidfd notifications */
wait_queue_head_t wait_pidfd;
struct rcu_head rcu;
struct upid numbers[1];
};
However, in pid.c, the member is accessed with indices other than 0.
pid->numbers[i].nr = nr;
How does this work without writing out of bounds?