linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / proc / kcore.c
index 150d9c5..adc2cd9 100644 (file)
@@ -9,6 +9,7 @@
  *     Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <kanoj@sgi.com>
  */
 
+#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/user.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 *);
 
-const struct file_operations proc_kcore_operations = {
+struct file_operations proc_kcore_operations = {
        .read           = read_kcore,
        .open           = open_kcore,
 };
@@ -42,6 +43,8 @@ const struct file_operations proc_kcore_operations = {
 #define        kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET)
 #endif
 
+#define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
+
 /* An ELF note in memory */
 struct memelfnote
 {
@@ -382,7 +385,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                                 */
                                if (n) { 
                                        if (clear_user(buffer + tsz - n,
-                                                               n))
+                                                               tsz - n))
                                                return -EFAULT;
                                }
                        } else {