From: Greg Kroah-Hartman Date: Thu, 6 Feb 2020 19:31:31 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.19.103~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=127d1afd1248f894a372c9a7f7a78f7fa3774d12;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: acpi-video-do-not-export-a-non-working-backlight-interface-on-msi-ms-7721-boards.patch alarmtimer-unregister-wakeup-source-when-module-get-fails.patch mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch ubifs-fix-deadlock-in-concurrent-bulk-read-and-writepage.patch ubifs-fix-fs_ioc_setflags-unexpectedly-clearing-encrypt-flag.patch ubifs-reject-unsupported-ioctl-flags-explicitly.patch --- diff --git a/queue-4.14/acpi-video-do-not-export-a-non-working-backlight-interface-on-msi-ms-7721-boards.patch b/queue-4.14/acpi-video-do-not-export-a-non-working-backlight-interface-on-msi-ms-7721-boards.patch new file mode 100644 index 00000000000..5f72c5632e8 --- /dev/null +++ b/queue-4.14/acpi-video-do-not-export-a-non-working-backlight-interface-on-msi-ms-7721-boards.patch @@ -0,0 +1,59 @@ +From d21a91629f4b8e794fc4c0e0c17c85cedf1d806c Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 17 Dec 2019 20:08:11 +0100 +Subject: ACPI: video: Do not export a non working backlight interface on MSI MS-7721 boards + +From: Hans de Goede + +commit d21a91629f4b8e794fc4c0e0c17c85cedf1d806c upstream. + +Despite our heuristics to not wrongly export a non working ACPI backlight +interface on desktop machines, we still end up exporting one on desktops +using a motherboard from the MSI MS-7721 series. + +I've looked at improving the heuristics, but in this case a quirk seems +to be the only way to solve this. + +While at it also add a comment to separate the video_detect_force_none +entries in the video_detect_dmi_table from other type of entries, as we +already do for the other entry types. + +Cc: All applicable +BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1783786 +Signed-off-by: Hans de Goede +Signed-off-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/acpi/video_detect.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/drivers/acpi/video_detect.c ++++ b/drivers/acpi/video_detect.c +@@ -328,6 +328,11 @@ static const struct dmi_system_id video_ + DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), + }, + }, ++ ++ /* ++ * Desktops which falsely report a backlight and which our heuristics ++ * for this do not catch. ++ */ + { + .callback = video_detect_force_none, + .ident = "Dell OptiPlex 9020M", +@@ -336,6 +341,14 @@ static const struct dmi_system_id video_ + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), + }, + }, ++ { ++ .callback = video_detect_force_none, ++ .ident = "MSI MS-7721", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "MSI"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"), ++ }, ++ }, + { }, + }; + diff --git a/queue-4.14/alarmtimer-unregister-wakeup-source-when-module-get-fails.patch b/queue-4.14/alarmtimer-unregister-wakeup-source-when-module-get-fails.patch new file mode 100644 index 00000000000..8a01b5d5dc1 --- /dev/null +++ b/queue-4.14/alarmtimer-unregister-wakeup-source-when-module-get-fails.patch @@ -0,0 +1,64 @@ +From 6b6d188aae79a630957aefd88ff5c42af6553ee3 Mon Sep 17 00:00:00 2001 +From: Stephen Boyd +Date: Thu, 9 Jan 2020 07:59:07 -0800 +Subject: alarmtimer: Unregister wakeup source when module get fails + +From: Stephen Boyd + +commit 6b6d188aae79a630957aefd88ff5c42af6553ee3 upstream. + +The alarmtimer_rtc_add_device() function creates a wakeup source and then +tries to grab a module reference. If that fails the function returns early +with an error code, but fails to remove the wakeup source. + +Cleanup this exit path so there is no dangling wakeup source, which is +named 'alarmtime' left allocated which will conflict with another RTC +device that may be registered later. + +Fixes: 51218298a25e ("alarmtimer: Ensure RTC module is not unloaded") +Signed-off-by: Stephen Boyd +Signed-off-by: Thomas Gleixner +Reviewed-by: Douglas Anderson +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20200109155910.907-2-swboyd@chromium.org +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/time/alarmtimer.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/kernel/time/alarmtimer.c ++++ b/kernel/time/alarmtimer.c +@@ -91,6 +91,7 @@ static int alarmtimer_rtc_add_device(str + unsigned long flags; + struct rtc_device *rtc = to_rtc_device(dev); + struct wakeup_source *__ws; ++ int ret = 0; + + if (rtcdev) + return -EBUSY; +@@ -105,8 +106,8 @@ static int alarmtimer_rtc_add_device(str + spin_lock_irqsave(&rtcdev_lock, flags); + if (!rtcdev) { + if (!try_module_get(rtc->owner)) { +- spin_unlock_irqrestore(&rtcdev_lock, flags); +- return -1; ++ ret = -1; ++ goto unlock; + } + + rtcdev = rtc; +@@ -115,11 +116,12 @@ static int alarmtimer_rtc_add_device(str + ws = __ws; + __ws = NULL; + } ++unlock: + spin_unlock_irqrestore(&rtcdev_lock, flags); + + wakeup_source_unregister(__ws); + +- return 0; ++ return ret; + } + + static inline void alarmtimer_rtc_timer_init(void) diff --git a/queue-4.14/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch b/queue-4.14/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch new file mode 100644 index 00000000000..7adc9bf7316 --- /dev/null +++ b/queue-4.14/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch @@ -0,0 +1,64 @@ +From af3ed119329cf9690598c5a562d95dfd128e91d6 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 4 Dec 2019 16:27:49 +0100 +Subject: mmc: spi: Toggle SPI polarity, do not hardcode it + +From: Linus Walleij + +commit af3ed119329cf9690598c5a562d95dfd128e91d6 upstream. + +The code in mmc_spi_initsequence() tries to send a burst with +high chipselect and for this reason hardcodes the device into +SPI_CS_HIGH. + +This is not good because the SPI_CS_HIGH flag indicates +logical "asserted" CS not always the physical level. In +some cases the signal is inverted in the GPIO library and +in that case SPI_CS_HIGH is already set, and enforcing +SPI_CS_HIGH again will actually drive it low. + +Instead of hard-coding this, toggle the polarity so if the +default is LOW it goes high to assert chipselect but if it +is already high then toggle it low instead. + +Cc: Phil Elwell +Reported-by: Mark Brown +Signed-off-by: Linus Walleij +Reviewed-by: Mark Brown +Link: https://lore.kernel.org/r/20191204152749.12652-1-linus.walleij@linaro.org +Cc: stable@vger.kernel.org +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/mmc_spi.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/drivers/mmc/host/mmc_spi.c ++++ b/drivers/mmc/host/mmc_spi.c +@@ -1154,17 +1154,22 @@ static void mmc_spi_initsequence(struct + * SPI protocol. Another is that when chipselect is released while + * the card returns BUSY status, the clock must issue several cycles + * with chipselect high before the card will stop driving its output. ++ * ++ * SPI_CS_HIGH means "asserted" here. In some cases like when using ++ * GPIOs for chip select, SPI_CS_HIGH is set but this will be logically ++ * inverted by gpiolib, so if we want to ascertain to drive it high ++ * we should toggle the default with an XOR as we do here. + */ +- host->spi->mode |= SPI_CS_HIGH; ++ host->spi->mode ^= SPI_CS_HIGH; + if (spi_setup(host->spi) != 0) { + /* Just warn; most cards work without it. */ + dev_warn(&host->spi->dev, + "can't change chip-select polarity\n"); +- host->spi->mode &= ~SPI_CS_HIGH; ++ host->spi->mode ^= SPI_CS_HIGH; + } else { + mmc_spi_readbytes(host, 18); + +- host->spi->mode &= ~SPI_CS_HIGH; ++ host->spi->mode ^= SPI_CS_HIGH; + if (spi_setup(host->spi) != 0) { + /* Wot, we can't get the same setup we had before? */ + dev_err(&host->spi->dev, diff --git a/queue-4.14/series b/queue-4.14/series index 7c571e61359..21351811bc9 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -33,3 +33,9 @@ mips-fix-indentation-of-the-relocs-message.patch s390-mm-fix-dynamic-pagetable-upgrade-for-hugetlbfs.patch powerpc-xmon-don-t-access-asdr-in-vms.patch powerpc-pseries-advance-pfn-if-section-is-not-present-in-lmb_is_removable.patch +mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch +acpi-video-do-not-export-a-non-working-backlight-interface-on-msi-ms-7721-boards.patch +alarmtimer-unregister-wakeup-source-when-module-get-fails.patch +ubifs-reject-unsupported-ioctl-flags-explicitly.patch +ubifs-fix-fs_ioc_setflags-unexpectedly-clearing-encrypt-flag.patch +ubifs-fix-deadlock-in-concurrent-bulk-read-and-writepage.patch diff --git a/queue-4.14/ubifs-fix-deadlock-in-concurrent-bulk-read-and-writepage.patch b/queue-4.14/ubifs-fix-deadlock-in-concurrent-bulk-read-and-writepage.patch new file mode 100644 index 00000000000..c390fcd3ca9 --- /dev/null +++ b/queue-4.14/ubifs-fix-deadlock-in-concurrent-bulk-read-and-writepage.patch @@ -0,0 +1,59 @@ +From f5de5b83303e61b1f3fb09bd77ce3ac2d7a475f2 Mon Sep 17 00:00:00 2001 +From: Zhihao Cheng +Date: Sat, 11 Jan 2020 17:50:36 +0800 +Subject: ubifs: Fix deadlock in concurrent bulk-read and writepage +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Zhihao Cheng + +commit f5de5b83303e61b1f3fb09bd77ce3ac2d7a475f2 upstream. + +In ubifs, concurrent execution of writepage and bulk read on the same file +may cause ABBA deadlock, for example (Reproduce method see Link): + +Process A(Bulk-read starts from page4) Process B(write page4 back) + vfs_read wb_workfn or fsync + ... ... + generic_file_buffered_read write_cache_pages + ubifs_readpage LOCK(page4) + + ubifs_bulk_read ubifs_writepage + LOCK(ui->ui_mutex) ubifs_write_inode + + ubifs_do_bulk_read LOCK(ui->ui_mutex) + find_or_create_page(alloc page4) ↑ + LOCK(page4) <-- ABBA deadlock occurs! + +In order to ensure the serialization execution of bulk read, we can't +remove the big lock 'ui->ui_mutex' in ubifs_bulk_read(). Instead, we +allow ubifs_do_bulk_read() to lock page failed by replacing +find_or_create_page(FGP_LOCK) with +pagecache_get_page(FGP_LOCK | FGP_NOWAIT). + +Signed-off-by: Zhihao Cheng +Suggested-by: zhangyi (F) +Cc: +Fixes: 4793e7c5e1c ("UBIFS: add bulk-read facility") +Link: https://bugzilla.kernel.org/show_bug.cgi?id=206153 +Signed-off-by: Richard Weinberger +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ubifs/file.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/fs/ubifs/file.c ++++ b/fs/ubifs/file.c +@@ -797,7 +797,9 @@ static int ubifs_do_bulk_read(struct ubi + + if (page_offset > end_index) + break; +- page = find_or_create_page(mapping, page_offset, ra_gfp_mask); ++ page = pagecache_get_page(mapping, page_offset, ++ FGP_LOCK|FGP_ACCESSED|FGP_CREAT|FGP_NOWAIT, ++ ra_gfp_mask); + if (!page) + break; + if (!PageUptodate(page)) diff --git a/queue-4.14/ubifs-fix-fs_ioc_setflags-unexpectedly-clearing-encrypt-flag.patch b/queue-4.14/ubifs-fix-fs_ioc_setflags-unexpectedly-clearing-encrypt-flag.patch new file mode 100644 index 00000000000..76feceb847d --- /dev/null +++ b/queue-4.14/ubifs-fix-fs_ioc_setflags-unexpectedly-clearing-encrypt-flag.patch @@ -0,0 +1,57 @@ +From 2b57067a7778484c10892fa191997bfda29fea13 Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Mon, 9 Dec 2019 14:23:24 -0800 +Subject: ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag + +From: Eric Biggers + +commit 2b57067a7778484c10892fa191997bfda29fea13 upstream. + +UBIFS's implementation of FS_IOC_SETFLAGS fails to preserve existing +inode flags that aren't settable by FS_IOC_SETFLAGS, namely the encrypt +flag. This causes the encrypt flag to be unexpectedly cleared. + +Fix it by preserving existing unsettable flags, like ext4 and f2fs do. + +Test case with kvm-xfstests shell: + + FSTYP=ubifs KEYCTL_PROG=keyctl + . fs/ubifs/config + . ~/xfstests/common/encrypt + dev=$(__blkdev_to_ubi_volume /dev/vdc) + ubiupdatevol -t $dev + mount $dev /mnt -t ubifs + k=$(_generate_session_encryption_key) + mkdir /mnt/edir + xfs_io -c "set_encpolicy $k" /mnt/edir + echo contents > /mnt/edir/file + chattr +i /mnt/edir/file + chattr -i /mnt/edir/file + +With the bug, the following errors occur on the last command: + + [ 18.081559] fscrypt (ubifs, inode 67): Inconsistent encryption context (parent directory: 65) + chattr: Operation not permitted while reading flags on /mnt/edir/file + +Fixes: d475a507457b ("ubifs: Add skeleton for fscrypto") +Cc: # v4.10+ +Signed-off-by: Eric Biggers +Signed-off-by: Richard Weinberger +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ubifs/ioctl.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/ubifs/ioctl.c ++++ b/fs/ubifs/ioctl.c +@@ -129,7 +129,8 @@ static int setflags(struct inode *inode, + } + } + +- ui->flags = ioctl2ubifs(flags); ++ ui->flags &= ~ioctl2ubifs(UBIFS_SUPPORTED_IOCTL_FLAGS); ++ ui->flags |= ioctl2ubifs(flags); + ubifs_set_inode_flags(inode); + inode->i_ctime = current_time(inode); + release = ui->dirty; diff --git a/queue-4.14/ubifs-reject-unsupported-ioctl-flags-explicitly.patch b/queue-4.14/ubifs-reject-unsupported-ioctl-flags-explicitly.patch new file mode 100644 index 00000000000..4db265fbd2b --- /dev/null +++ b/queue-4.14/ubifs-reject-unsupported-ioctl-flags-explicitly.patch @@ -0,0 +1,47 @@ +From 2fe8b2d5578d7d142982e3bf62e4c0caf8b8fe02 Mon Sep 17 00:00:00 2001 +From: Hou Tao +Date: Sat, 9 Feb 2019 16:54:20 +0800 +Subject: ubifs: Reject unsupported ioctl flags explicitly + +From: Hou Tao + +commit 2fe8b2d5578d7d142982e3bf62e4c0caf8b8fe02 upstream. + +Reject unsupported ioctl flags explicitly, so the following command +on a regular ubifs file will fail: + chattr +d ubifs_file + +And xfstests generic/424 will pass. + +Signed-off-by: Hou Tao +Signed-off-by: Richard Weinberger +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ubifs/ioctl.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/fs/ubifs/ioctl.c ++++ b/fs/ubifs/ioctl.c +@@ -28,6 +28,11 @@ + #include + #include "ubifs.h" + ++/* Need to be kept consistent with checked flags in ioctl2ubifs() */ ++#define UBIFS_SUPPORTED_IOCTL_FLAGS \ ++ (FS_COMPR_FL | FS_SYNC_FL | FS_APPEND_FL | \ ++ FS_IMMUTABLE_FL | FS_DIRSYNC_FL) ++ + /** + * ubifs_set_inode_flags - set VFS inode flags. + * @inode: VFS inode to set flags for +@@ -166,6 +171,9 @@ long ubifs_ioctl(struct file *file, unsi + if (get_user(flags, (int __user *) arg)) + return -EFAULT; + ++ if (flags & ~UBIFS_SUPPORTED_IOCTL_FLAGS) ++ return -EOPNOTSUPP; ++ + if (!S_ISDIR(inode->i_mode)) + flags &= ~FS_DIRSYNC_FL; +