Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-5.18/drivers-2022-04-02' of git://git.kernel.dk/linux-block

Pull block driver fix from Jens Axboe:
"Got two reports on nbd spewing warnings on load now, which is a
regression from a commit that went into your tree yesterday.

Revert the problematic change for now"

* tag 'for-5.18/drivers-2022-04-02' of git://git.kernel.dk/linux-block:
Revert "nbd: fix possible overflow on 'first_minor' in nbd_dev_add()"

+12 -12
+12 -12
drivers/block/nbd.c
··· 1800 1800 refcount_set(&nbd->refs, 0); 1801 1801 INIT_LIST_HEAD(&nbd->list); 1802 1802 disk->major = NBD_MAJOR; 1803 + 1804 + /* Too big first_minor can cause duplicate creation of 1805 + * sysfs files/links, since index << part_shift might overflow, or 1806 + * MKDEV() expect that the max bits of first_minor is 20. 1807 + */ 1808 + disk->first_minor = index << part_shift; 1809 + if (disk->first_minor < index || disk->first_minor > MINORMASK) { 1810 + err = -EINVAL; 1811 + goto out_free_work; 1812 + } 1813 + 1803 1814 disk->minors = 1 << part_shift; 1804 1815 disk->fops = &nbd_fops; 1805 1816 disk->private_data = nbd; ··· 1915 1904 if (!netlink_capable(skb, CAP_SYS_ADMIN)) 1916 1905 return -EPERM; 1917 1906 1918 - if (info->attrs[NBD_ATTR_INDEX]) { 1907 + if (info->attrs[NBD_ATTR_INDEX]) 1919 1908 index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]); 1920 - 1921 - /* 1922 - * Too big first_minor can cause duplicate creation of 1923 - * sysfs files/links, since index << part_shift might overflow, or 1924 - * MKDEV() expect that the max bits of first_minor is 20. 1925 - */ 1926 - if (index < 0 || index > MINORMASK >> part_shift) { 1927 - printk(KERN_ERR "nbd: illegal input index %d\n", index); 1928 - return -EINVAL; 1929 - } 1930 - } 1931 1909 if (!info->attrs[NBD_ATTR_SOCKETS]) { 1932 1910 printk(KERN_ERR "nbd: must specify at least one socket\n"); 1933 1911 return -EINVAL;