Comment 6 for bug 2015400

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Regression in Jammy
-------------------

Before:

$ uname -rv
5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023

$ truncate -s 1M disk.img
$ sudo mknod /dev/loopNaN b 7 8
$ sudo losetup /dev/loopNaN disk.img
$

$ sudo ./test-loop
$

...

After:

$ uname -rv
5.15.0-68-generic #75-Ubuntu SMP Fri Feb 24 13:01:57 UTC 2023

$ truncate -s 1M disk.img
$ sudo mknod /dev/loopNaN b 7 8
$ sudo losetup /dev/loopNaN disk.img
losetup: /dev/loopNaN: failed to set up loop device: No such device or address

$ sudo ./test-loop
open: /dev/loop8: No such device or address

...

Upstream stable release bug:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2005113

...

Test-case:

$ cat test-loop.c
#include <fcntl.h>
#include <stdio.h>
#include <linux/major.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>

#define LOOP_MINOR 8

#define _DEV_LOOP(x) "/dev/loop" #x
#define DEV_LOOP(x) _DEV_LOOP(x)

int main() {
        int rc, fd;

        rc = mknodat(AT_FDCWD, DEV_LOOP(LOOP_MINOR), S_IFBLK | 0660,
                     makedev(LOOP_MAJOR, LOOP_MINOR));
        if (rc == -1) {
                perror("mknod: " DEV_LOOP(LOOP_MINOR));
                return 1;
        }

        fd = open(DEV_LOOP(LOOP_MINOR), O_RDWR, 0);
        if (fd == -1) {
                perror("open: " DEV_LOOP(LOOP_MINOR));
                return 1;
        }

        return 0;
}

$ gcc -o test-loop test-loop.c