From: Kees Cook <kees@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>,
Michael Stapelberg <michael@stapelberg.ch>,
Brian Mak <makb@juniper.net>,
Christian Brauner <brauner@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Oleg Nesterov <oleg@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v3] binfmt_elf: Dump smaller VMAs first in ELF cores
Date: Wed, 19 Feb 2025 17:36:37 -0800 [thread overview]
Message-ID: <202502191731.16FBB1EB@keescook> (raw)
In-Reply-To: <CAHk-=wgiwRrrcJ_Nc95jL616z=Xqg4TWYXRWZ1t_GTLnvTWc7w@mail.gmail.com>
On Wed, Feb 19, 2025 at 04:39:41PM -0800, Linus Torvalds wrote:
> On Wed, 19 Feb 2025 at 11:52, Kees Cook <kees@kernel.org> wrote:
> >
> > Yeah, I think we need to make this a tunable. Updating the kernel breaks
> > elftools, which isn't some weird custom corner case. :P
>
> I wonder if we could also make the default be "no sorting" if the
> vma's are all fairly small...
>
> IOW, only trigger the new behavior when nity actually *matters*.
>
> We already have the code to count how big the core dump is, it's that
>
> cprm->vma_data_size += m->dump_size;
>
> in dump_vma_snapshot() thing, so I think this could all basically be a
> one-liner that does the sort() call only if that vma_data_size is
> larger than the core-dump limit, or something like that?
>
> That way, the normal case could basically work for everybody, and the
> system tunable would be only for people who want to force a certain
> situation.
>
> Something trivial like this (ENTIRELY UNTESTED) patch, perhaps:
>
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -1256,6 +1256,10 @@ static bool dump_vma_snapshot(struct
> coredump_params *cprm)
> cprm->vma_data_size += m->dump_size;
> }
>
> + /* Only sort the vmas by size if they don't all fit in the
> core dump */
> + if (cprm->vma_data_size < cprm->limit)
> + return true;
> +
> sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
> cmp_vma_size, NULL);
>
> Hmm?
Oh! That's a good idea. In theory, a truncated dump is going to be
traditionally "unusable", so a sort shouldn't hurt tools that are
expecting a complete dump.
Brian, are you able to test this for your case?
-Kees
--
Kees Cook
next prev parent reply other threads:[~2025-02-20 1:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <036CD6AE-C560-4FC7-9B02-ADD08E380DC9@juniper.net>
[not found] ` <CAHk-=wh_P7UR6RiYmgBDQ4L-kgmmLMziGarLsx_0bUn5vYTJUw@mail.gmail.com>
2024-08-09 14:39 ` Eric W. Biederman
2024-08-09 15:13 ` Linus Torvalds
[not found] ` <172300808013.2419749.16446009147309523545.b4-ty@kernel.org>
2024-08-10 0:52 ` Brian Mak
2024-08-10 4:06 ` Kees Cook
2024-08-10 12:28 ` Eric W. Biederman
2024-08-12 18:05 ` Kees Cook
2024-08-12 18:21 ` Brian Mak
2024-08-12 18:25 ` Kees Cook
2025-02-18 8:54 ` Michael Stapelberg
2025-02-18 19:53 ` Brian Mak
2025-02-19 13:28 ` Sam James
2025-02-19 16:20 ` Jan Kara
2025-02-19 19:52 ` Kees Cook
2025-02-19 20:38 ` Brian Mak
2025-02-22 2:13 ` Brian Mak
2025-02-22 14:51 ` Kees Cook
2025-02-20 0:23 ` Brian Mak
2025-02-20 0:39 ` Linus Torvalds
2025-02-20 1:36 ` Kees Cook [this message]
2025-02-20 22:59 ` Brian Mak
2025-02-22 15:15 ` Kees Cook
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=202502191731.16FBB1EB@keescook \
--to=kees@kernel.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=makb@juniper.net \
--cc=michael@stapelberg.ch \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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