Commit e1d16022 authored by Mark Kettenis's avatar Mark Kettenis Committed by Greg Kroah-Hartman

[PATCH] Fix note sections in ELF core dumps

Edition 4.1 of the System V Application Binary Interface says that
"The first namesz bytes in name contains a null-terminated
representation of the entry's owner or originator".  This implies that
the terminating null is included in namesz, which is corroborated by
the example that follows the description.  However, this is not what
the Linux kernel does when it writes its notes into an ELF core dump.
The attached patch fixes this.
parent b131b195
...@@ -954,7 +954,7 @@ static int notesize(struct memelfnote *en) ...@@ -954,7 +954,7 @@ static int notesize(struct memelfnote *en)
int sz; int sz;
sz = sizeof(struct elf_note); sz = sizeof(struct elf_note);
sz += roundup(strlen(en->name), 4); sz += roundup(strlen(en->name) + 1, 4);
sz += roundup(en->datasz, 4); sz += roundup(en->datasz, 4);
return sz; return sz;
...@@ -989,7 +989,7 @@ static int writenote(struct memelfnote *men, struct file *file) ...@@ -989,7 +989,7 @@ static int writenote(struct memelfnote *men, struct file *file)
{ {
struct elf_note en; struct elf_note en;
en.n_namesz = strlen(men->name); en.n_namesz = strlen(men->name) + 1;
en.n_descsz = men->datasz; en.n_descsz = men->datasz;
en.n_type = men->type; en.n_type = men->type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment