git: sys/dev/disk/dm: Remove read/write support for /dev/mapper/control

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Sat Apr 30 20:18:23 PDT 2016


commit 963efb759bfcde56802056358895073b943f1dc6
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Sun May 1 09:12:10 2016 +0900

    sys/dev/disk/dm: Remove read/write support for /dev/mapper/control
    
    It's obvious that /dev/mapper/control has nothing to read/write.
    Running below results in kernel panic as the code requires properly
    initialized a per-table lock while this chrdev has no tables mapped.
    (control chrdev and dm blkdevs use the same dm device structures)
    
    -----
     [root@]~# cat ./dm1.c
     #include <stdio.h>
     #include <stdlib.h>
     #include <unistd.h>
     #include <fcntl.h>
     int main(void)
     {
             int fd;
             char buf[1024];
             fd = open("/dev/mapper/control", O_RDWR);
             if (fd == -1) {
                     perror("open");
                     exit(1);
             }
             if (read(fd, buf, sizeof(buf)) == -1)
                     perror("read");
             if (write(fd, buf, sizeof(buf)) == -1)
                     perror("write");
             close(fd);
             return 0;
     }
    
    With this commit.
    -----
     [root@]~# uname
     DragonFly
     [root@]~# kldload dm
     [root@]~# ls -l /dev/mapper/control
     crw-r-----  1 root  operator   65, 0x00000000 May  1 09:25 /dev/mapper/control
     [root@]~# gcc -Wall -g ./dm1.c -o ./dm1
     [root@]~# ./dm1
     read: Operation not supported by device
     write: Operation not supported by device
    
    With Linux kernel.
    -----
     [root at localhost]~# uname
     Linux
     [root at localhost]~# ls -l /dev/mapper/control
     crw-rw---- 1 root root 10, 236 Apr 25 12:44 /dev/mapper/control
     [root at localhost]~# gcc -Wall -g ./dm1.c -o ./dm1
     [root at localhost]~# ./dm1
     read: Invalid argument
     write: Invalid argument

Summary of changes:
 sys/dev/disk/dm/device-mapper.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/963efb759bfcde56802056358895073b943f1dc6


-- 
DragonFly BSD source repository



More information about the Commits mailing list