Kees Cook b69f0aeb06 pid: Replace struct pid 1-element array with flex-array
For pid namespaces, struct pid uses a dynamically sized array member,
"numbers".  This was implemented using the ancient 1-element fake
flexible array, which has been deprecated for decades.

Replace it with a C99 flexible array, refactor the array size
calculations to use struct_size(), and address elements via indexes.
Note that the static initializer (which defines a single element) works
as-is, and requires no special handling.

Without this, CONFIG_UBSAN_BOUNDS (and potentially
CONFIG_FORTIFY_SOURCE) will trigger bounds checks:

  https://lore.kernel.org/lkml/20230517-bushaltestelle-super-e223978c1ba6@brauner

Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Xu <jeffxu@google.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Jeff Xu <jeffxu@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Reported-by: syzbot+ac3b41786a2d0565b6d5@syzkaller.appspotmail.com
[brauner: dropped unrelated changes and remove 0 with NULL cast]
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-06-30 09:04:01 -07:00
..
2023-06-24 14:52:28 -07:00
2022-12-02 11:25:00 +01:00
2023-06-29 21:12:20 -07:00
2022-12-21 14:31:52 -08:00
2023-06-26 11:05:49 +02:00
2023-04-28 14:53:30 -07:00
2023-06-28 15:51:08 -07:00
2023-06-27 16:54:21 -07:00
2023-06-27 21:24:18 -07:00
2022-08-29 19:47:03 -04:00
2022-09-26 10:13:13 -07:00
2023-03-24 11:01:29 +01:00
2023-06-28 15:51:08 -07:00
2023-06-28 15:51:08 -07:00
2023-04-20 22:55:35 -04:00
2023-06-09 17:44:15 -07:00
2023-06-28 16:05:21 -07:00
2023-06-28 16:05:21 -07:00
2023-06-27 16:32:52 -07:00