From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Brian Mak <makb@juniper.net>, Kees Cook <kees@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v3] binfmt_elf: Dump smaller VMAs first in ELF cores
Date: Fri, 09 Aug 2024 09:39:54 -0500 [thread overview]
Message-ID: <875xs93glh.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <CAHk-=wh_P7UR6RiYmgBDQ4L-kgmmLMziGarLsx_0bUn5vYTJUw@mail.gmail.com> (Linus Torvalds's message of "Tue, 6 Aug 2024 11:33:12 -0700")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Tue, 6 Aug 2024 at 11:16, Brian Mak <makb@juniper.net> wrote:
>>
>> @@ -1253,5 +1266,8 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
>> cprm->vma_data_size += m->dump_size;
>> }
>>
>> + sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
>> + cmp_vma_size, NULL);
>> +
>> return true;
>> }
>
> Hmm. Realistically we only dump core in ELF, and the order of the
> segments shouldn't matter.
>
> But I wonder if we should do this in the ->core_dump() function
> itself, in case it would have mattered for other dump formats?
>
> IOW, instead of being at the bottom of dump_vma_snapshot(), maybe the
> sorting should be at the top of elf_core_dump()?
>
> And yes, in practice I doubt we'll ever have other dump formats, and
> no, a.out isn't doing some miraculous comeback either.
>
> But I bet you didn't test elf_fdpic_core_dump() even if I bet it (a)
> works and (b) nobody cares.
>
> So moving it to the ELF side might be conceptually the right thing to do?
>
> (Or is there some reason it needs to be done at snapshot time that I
> just didn't fully appreciate?)
I asked him to perform this at snapshot time. Plus it is obvious at
snapshot time that you can change the allocated array, while it is
not so obvious in the ->core_dump methods.
I would argue that the long term maintainable thing to do is to
merge elf_core_dump and elf_fdpic_core_dump and put all of the code
in fs/coredump.c
Performing the sort at snapshot time avoids introducing one extra reason
why the two elf implementations of elf coredumping are different.
I did read through the elf fdpic code quickly and it looks like it
should just work no matter which order the vma's are dumped in. Just
like the other elf coredump code does.
My practical concern is that someone has a coredump thing that walks
through the program headers and short circuits the walk because it knows
the program headers are all written in order. But the only way to find
one of those is to just try it.
Eric
next parent reply other threads:[~2024-08-09 14:40 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 [this message]
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
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=875xs93glh.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=makb@juniper.net \
--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