diff options
Diffstat (limited to 'fs/proc/kcore.c')
| -rw-r--r-- | fs/proc/kcore.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 17f6e8fa1397..1294eda4acae 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | * Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <kanoj@sgi.com> | 9 | * Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <kanoj@sgi.com> |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/config.h> | ||
| 13 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
| 14 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
| 15 | #include <linux/user.h> | 14 | #include <linux/user.h> |
| @@ -43,8 +42,6 @@ const struct file_operations proc_kcore_operations = { | |||
| 43 | #define kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET) | 42 | #define kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET) |
| 44 | #endif | 43 | #endif |
| 45 | 44 | ||
| 46 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | ||
| 47 | |||
| 48 | /* An ELF note in memory */ | 45 | /* An ELF note in memory */ |
| 49 | struct memelfnote | 46 | struct memelfnote |
| 50 | { | 47 | { |
| @@ -103,7 +100,7 @@ static int notesize(struct memelfnote *en) | |||
| 103 | int sz; | 100 | int sz; |
| 104 | 101 | ||
| 105 | sz = sizeof(struct elf_note); | 102 | sz = sizeof(struct elf_note); |
| 106 | sz += roundup(strlen(en->name), 4); | 103 | sz += roundup((strlen(en->name) + 1), 4); |
| 107 | sz += roundup(en->datasz, 4); | 104 | sz += roundup(en->datasz, 4); |
| 108 | 105 | ||
| 109 | return sz; | 106 | return sz; |
| @@ -119,7 +116,7 @@ static char *storenote(struct memelfnote *men, char *bufp) | |||
| 119 | 116 | ||
| 120 | #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0) | 117 | #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0) |
| 121 | 118 | ||
| 122 | en.n_namesz = strlen(men->name); | 119 | en.n_namesz = strlen(men->name) + 1; |
| 123 | en.n_descsz = men->datasz; | 120 | en.n_descsz = men->datasz; |
| 124 | en.n_type = men->type; | 121 | en.n_type = men->type; |
| 125 | 122 | ||
| @@ -282,12 +279,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
| 282 | tsz = elf_buflen - *fpos; | 279 | tsz = elf_buflen - *fpos; |
| 283 | if (buflen < tsz) | 280 | if (buflen < tsz) |
| 284 | tsz = buflen; | 281 | tsz = buflen; |
| 285 | elf_buf = kmalloc(elf_buflen, GFP_ATOMIC); | 282 | elf_buf = kzalloc(elf_buflen, GFP_ATOMIC); |
| 286 | if (!elf_buf) { | 283 | if (!elf_buf) { |
| 287 | read_unlock(&kclist_lock); | 284 | read_unlock(&kclist_lock); |
| 288 | return -ENOMEM; | 285 | return -ENOMEM; |
| 289 | } | 286 | } |
| 290 | memset(elf_buf, 0, elf_buflen); | ||
| 291 | elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen); | 287 | elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen); |
| 292 | read_unlock(&kclist_lock); | 288 | read_unlock(&kclist_lock); |
| 293 | if (copy_to_user(buffer, elf_buf + *fpos, tsz)) { | 289 | if (copy_to_user(buffer, elf_buf + *fpos, tsz)) { |
| @@ -333,10 +329,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
| 333 | unsigned long curstart = start; | 329 | unsigned long curstart = start; |
| 334 | unsigned long cursize = tsz; | 330 | unsigned long cursize = tsz; |
| 335 | 331 | ||
| 336 | elf_buf = kmalloc(tsz, GFP_KERNEL); | 332 | elf_buf = kzalloc(tsz, GFP_KERNEL); |
| 337 | if (!elf_buf) | 333 | if (!elf_buf) |
| 338 | return -ENOMEM; | 334 | return -ENOMEM; |
| 339 | memset(elf_buf, 0, tsz); | ||
| 340 | 335 | ||
| 341 | read_lock(&vmlist_lock); | 336 | read_lock(&vmlist_lock); |
| 342 | for (m=vmlist; m && cursize; m=m->next) { | 337 | for (m=vmlist; m && cursize; m=m->next) { |
| @@ -385,7 +380,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
| 385 | */ | 380 | */ |
| 386 | if (n) { | 381 | if (n) { |
| 387 | if (clear_user(buffer + tsz - n, | 382 | if (clear_user(buffer + tsz - n, |
| 388 | tsz - n)) | 383 | n)) |
| 389 | return -EFAULT; | 384 | return -EFAULT; |
| 390 | } | 385 | } |
| 391 | } else { | 386 | } else { |
