#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 -EPERM;
+ return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
}
static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *);
};
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)
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;
}
*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);
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;