Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / proc / kcore.c
index 1f55db7..5c08a9c 100644 (file)
 #include <linux/proc_fs.h>
 #include <linux/user.h>
 #include <linux/a.out.h>
+#include <linux/capability.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
+#include <linux/init.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
 
 static int open_kcore(struct inode * inode, struct file * filp)
 {
-       return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
+       return -EPERM;
 }
 
 static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *);
 
-struct file_operations proc_kcore_operations = {
+const struct file_operations proc_kcore_operations = {
        .read           = read_kcore,
        .open           = open_kcore,
 };
@@ -53,7 +55,7 @@ struct memelfnote
 };
 
 static struct kcore_list *kclist;
-static rwlock_t kclist_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(kclist_lock);
 
 void
 kclist_add(struct kcore_list *new, void *addr, size_t size)
@@ -67,25 +69,6 @@ kclist_add(struct kcore_list *new, void *addr, size_t size)
        write_unlock(&kclist_lock);
 }
 
-struct kcore_list *
-kclist_del(void *addr)
-{
-       struct kcore_list *m, **p = &kclist;
-
-       write_lock(&kclist_lock);
-       for (m = *p; m; p = &m->next) {
-               if (m->addr == (unsigned long)addr) {
-                       *p = m->next;
-                       write_unlock(&kclist_lock);
-                       return m;
-               }
-       }
-       write_unlock(&kclist_lock);
-       return 0;
-}
-
-extern char saved_command_line[];
-
 static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 {
        size_t try, size;
@@ -102,7 +85,7 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
        }
        *elf_buflen =   sizeof(struct elfhdr) + 
                        (*nphdr + 2)*sizeof(struct elf_phdr) + 
-                       3 * sizeof(struct memelfnote) +
+                       3 * (sizeof(struct elf_note) + 4) +
                        sizeof(struct elf_prstatus) +
                        sizeof(struct elf_prpsinfo) +
                        sizeof(struct task_struct);
@@ -282,8 +265,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
        unsigned long start;
 
        read_lock(&kclist_lock);
-       tsz =  get_kcore_size(&nphdr, &elf_buflen);
-       proc_root_kcore->size = size = tsz + elf_buflen;
+       proc_root_kcore->size = size = get_kcore_size(&nphdr, &elf_buflen);
        if (buflen == 0 || *fpos >= size) {
                read_unlock(&kclist_lock);
                return 0;