]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.11-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Mar 2021 12:13:33 +0000 (13:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Mar 2021 12:13:33 +0000 (13:13 +0100)
added patches:
cifs-fix-allocation-size-on-newly-created-files.patch
cifs-warn-and-fail-if-trying-to-use-rootfs-without-the-config-option.patch
risc-v-fix-out-of-bounds-accesses-in-init_resources.patch
riscv-correct-sparsemem-configuration.patch

queue-5.11/cifs-fix-allocation-size-on-newly-created-files.patch [new file with mode: 0644]
queue-5.11/cifs-warn-and-fail-if-trying-to-use-rootfs-without-the-config-option.patch [new file with mode: 0644]
queue-5.11/risc-v-fix-out-of-bounds-accesses-in-init_resources.patch [new file with mode: 0644]
queue-5.11/riscv-correct-sparsemem-configuration.patch [new file with mode: 0644]
queue-5.11/series

diff --git a/queue-5.11/cifs-fix-allocation-size-on-newly-created-files.patch b/queue-5.11/cifs-fix-allocation-size-on-newly-created-files.patch
new file mode 100644 (file)
index 0000000..008d981
--- /dev/null
@@ -0,0 +1,58 @@
+From 65af8f0166f4d15e61c63db498ec7981acdd897f Mon Sep 17 00:00:00 2001
+From: Steve French <stfrench@microsoft.com>
+Date: Fri, 19 Mar 2021 00:05:48 -0500
+Subject: cifs: fix allocation size on newly created files
+
+From: Steve French <stfrench@microsoft.com>
+
+commit 65af8f0166f4d15e61c63db498ec7981acdd897f upstream.
+
+Applications that create and extend and write to a file do not
+expect to see 0 allocation size.  When file is extended,
+set its allocation size to a plausible value until we have a
+chance to query the server for it.  When the file is cached
+this will prevent showing an impossible number of allocated
+blocks (like 0).  This fixes e.g. xfstests 614 which does
+
+    1) create a file and set its size to 64K
+    2) mmap write 64K to the file
+    3) stat -c %b for the file (to query the number of allocated blocks)
+
+It was failing because we returned 0 blocks.  Even though we would
+return the correct cached file size, we returned an impossible
+allocation size.
+
+Signed-off-by: Steve French <stfrench@microsoft.com>
+CC: <stable@vger.kernel.org>
+Reviewed-by: Aurelien Aptel <aaptel@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/inode.c |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/fs/cifs/inode.c
++++ b/fs/cifs/inode.c
+@@ -2383,7 +2383,7 @@ int cifs_getattr(const struct path *path
+        * We need to be sure that all dirty pages are written and the server
+        * has actual ctime, mtime and file length.
+        */
+-      if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) &&
++      if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE | STATX_BLOCKS)) &&
+           !CIFS_CACHE_READ(CIFS_I(inode)) &&
+           inode->i_mapping && inode->i_mapping->nrpages != 0) {
+               rc = filemap_fdatawait(inode->i_mapping);
+@@ -2573,6 +2573,14 @@ set_size_out:
+       if (rc == 0) {
+               cifsInode->server_eof = attrs->ia_size;
+               cifs_setsize(inode, attrs->ia_size);
++              /*
++               * i_blocks is not related to (i_size / i_blksize), but instead
++               * 512 byte (2**9) size is required for calculating num blocks.
++               * Until we can query the server for actual allocation size,
++               * this is best estimate we have for blocks allocated for a file
++               * Number of blocks must be rounded up so size 1 is not 0 blocks
++               */
++              inode->i_blocks = (512 - 1 + attrs->ia_size) >> 9;
+               /*
+                * The man page of truncate says if the size changed,
diff --git a/queue-5.11/cifs-warn-and-fail-if-trying-to-use-rootfs-without-the-config-option.patch b/queue-5.11/cifs-warn-and-fail-if-trying-to-use-rootfs-without-the-config-option.patch
new file mode 100644 (file)
index 0000000..3842271
--- /dev/null
@@ -0,0 +1,35 @@
+From af3ef3b1031634724a3763606695ebcd113d782b Mon Sep 17 00:00:00 2001
+From: Aurelien Aptel <aaptel@suse.com>
+Date: Thu, 18 Mar 2021 19:17:10 +0100
+Subject: cifs: warn and fail if trying to use rootfs without the config option
+
+From: Aurelien Aptel <aaptel@suse.com>
+
+commit af3ef3b1031634724a3763606695ebcd113d782b upstream.
+
+If CONFIG_CIFS_ROOT is not set, rootfs mount option is invalid
+
+Signed-off-by: Aurelien Aptel <aaptel@suse.com>
+CC: <stable@vger.kernel.org> # v5.11
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/fs_context.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/fs/cifs/fs_context.c
++++ b/fs/cifs/fs_context.c
+@@ -1175,9 +1175,11 @@ static int smb3_fs_context_parse_param(s
+               pr_warn_once("Witness protocol support is experimental\n");
+               break;
+       case Opt_rootfs:
+-#ifdef CONFIG_CIFS_ROOT
+-              ctx->rootfs = true;
++#ifndef CONFIG_CIFS_ROOT
++              cifs_dbg(VFS, "rootfs support requires CONFIG_CIFS_ROOT config option\n");
++              goto cifs_parse_mount_err;
+ #endif
++              ctx->rootfs = true;
+               break;
+       case Opt_posixpaths:
+               if (result.negated)
diff --git a/queue-5.11/risc-v-fix-out-of-bounds-accesses-in-init_resources.patch b/queue-5.11/risc-v-fix-out-of-bounds-accesses-in-init_resources.patch
new file mode 100644 (file)
index 0000000..d0af565
--- /dev/null
@@ -0,0 +1,40 @@
+From ce989f1472ae350e844b10c880b22543168fbc92 Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert@linux-m68k.org>
+Date: Fri, 12 Mar 2021 16:46:34 +0100
+Subject: RISC-V: Fix out-of-bounds accesses in init_resources()
+
+From: Geert Uytterhoeven <geert@linux-m68k.org>
+
+commit ce989f1472ae350e844b10c880b22543168fbc92 upstream.
+
+init_resources() allocates an array of resources, based on the current
+total number of memory regions and reserved memory regions.  However,
+allocating this array using memblock_alloc() might increase the number
+of reserved memory regions.  If that happens, populating the array later
+based on the new number of regions will cause out-of-bounds writes
+beyond the end of the allocated array.
+
+Fix this by allocating one more entry, which may or may not be used.
+
+Fixes: 797f0375dd2ef5cd ("RISC-V: Do not allocate memblock while iterating reserved memblocks")
+Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Reviewed-by: Atish Patra <atish.patra@wdc.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/kernel/setup.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/arch/riscv/kernel/setup.c
++++ b/arch/riscv/kernel/setup.c
+@@ -147,7 +147,8 @@ static void __init init_resources(void)
+       bss_res.end = __pa_symbol(__bss_stop) - 1;
+       bss_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
+-      mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt) * sizeof(*mem_res);
++      /* + 1 as memblock_alloc() might increase memblock.reserved.cnt */
++      mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt + 1) * sizeof(*mem_res);
+       mem_res = memblock_alloc(mem_res_sz, SMP_CACHE_BYTES);
+       if (!mem_res)
+               panic("%s: Failed to allocate %zu bytes\n", __func__, mem_res_sz);
diff --git a/queue-5.11/riscv-correct-sparsemem-configuration.patch b/queue-5.11/riscv-correct-sparsemem-configuration.patch
new file mode 100644 (file)
index 0000000..a41fd41
--- /dev/null
@@ -0,0 +1,42 @@
+From a5406a7ff56e63376c210b06072aa0ef23473366 Mon Sep 17 00:00:00 2001
+From: Kefeng Wang <wangkefeng.wang@huawei.com>
+Date: Mon, 15 Mar 2021 20:03:07 +0800
+Subject: riscv: Correct SPARSEMEM configuration
+
+From: Kefeng Wang <wangkefeng.wang@huawei.com>
+
+commit a5406a7ff56e63376c210b06072aa0ef23473366 upstream.
+
+There are two issues for RV32,
+1) if use FLATMEM, it is useless to enable SPARSEMEM_STATIC.
+2) if use SPARSMEM, both SPARSEMEM_VMEMMAP and SPARSEMEM_STATIC is enabled.
+
+Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
+Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/Kconfig |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/riscv/Kconfig
++++ b/arch/riscv/Kconfig
+@@ -87,7 +87,6 @@ config RISCV
+       select PCI_MSI if PCI
+       select RISCV_INTC
+       select RISCV_TIMER if RISCV_SBI
+-      select SPARSEMEM_STATIC if 32BIT
+       select SPARSE_IRQ
+       select SYSCTL_EXCEPTION_TRACE
+       select THREAD_INFO_IN_TASK
+@@ -148,7 +147,8 @@ config ARCH_FLATMEM_ENABLE
+ config ARCH_SPARSEMEM_ENABLE
+       def_bool y
+       depends on MMU
+-      select SPARSEMEM_VMEMMAP_ENABLE
++      select SPARSEMEM_STATIC if 32BIT && SPARSMEM
++      select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
+ config ARCH_SELECT_MEMORY_MODEL
+       def_bool ARCH_SPARSEMEM_ENABLE
index f2ee740317227580795006294428c1fa4af6eed4..e15ec4d5d50667c6ef56a35c17f2b91b03019c22 100644 (file)
@@ -57,3 +57,7 @@ pstore-fix-warning-in-pstore_kill_sb.patch
 io_uring-ensure-that-sqpoll-thread-is-started-for-exit.patch
 net-qrtr-fix-__netdev_alloc_skb-call.patch
 kbuild-fix-linux-version.h-for-empty-sublevel-or-patchlevel-again.patch
+cifs-warn-and-fail-if-trying-to-use-rootfs-without-the-config-option.patch
+cifs-fix-allocation-size-on-newly-created-files.patch
+risc-v-fix-out-of-bounds-accesses-in-init_resources.patch
+riscv-correct-sparsemem-configuration.patch