From: Oleg Nesterov <oleg@redhat.com>
To: Denys Vlasenko <vda.linux@gmail.com>
Cc: linux-kernel@vger.kernel.org,
"Jonathan M. Foote" <jmfoote@cert.org>,
"H. J. Lu" <hjl.tools@gmail.com>, Ingo Molnar <mingo@elte.hu>,
"H. Peter Anvin" <hpa@zytor.com>, Andi Kleen <ak@suse.de>,
Denys Vlasenko <dvlasenk@redhat.com>,
Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [PATCH] Extend core dump note section to contain file names of mapped files
Date: Wed, 11 Jul 2012 17:15:13 +0200 [thread overview]
Message-ID: <20120711151513.GA9314@redhat.com> (raw)
In-Reply-To: <CAK1hOcNWo2mV2nKmVEuzKzEs7pCveFCBFWrYSrMbj4Y7M8zQ6Q@mail.gmail.com>
On 07/11, Denys Vlasenko wrote:
>
> I propose to save this information in core dump, as a new note
> in note segment.
Denys, I am in no position to discuss whether we need this change or not,
format, etc. I'll only try to comment the code.
And please do not use the attachments ;)
> +static void fill_files_note(struct memelfnote *note)
> +{
> + struct vm_area_struct *vma;
> + struct file *file;
> + unsigned count, word_count, size, remaining;
> + long *data;
> + long *start_end_ofs;
> + char *name;
> +
> + count = 0;
> + for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
> + file = vma->vm_file;
> + if (!file)
> + continue;
> + count++;
> + if (count >= MAX_FILE_NOTE_SIZE / 64) /* paranoia check */
> + goto err;
Why this check? If count is huge, then...
> + size = count * 64;
> + word_count = 2 + 3 * count;
> + alloc:
> + if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */
> + goto err;
we should detect this case before the first alloc?
> + size = (size + PAGE_SIZE - 1) & (-PAGE_SIZE);
Well, I'd suggest PAGE_MASK instead of -PAGE_SIZE. Better yet,
size = round_up(size, PAGE_SIZE);
> + if (remaining == 0) {
> + try_new_size:
> + vfree(data);
> + size = size * 5 / 4;
> + goto alloc;
> + }
> + filename = d_path(&file->f_path, name, remaining);
> + if (IS_ERR(filename)) {
> + if (PTR_ERR(filename) == -ENAMETOOLONG)
> + goto try_new_size;
This looks like unnecessary complication to me, or I missed something.
d_path(..., buflen) should handle the "buflen == 0" case correctly, so
afacics you can remove the "if (remaining == 0)" block and move this
free-and-goto-alloc code under the -ENAMETOOLONG check.
> + while ((remaining--, *name++ = *filename++) != '\0')
> + continue;
Well, perhaps this is just me... but this looks a bit too complex
to me ;) I won't insist, but
do
remaining--;
while ((*name++ = *filename++));
looks more understandable, imho.
Or even
/* d_path() fills the end of the buffer */
remaining = name - filename;
strcpy(name, filename);
Oleg.
next prev parent reply other threads:[~2012-07-11 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 10:35 [PATCH] Extend core dump note section to contain file names of mapped files Denys Vlasenko
2012-07-11 15:15 ` Oleg Nesterov [this message]
2012-07-12 19:41 ` Denys Vlasenko
2012-07-11 15:40 ` Jonathan M. Foote
-- strict thread matches above, loose matches on Subject: below --
2012-03-31 20:51 Denys Vlasenko
2012-04-01 3:13 ` Andi Kleen
2012-04-01 3:20 ` H. Peter Anvin
2012-04-01 9:44 ` Andi Kleen
2012-04-01 13:33 ` Denys Vlasenko
2012-04-01 16:53 ` Andi Kleen
2012-04-02 0:24 ` Oleg Nesterov
2012-04-02 11:20 ` Pedro Alves
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=20120711151513.GA9314@redhat.com \
--to=oleg@redhat.com \
--cc=ak@suse.de \
--cc=dvlasenk@redhat.com \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=jan.kratochvil@redhat.com \
--cc=jmfoote@cert.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=vda.linux@gmail.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