From: Christian Brauner <brauner@kernel.org>
To: Kees Cook <keescook@chromium.org>
Cc: Jan Kara <jack@suse.cz>,
Andreas Gruenbacher <agruenba@redhat.com>,
Daniel Verkamp <dverkamp@chromium.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Jeff Xu <jeffxu@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Boqun Feng <boqun.feng@gmail.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
syzbot+ac3b41786a2d0565b6d5@syzkaller.appspotmail.com,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] pid: Replace struct pid 1-element array with flex-array
Date: Sat, 1 Jul 2023 08:24:15 +0200 [thread overview]
Message-ID: <20230701-umspielen-wohin-de72fcaa7bbc@brauner> (raw)
In-Reply-To: <20230630180418.gonna.286-kees@kernel.org>
On Fri, Jun 30, 2023 at 11:04:22AM -0700, Kees Cook wrote:
> 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 when entering a pid namespace:
> https://lore.kernel.org/lkml/20230517-bushaltestelle-super-e223978c1ba6@brauner
>
> For example: unshare --fork --pid --mount-proc readlink /proc/self
>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Jan Kara <jack@suse.cz>
> 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
> Closes: https://lore.kernel.org/lkml/000000000000c6de2a05fbdecbbb@google.com/
> Acked-by: Jeff Xu <jeffxu@google.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> v2:
> - drop pointer math to array index conversions (torvalds)
> - use struct_size_t now that it exists (torvalds)
> - updated commit log with reproducer example
Thanks for that. Linus already merged the other version I gave him with
his requested changes but without your struct_size_t() update. It didn't
exist when you originally sent that patch afaiu and I just realized that
it existed right now. In any case, I'm just going to send a trivial
follow-up patch switching the two places to struct_size_t().
Thanks, Kees!
prev parent reply other threads:[~2023-07-01 6:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 18:04 Kees Cook
2023-06-30 19:00 ` Gustavo A. R. Silva
2023-07-01 6:24 ` Christian Brauner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230701-umspielen-wohin-de72fcaa7bbc@brauner \
--to=brauner@kernel.org \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=boqun.feng@gmail.com \
--cc=dverkamp@chromium.org \
--cc=frederic@kernel.org \
--cc=jack@suse.cz \
--cc=jeffxu@google.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=paulmck@kernel.org \
--cc=syzbot+ac3b41786a2d0565b6d5@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®