]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Nov 2021 15:39:21 +0000 (16:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Nov 2021 15:39:21 +0000 (16:39 +0100)
added patches:
fuse-truncate-pagecache-on-atomic_o_trunc.patch
pci-add-pci_exp_devctl_payload_-macros.patch

queue-4.19/fuse-truncate-pagecache-on-atomic_o_trunc.patch [new file with mode: 0644]
queue-4.19/pci-add-pci_exp_devctl_payload_-macros.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/fuse-truncate-pagecache-on-atomic_o_trunc.patch b/queue-4.19/fuse-truncate-pagecache-on-atomic_o_trunc.patch
new file mode 100644 (file)
index 0000000..c8aaad8
--- /dev/null
@@ -0,0 +1,59 @@
+From 76224355db7570cbe6b6f75c8929a1558828dd55 Mon Sep 17 00:00:00 2001
+From: Miklos Szeredi <mszeredi@redhat.com>
+Date: Tue, 17 Aug 2021 21:05:16 +0200
+Subject: fuse: truncate pagecache on atomic_o_trunc
+
+From: Miklos Szeredi <mszeredi@redhat.com>
+
+commit 76224355db7570cbe6b6f75c8929a1558828dd55 upstream.
+
+fuse_finish_open() will be called with FUSE_NOWRITE in case of atomic
+O_TRUNC.  This can deadlock with fuse_wait_on_page_writeback() in
+fuse_launder_page() triggered by invalidate_inode_pages2().
+
+Fix by replacing invalidate_inode_pages2() in fuse_finish_open() with a
+truncate_pagecache() call.  This makes sense regardless of FOPEN_KEEP_CACHE
+or fc->writeback cache, so do it unconditionally.
+
+Reported-by: Xie Yongji <xieyongji@bytedance.com>
+Reported-and-tested-by: syzbot+bea44a5189836d956894@syzkaller.appspotmail.com
+Fixes: e4648309b85a ("fuse: truncate pending writes on O_TRUNC")
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/fuse/file.c |    7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/fs/fuse/file.c
++++ b/fs/fuse/file.c
+@@ -178,12 +178,11 @@ void fuse_finish_open(struct inode *inod
+       if (ff->open_flags & FOPEN_DIRECT_IO)
+               file->f_op = &fuse_direct_io_file_operations;
+-      if (!(ff->open_flags & FOPEN_KEEP_CACHE))
+-              invalidate_inode_pages2(inode->i_mapping);
+       if (ff->open_flags & FOPEN_STREAM)
+               stream_open(inode, file);
+       else if (ff->open_flags & FOPEN_NONSEEKABLE)
+               nonseekable_open(inode, file);
++
+       if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) {
+               struct fuse_inode *fi = get_fuse_inode(inode);
+@@ -191,10 +190,14 @@ void fuse_finish_open(struct inode *inod
+               fi->attr_version = ++fc->attr_version;
+               i_size_write(inode, 0);
+               spin_unlock(&fc->lock);
++              truncate_pagecache(inode, 0);
+               fuse_invalidate_attr(inode);
+               if (fc->writeback_cache)
+                       file_update_time(file);
++      } else if (!(ff->open_flags & FOPEN_KEEP_CACHE)) {
++              invalidate_inode_pages2(inode->i_mapping);
+       }
++
+       if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache)
+               fuse_link_write_file(file);
+ }
diff --git a/queue-4.19/pci-add-pci_exp_devctl_payload_-macros.patch b/queue-4.19/pci-add-pci_exp_devctl_payload_-macros.patch
new file mode 100644 (file)
index 0000000..cfc323c
--- /dev/null
@@ -0,0 +1,41 @@
+From 460275f124fb072dca218a6b43b6370eebbab20d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
+Date: Tue, 5 Oct 2021 20:09:40 +0200
+Subject: PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Pali Rohár <pali@kernel.org>
+
+commit 460275f124fb072dca218a6b43b6370eebbab20d upstream.
+
+Define a macro PCI_EXP_DEVCTL_PAYLOAD_* for every possible Max Payload
+Size in linux/pci_regs.h, in the same style as PCI_EXP_DEVCTL_READRQ_*.
+
+Link: https://lore.kernel.org/r/20211005180952.6812-2-kabel@kernel.org
+Signed-off-by: Pali Rohár <pali@kernel.org>
+Signed-off-by: Marek Behún <kabel@kernel.org>
+Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+Reviewed-by: Marek Behún <kabel@kernel.org>
+Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/uapi/linux/pci_regs.h |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/include/uapi/linux/pci_regs.h
++++ b/include/uapi/linux/pci_regs.h
+@@ -497,6 +497,12 @@
+ #define  PCI_EXP_DEVCTL_URRE  0x0008  /* Unsupported Request Reporting En. */
+ #define  PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
+ #define  PCI_EXP_DEVCTL_PAYLOAD       0x00e0  /* Max_Payload_Size */
++#define  PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000 /* 128 Bytes */
++#define  PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020 /* 256 Bytes */
++#define  PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040 /* 512 Bytes */
++#define  PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060 /* 1024 Bytes */
++#define  PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080 /* 2048 Bytes */
++#define  PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0 /* 4096 Bytes */
+ #define  PCI_EXP_DEVCTL_EXT_TAG       0x0100  /* Extended Tag Field Enable */
+ #define  PCI_EXP_DEVCTL_PHANTOM       0x0200  /* Phantom Functions Enable */
+ #define  PCI_EXP_DEVCTL_AUX_PME       0x0400  /* Auxiliary Power PM Enable */
index 90188fe6f3263becaad014d45d961b25b4494785..eea1c5202f08ea00d1f9ef1ff15d0669133a0443 100644 (file)
@@ -247,3 +247,5 @@ backlight-gpio-backlight-correct-initial-power-state-handling.patch
 video-backlight-drop-maximum-brightness-override-for-brightness-zero.patch
 s390-cio-check-the-subchannel-validity-for-dev_busid.patch
 s390-tape-fix-timer-initialization-in-tape_std_assign.patch
+pci-add-pci_exp_devctl_payload_-macros.patch
+fuse-truncate-pagecache-on-atomic_o_trunc.patch