From:Suzuki K. Poulose <[email protected]>

Calculate the size of the core file

Signed-off-by: Suzuki K. Poulose <[email protected]>
Signed-off-by: Ananth N. Mavinakayanahalli <[email protected]>
---
 fs/proc/gencore-elf.c |    6 ++++++
 fs/proc/gencore.h     |    1 +
 2 files changed, 7 insertions(+)

diff --git a/fs/proc/gencore-elf.c b/fs/proc/gencore-elf.c
index 6e97f6a..efd1722 100644
--- a/fs/proc/gencore-elf.c
+++ b/fs/proc/gencore-elf.c
@@ -291,6 +291,9 @@ static int create_elf_header(struct core_proc *cp)
                                                dataoff, cp->nphdrs);
                dataoff += sizeof(struct elf_shdr);
        }
+
+       cp->size = dataoff;
+
        /* Store the notes */
        tinfo = cp->tinfo;
        do {
@@ -351,6 +354,9 @@ ssize_t elf_read_gencore(struct core_proc *cp, char __user 
*buffer,
                        buffer += bcp;
                }
        }
+       if (*fpos > cp->size)
+               goto out;
+  
 out:
        return ret;
 }
diff --git a/fs/proc/gencore.h b/fs/proc/gencore.h
index e508417..f6822f2 100644
--- a/fs/proc/gencore.h
+++ b/fs/proc/gencore.h
@@ -30,6 +30,7 @@ struct core_proc {
        size_t elf_buflen;      /* size of elf_buf */
        size_t nphdrs;          /* number of phdrs */
        size_t notes_size;
+       size_t size;
 };
 
 #ifdef CORE_DUMP_USE_REGSET

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to