From: Greg Kroah-Hartman Date: Wed, 11 Dec 2019 08:57:44 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v5.4.3~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb882a1f9050bdf890d34b6e599213f009cdc7f0;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: bdev-factor-out-bdev-revalidation-into-a-common-helper.patch bdev-refresh-bdev-size-for-disks-without-partitioning.patch rdma-qib-validate-show-store-callbacks-before-calling-them.patch rfkill-allocate-static-minor.patch --- diff --git a/queue-5.4/bdev-factor-out-bdev-revalidation-into-a-common-helper.patch b/queue-5.4/bdev-factor-out-bdev-revalidation-into-a-common-helper.patch new file mode 100644 index 00000000000..e2f3c2a8454 --- /dev/null +++ b/queue-5.4/bdev-factor-out-bdev-revalidation-into-a-common-helper.patch @@ -0,0 +1,70 @@ +From 731dc4868311ee097757b8746eaa1b4f8b2b4f1c Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 21 Oct 2019 10:37:59 +0200 +Subject: bdev: Factor out bdev revalidation into a common helper + +From: Jan Kara + +commit 731dc4868311ee097757b8746eaa1b4f8b2b4f1c upstream. + +Factor out code handling revalidation of bdev on disk change into a +common helper. + +Signed-off-by: Jan Kara +Signed-off-by: Jens Axboe +Cc: Laura Abbott +Signed-off-by: Greg Kroah-Hartman + +--- + fs/block_dev.c | 26 ++++++++++++++------------ + 1 file changed, 14 insertions(+), 12 deletions(-) + +--- a/fs/block_dev.c ++++ b/fs/block_dev.c +@@ -1512,6 +1512,14 @@ EXPORT_SYMBOL(bd_set_size); + + static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part); + ++static void bdev_disk_changed(struct block_device *bdev, bool invalidate) ++{ ++ if (invalidate) ++ invalidate_partitions(bdev->bd_disk, bdev); ++ else ++ rescan_partitions(bdev->bd_disk, bdev); ++} ++ + /* + * bd_mutex locking: + * +@@ -1594,12 +1602,9 @@ static int __blkdev_get(struct block_dev + * The latter is necessary to prevent ghost + * partitions on a removed medium. + */ +- if (bdev->bd_invalidated) { +- if (!ret) +- rescan_partitions(disk, bdev); +- else if (ret == -ENOMEDIUM) +- invalidate_partitions(disk, bdev); +- } ++ if (bdev->bd_invalidated && ++ (!ret || ret == -ENOMEDIUM)) ++ bdev_disk_changed(bdev, ret == -ENOMEDIUM); + + if (ret) + goto out_clear; +@@ -1632,12 +1637,9 @@ static int __blkdev_get(struct block_dev + if (bdev->bd_disk->fops->open) + ret = bdev->bd_disk->fops->open(bdev, mode); + /* the same as first opener case, read comment there */ +- if (bdev->bd_invalidated) { +- if (!ret) +- rescan_partitions(bdev->bd_disk, bdev); +- else if (ret == -ENOMEDIUM) +- invalidate_partitions(bdev->bd_disk, bdev); +- } ++ if (bdev->bd_invalidated && ++ (!ret || ret == -ENOMEDIUM)) ++ bdev_disk_changed(bdev, ret == -ENOMEDIUM); + if (ret) + goto out_unlock_bdev; + } diff --git a/queue-5.4/bdev-refresh-bdev-size-for-disks-without-partitioning.patch b/queue-5.4/bdev-refresh-bdev-size-for-disks-without-partitioning.patch new file mode 100644 index 00000000000..bbc3344d410 --- /dev/null +++ b/queue-5.4/bdev-refresh-bdev-size-for-disks-without-partitioning.patch @@ -0,0 +1,63 @@ +From cba22d86e0a10b7070d2e6a7379dbea51aa0883c Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 21 Oct 2019 10:38:00 +0200 +Subject: bdev: Refresh bdev size for disks without partitioning + +From: Jan Kara + +commit cba22d86e0a10b7070d2e6a7379dbea51aa0883c upstream. + +Currently, block device size in not updated on second and further open +for block devices where partition scan is disabled. This is particularly +annoying for example for DVD drives as that means block device size does +not get updated once the media is inserted into a drive if the device is +already open when inserting the media. This is actually always the case +for example when pktcdvd is in use. + +Fix the problem by revalidating block device size on every open even for +devices with partition scan disabled. + +Signed-off-by: Jan Kara +Signed-off-by: Jens Axboe +Cc: Laura Abbott +Signed-off-by: Greg Kroah-Hartman + +--- + fs/block_dev.c | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +--- a/fs/block_dev.c ++++ b/fs/block_dev.c +@@ -1403,11 +1403,7 @@ static void flush_disk(struct block_devi + "resized disk %s\n", + bdev->bd_disk ? bdev->bd_disk->disk_name : ""); + } +- +- if (!bdev->bd_disk) +- return; +- if (disk_part_scan_enabled(bdev->bd_disk)) +- bdev->bd_invalidated = 1; ++ bdev->bd_invalidated = 1; + } + + /** +@@ -1514,10 +1510,15 @@ static void __blkdev_put(struct block_de + + static void bdev_disk_changed(struct block_device *bdev, bool invalidate) + { +- if (invalidate) +- invalidate_partitions(bdev->bd_disk, bdev); +- else +- rescan_partitions(bdev->bd_disk, bdev); ++ if (disk_part_scan_enabled(bdev->bd_disk)) { ++ if (invalidate) ++ invalidate_partitions(bdev->bd_disk, bdev); ++ else ++ rescan_partitions(bdev->bd_disk, bdev); ++ } else { ++ check_disk_size_change(bdev->bd_disk, bdev, !invalidate); ++ bdev->bd_invalidated = 0; ++ } + } + + /* diff --git a/queue-5.4/rdma-qib-validate-show-store-callbacks-before-calling-them.patch b/queue-5.4/rdma-qib-validate-show-store-callbacks-before-calling-them.patch new file mode 100644 index 00000000000..24a1abb1fe6 --- /dev/null +++ b/queue-5.4/rdma-qib-validate-show-store-callbacks-before-calling-them.patch @@ -0,0 +1,48 @@ +From 7ee23491b39259ae83899dd93b2a29ef0f22f0a7 Mon Sep 17 00:00:00 2001 +From: Viresh Kumar +Date: Thu, 7 Nov 2019 08:50:25 +0530 +Subject: RDMA/qib: Validate ->show()/store() callbacks before calling them + +From: Viresh Kumar + +commit 7ee23491b39259ae83899dd93b2a29ef0f22f0a7 upstream. + +The permissions of the read-only or write-only sysfs files can be +changed (as root) and the user can then try to read a write-only file or +write to a read-only file which will lead to kernel crash here. + +Protect against that by always validating the show/store callbacks. + +Link: https://lore.kernel.org/r/d45cc26361a174ae12dbb86c994ef334d257924b.1573096807.git.viresh.kumar@linaro.org +Signed-off-by: Viresh Kumar +Reviewed-by: Greg Kroah-Hartman +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/infiniband/hw/qib/qib_sysfs.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/infiniband/hw/qib/qib_sysfs.c ++++ b/drivers/infiniband/hw/qib/qib_sysfs.c +@@ -301,6 +301,9 @@ static ssize_t qib_portattr_show(struct + struct qib_pportdata *ppd = + container_of(kobj, struct qib_pportdata, pport_kobj); + ++ if (!pattr->show) ++ return -EIO; ++ + return pattr->show(ppd, buf); + } + +@@ -312,6 +315,9 @@ static ssize_t qib_portattr_store(struct + struct qib_pportdata *ppd = + container_of(kobj, struct qib_pportdata, pport_kobj); + ++ if (!pattr->store) ++ return -EIO; ++ + return pattr->store(ppd, buf, len); + } + diff --git a/queue-5.4/rfkill-allocate-static-minor.patch b/queue-5.4/rfkill-allocate-static-minor.patch new file mode 100644 index 00000000000..2900ee49971 --- /dev/null +++ b/queue-5.4/rfkill-allocate-static-minor.patch @@ -0,0 +1,62 @@ +From 8670b2b8b029a6650d133486be9d2ace146fd29a Mon Sep 17 00:00:00 2001 +From: Marcel Holtmann +Date: Thu, 24 Oct 2019 19:40:42 +0200 +Subject: rfkill: allocate static minor + +From: Marcel Holtmann + +commit 8670b2b8b029a6650d133486be9d2ace146fd29a upstream. + +udev has a feature of creating /dev/ device-nodes if it finds +a devnode: modalias. This allows for auto-loading of modules that +provide the node. This requires to use a statically allocated minor +number for misc character devices. + +However, rfkill uses dynamic minor numbers and prevents auto-loading +of the module. So allocate the next static misc minor number and use +it for rfkill. + +Signed-off-by: Marcel Holtmann +Link: https://lore.kernel.org/r/20191024174042.19851-1-marcel@holtmann.org +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin + +--- + include/linux/miscdevice.h | 1 + + net/rfkill/core.c | 9 +++++++-- + 2 files changed, 8 insertions(+), 2 deletions(-) + +--- a/include/linux/miscdevice.h ++++ b/include/linux/miscdevice.h +@@ -57,6 +57,7 @@ + #define UHID_MINOR 239 + #define USERIO_MINOR 240 + #define VHOST_VSOCK_MINOR 241 ++#define RFKILL_MINOR 242 + #define MISC_DYNAMIC_MINOR 255 + + struct device; +--- a/net/rfkill/core.c ++++ b/net/rfkill/core.c +@@ -1316,10 +1316,12 @@ static const struct file_operations rfki + .llseek = no_llseek, + }; + ++#define RFKILL_NAME "rfkill" ++ + static struct miscdevice rfkill_miscdev = { +- .name = "rfkill", + .fops = &rfkill_fops, +- .minor = MISC_DYNAMIC_MINOR, ++ .name = RFKILL_NAME, ++ .minor = RFKILL_MINOR, + }; + + static int __init rfkill_init(void) +@@ -1371,3 +1373,6 @@ static void __exit rfkill_exit(void) + class_unregister(&rfkill_class); + } + module_exit(rfkill_exit); ++ ++MODULE_ALIAS_MISCDEV(RFKILL_MINOR); ++MODULE_ALIAS("devname:" RFKILL_NAME); diff --git a/queue-5.4/series b/queue-5.4/series index 6d73405e632..e4c15bdf269 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -79,3 +79,7 @@ spi-atmel-fix-cs-high-support.patch spi-fix-spi_cs_high-setting-when-using-native-and-gpio-cs.patch spi-fix-null-pointer-when-setting-spi_cs_high-for-gpio-cs.patch can-ucan-fix-non-atomic-allocation-in-completion-handler.patch +rdma-qib-validate-show-store-callbacks-before-calling-them.patch +rfkill-allocate-static-minor.patch +bdev-factor-out-bdev-revalidation-into-a-common-helper.patch +bdev-refresh-bdev-size-for-disks-without-partitioning.patch