]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Revert "drivers/char/mem.c: deny access in open operation when securelevel is set"
authorDhaval Giani <dhaval.giani@oracle.com>
Fri, 27 Oct 2017 23:22:53 +0000 (19:22 -0400)
committerDhaval Giani <dhaval.giani@oracle.com>
Fri, 27 Oct 2017 23:22:53 +0000 (19:22 -0400)
This reverts commit 8ca81822fffb2536aa1076fb17d1ea1413df3e7f.

Orabug: 27037788
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
drivers/char/mem.c

index 5ffb67599431ef072c62199958d2760fab72834f..fff12a61d8cbfeeea4e9099f662d5da6c1bbb374 100644 (file)
@@ -183,6 +183,9 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
        if (p != *ppos)
                return -EFBIG;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        if (!valid_phys_addr_range(p, count))
                return -EFAULT;
 
@@ -535,6 +538,9 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,
        char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
        int err = 0;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        if (p < (unsigned long) high_memory) {
                unsigned long to_write = min_t(unsigned long, count,
                                               (unsigned long)high_memory - p);
@@ -582,6 +588,9 @@ static ssize_t read_port(struct file *file, char __user *buf,
        unsigned long i = *ppos;
        char __user *tmp = buf;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        if (!access_ok(VERIFY_WRITE, buf, count))
                return -EFAULT;
        while (count-- > 0 && i < 65536) {
@@ -600,6 +609,9 @@ static ssize_t write_port(struct file *file, const char __user *buf,
        unsigned long i = *ppos;
        const char __user *tmp = buf;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        if (!access_ok(VERIFY_READ, buf, count))
                return -EFAULT;
        while (count-- > 0 && i < 65536) {
@@ -735,9 +747,6 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
 
 static int open_port(struct inode *inode, struct file *filp)
 {
-       if (get_securelevel() > 0)
-               return -EPERM;
-
        return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 }